Skip to content

mcp: find an uncached tool's definition in CallTool for Mcp-Param headers - #1483

Closed
sundarshahi wants to merge 1 commit into
modelcontextprotocol:mainfrom
sundarshahi:fix-1481-calltool-param-headers
Closed

sundarshahi wants to merge 1 commit into
modelcontextprotocol:mainfrom
sundarshahi:fix-1481-calltool-param-headers

Conversation

@sundarshahi

Copy link
Copy Markdown

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. docs/protocol.md promises the headers whenever a client calls an annotated tool over HTTP.

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.

Tests:

gofmt, go vet ./..., go test -race ./... and go generate ./... (docs) are clean locally.

The trade-off is one extra tools/list round 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

…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
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Oct 31, 2026
@github-actions

Copy link
Copy Markdown
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 missing-issue-link, or add bypass-issue-check to override.

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

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant