Conversation
Every argument-bearing tools/call resolves the called tool's inputSchema by running the full tools/list handler (_mcp_param_rejection -> _tool_input_schema). For a server whose tools/list is expensive (e.g. a gateway aggregating backend servers), that is a large per-call cost even when no tool declares x-mcp-header. Add Server(mcp_param_validation=False) to skip the schema-resolving walk while keeping the default behavior (and all existing validation) untouched. The flag lives on the lowlevel Server and is honored by the modern single-exchange HTTP path; the McpServer wrapper delegates to the same app. Regression tests: with the flag off, an argument-bearing tools/call dispatches without invoking the tools/list handler (list_calls == 0); with the flag on, the missing-header rejection still fires.
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3565. If a maintainer assigns you to #3565, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3565.
Problem
On the 2026-07-28 HTTP path, every
tools/callwith arguments runs the server's fulltools/listhandler before dispatch (_mcp_param_rejection→_tool_input_schema) to resolve the called tool'sinputSchemaforMcp-Param-*header validation. There is no way to opt out, and it runs even when no tool declaresx-mcp-header.For a server whose
tools/listis expensive — e.g. a gateway aggregating several backend MCP servers where listing fans out per-user credentials — this is a large per-call cost on every singletools/call.Change
Add an explicit opt-out on the lowlevel
Server:When
False, the schema-resolvingtools/listwalk is skipped entirely andtools/calldispatches directly. Default remainsTrue, so every existingMcp-Param-*validation behavior is unchanged (missing-header rejection, mismatch rejection, orphan/duplicate header rejection all still fire). TheMcpServerwrapper delegates to the same app, so the flag is honored there too.Tests
test_modern_tools_call_skips_tools_list_when_mcp_param_validation_opted_out: with the flag off, an argument-bearingtools/callreturns 200 and thetools/listhandler is never invoked (list_calls == 0).test_modern_tools_call_runs_tools_list_by_default_for_validation: with the flag on (default), the missing-header rejection for an annotated argument still returns 400HEADER_MISMATCH.Full suite: 5893 passed.