Repository navigation
Open
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working onv1Issues / PRs related to v1.x
Description
Description
Client.callTool() retrieves the cached output validator after awaiting the tools/call response.
If listTools() runs while that request is pending, cacheToolMetadata() clears and replaces the validator cache. The completed call can therefore be validated against a newer schema than the one active when the call started.
Reproduction
- List a tool whose output schema requires
{ generation: "old" }. - Start a delayed
callTool()for that tool. - While it is pending, refresh the tool list with a schema requiring
{ generation: "new" }. - Complete the original call with
{ generation: "old" }.
Actual result:
McpError -32602: Structured content does not match the tool's output schema
Expected result:* The call is validated using the schema generation active when the call began.
Proposed fix
Capture the validator before yielding to the request:
const validator = this.getToolOutputValidator(params.name);
const result = await this.request(
{ method: "tools/call", params },
resultSchema,
options,
);This is consistent with the existing required-task check, which is also performed before the request.
diff --git a/src/client/index.ts b/src/client/index.ts
--- a/src/client/index.ts
+++ b/src/client/index.ts
@@
if (this.isToolTaskRequired(params.name)) {
throw new McpError(
ErrorCode.InvalidRequest,
`Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`
);
}
- const result = await this.request({ method: 'tools/call', params }, resultSchema, options);
-
- // Check if the tool has an outputSchema
+ // A concurrent listTools() can replace the cache while this request is
+ // in flight. Capture the validator used when the call is dispatched.
const validator = this.getToolOutputValidator(params.name);
+ const result = await this.request({ method: 'tools/call', params }, resultSchema, options);
if (validator) {
// If tool has outputSchema, it MUST return structuredContent (unless it's an error)
if (!result.structuredContent && !result.isError) {Affected versions
Reproduced with @modelcontextprotocol/sdk 1.30.0.
Metadata
Metadata
Assignees
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working onv1Issues / PRs related to v1.x
Activity
Linxiushen commentedon Aug 5, 2026
I would like to work on this. I verified that the v1.x client still resolves the output validator after awaiting the tools/call response, so a concurrent tools/list refresh can replace the schema generation used by an in-flight call. I plan to target v1.x with a deterministic regression test that pauses tools/call, refreshes the catalog, and verifies the original response is validated against the dispatch-time schema, then move the validator lookup before the request await. Please assign it to me if that approach looks right.