Repository navigation
mcp: find an uncached tool's definition in CallTool for Mcp-Param headers - #1483
Closed
sundarshahi wants to merge 1 commit into
Closed
sundarshahi wants to merge 1 commit into
sundarshahi wants to merge 1 commit into
Conversation
…ders On 2026-07-28 over the streamable transport, CallTool takes the tool definition for SEP-2243 x-mcp-header annotations only from the ListTools cache. A session that calls a tool without listing it first sends no Mcp-Param-* headers, and a go-sdk server rejects the call with 400. On a cache miss, CallTool now pages through tools/list until it finds the tool, which also fills the cache for later calls. It does so only when the session sends these headers (2026-07-28 over the streamable connection), so stdio and legacy sessions make no extra request. If listing fails or the tool is not listed, the call goes out without the headers, as before. Fixes modelcontextprotocol#1481
Contributor
|
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 #1481. 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. There's no need to open a new PR either way. Maintainers: reopen, remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On 2026-07-28 over the streamable transport,
CallTooltakes the tool definition for SEP-2243x-mcp-headerannotations only from theListToolscache. A session that calls a tool without listing it first sends noMcp-Param-*headers, and a go-sdk server rejects the call with 400.docs/protocol.mdpromises the headers whenever a client calls an annotated tool over HTTP.On a cache miss,
CallToolnow pages throughtools/listuntil it finds the tool, which also fills the cache for later calls. It does so only when the session sends these headers (2026-07-28 over the streamable connection), so stdio and legacy sessions make no extra request. If listing fails or the tool is not listed, the call goes out without the headers, as before.Tests:
TestStreamableParamHeadersWithoutListTools: the reproduction from mcp: ClientSession.CallTool omits Mcp-Param-* headers unless the tool is in the ListTools cache, so a call without a prior tools/list is rejected #1481, with no priorListToolsand nottlMs; it fails onmainwithmissing Mcp-Param-Region header ... Bad Request.TestCallToolWithoutListToolsNonHTTP: an in-memory 2026-07-28 session sends notools/listfromCallTool.TestStreamableClientHandlerErrorPropagation: its fake server now answers thetools/listlookup.gofmt,go vet ./...,go test -race ./...andgo generate ./...(docs) are clean locally.The trade-off is one extra
tools/listround trip the first time an unlisted tool is called. If you'd rather avoid it, the alternative is an exported way to pass the definition (e.g.mcp.WithToolDefinition(ctx, tool)), which I can switch to.Could a maintainer assign #1481 to me so this can reopen?
AI-assisted: I used an AI coding assistant and reviewed and tested every change.
Fixes #1481