Skip to content

fix(client): return input_required from callTool before output-schema validation - #3250

Open
mgoldsborough wants to merge 1 commit into
modelcontextprotocol:mainfrom
mgoldsborough:fix-calltool-input-required-output-schema
Open

mgoldsborough wants to merge 1 commit into
modelcontextprotocol:mainfrom
mgoldsborough:fix-calltool-input-required-output-schema

Conversation

@mgoldsborough

Copy link
Copy Markdown

Fixes #3249.

With allowInputRequired: true, callTool ran the outputSchema check before looking at resultType. An input_required result carries no structuredContent, so for any tool that declares an outputSchema, callTool threw Tool <name> has an output schema but did not return structured content, and the caller never saw the input requests. A tool without an outputSchema already got the result back, as allowInputRequired documents.

An input_required result is not a tool result, so the output schema does not apply to it. callTool now returns it before validating. Complete results, including the retry after the caller answers, still validate against the schema. The default auto-fulfil path is unchanged: there the driver completes the rounds inside request(), so callTool only sees a complete result.

Test: a manual-mode case in inputRequiredEngine.test.ts with an outputSchema passed through toolDefinition. The first call returns input_required, and the manual retry returns structured content that validates. It fails on main with the error above.

Not in this PR: callTool is still typed Promise<CallToolResult>, so a manual-mode caller casts the result, as the existing manual-mode tests do. An overload returning CallToolResult | InputRequiredResult when allowInputRequired: true could follow separately.

pnpm lint:all and pnpm build:all pass. In pnpm test:all, everything passes except protocol:timeout:max-total [sse …] in test/e2e, which fails the same way on main without this change in my environment.

… validation

With allowInputRequired: true, callTool ran the outputSchema check on the
result before looking at resultType. An input_required result carries no
structuredContent, so a tool that declares an outputSchema always threw
"has an output schema but did not return structured content" and the caller
never saw the input requests. An input_required result is not a tool result,
so callTool now returns it before validating; complete results still validate.

Fixes modelcontextprotocol#3249
@mgoldsborough
mgoldsborough requested a review from a team as a code owner November 28, 2026 19:49
@changeset-bot

changeset-bot Bot commented Nov 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1b456e3

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/core-internal Patch

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 Nov 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3250

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3250

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3250

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3250

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3250

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3250

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3250

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3250

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3250

commit: 1b456e3

@mgoldsborough

Copy link
Copy Markdown
Author

The one failure is a 5s timeout in dpop.test.ts on Node 20 (key generation, unrelated to this change); it passes locally and on Node 22/24. Could a maintainer re-run it?

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 29, 2026
@prkomb

prkomb commented Nov 29, 2026

Copy link
Copy Markdown

#3249 is the same bug as #3216 (opened 20 Nov), and #3217 has been open for it since then, with the same isInputRequiredResult check in callTool and a manual-mode test in inputRequiredEngine.test.ts. The fixes differ only in where the check sits: #3217 skips the validator block for an input_required result, and this PR returns before it, so callers see the same result either way. On main (5ee54ee), each PR's new test passes against the other's client.ts, and this PR's test fails without the fix.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

callTool with allowInputRequired: true throws on an input_required result when the tool declares an outputSchema

2 participants