Repository navigation
fix(client): return input_required from callTool before output-schema validation - #3250
Conversation
… 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
🦋 Changeset detectedLatest commit: 1b456e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
|
The one failure is a 5s timeout in |
|
#3249 is the same bug as #3216 (opened 20 Nov), and #3217 has been open for it since then, with the same |
Fixes #3249.
With
allowInputRequired: true,callToolran theoutputSchemacheck before looking atresultType. Aninput_requiredresult carries nostructuredContent, so for any tool that declares anoutputSchema,callToolthrewTool <name> has an output schema but did not return structured content, and the caller never saw the input requests. A tool without anoutputSchemaalready got the result back, asallowInputRequireddocuments.An
input_requiredresult is not a tool result, so the output schema does not apply to it.callToolnow 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 insiderequest(), socallToolonly sees a complete result.Test: a manual-mode case in
inputRequiredEngine.test.tswith anoutputSchemapassed throughtoolDefinition. The first call returnsinput_required, and the manual retry returns structured content that validates. It fails onmainwith the error above.Not in this PR:
callToolis still typedPromise<CallToolResult>, so a manual-mode caller casts the result, as the existing manual-mode tests do. An overload returningCallToolResult | InputRequiredResultwhenallowInputRequired: truecould follow separately.pnpm lint:allandpnpm build:allpass. Inpnpm test:all, everything passes exceptprotocol:timeout:max-total [sse …]intest/e2e, which fails the same way onmainwithout this change in my environment.