Skip to content

fix(client): pin output schema for in-flight tool calls (v1.x) - #2708

Open
OllieinCanada wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
OllieinCanada:fix/call-tool-schema-generation
Open

fix(client): pin output schema for in-flight tool calls (v1.x)#2708
OllieinCanada wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
OllieinCanada:fix/call-tool-schema-generation

Conversation

@OllieinCanada

Copy link
Copy Markdown

Summary

  • capture a tool's cached output validator before dispatching tools/call
  • keep an in-flight response tied to the schema generation that was active when the call began
  • add a deterministic regression that refreshes the tool catalog while the first call is parked, then verifies the first call uses the old schema and the next call uses the new one
  • add a patch changeset for @modelcontextprotocol/sdk

Why this ordering matters

Client.callTool() currently checks required-task metadata before sending the request, but reads the output validator only after the response arrives. A concurrent listTools() refresh can replace that cache in between, so a valid response may be rejected against a schema that did not exist when the call was dispatched.

The validator is immutable for the lifetime of a call now: it is captured alongside the other dispatch-time metadata, without preventing later calls from using a refreshed catalog.

Fixes #2612.

Validation

  • regression on unmodified v1.30.0: fails with McpError -32602 against the newer schema
  • focused regression after the change: passes
  • client suite: 69/69 passed
  • npm run typecheck
  • npx eslint src/
  • npx prettier --check .
  • npx tsc -p tsconfig.prod.json
  • npx tsc -p tsconfig.cjs.json
Local full-suite note

On this Windows host (Node 20.9.0), the resource-safe full run completed with 1,612 passing tests and four unrelated integration timeouts in processCleanup.test.ts and the Zod v3 half of taskResumability.test.ts; Windows stdio teardown also emitted two pipe errors. The installed Vite/Undici dev dependencies warn that this local Node version is below their current supported 20.x patch level. The changed client suite is green, and the upstream Linux CI matrix is the authoritative full-suite result.

Capture the cached validator before dispatching tools/call so a concurrent listTools refresh cannot validate a response against a newer schema generation. Add a deterministic regression covering both the in-flight and subsequent-call behavior.
@OllieinCanada
OllieinCanada requested a review from a team as a code owner August 24, 2026 07:35
@changeset-bot

changeset-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a992ad4

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2708

commit: a992ad4

@claude claude Bot added the v1 Issues / PRs related to v1.x label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Issues / PRs related to v1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant