ai-mcp: modern tool calls omit x-mcp-header parameter headers in 0.9.0
I maintainer di solito rispondono entro 1 giorno
@tombeckenham ci sta già lavorando.
Dal 15/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 32/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Start in src/tools.ts, where callMcpTool sends modern calls through rawRequest, and in src/client.ts, where tools/list is requested directly. Run the inline Deno repro to confirm Mcp-Param-Region is missing from tools/call headers. Done when a discovered tool with an x-mcp-header argument sends the matching Mcp-Param header and the strict fixture passes, with input-required handling still working.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
TanStack AI version
@tanstack/[email protected]. The same behavior was observed with 0.8.3.
Framework/Library version
@modelcontextprotocol/[email protected], Deno 2.9.7, TypeScript 6.0.3, macOS arm64. The reproduction calls the MCP client directly and does not require React, an AI model, or a chat framework.
Describe the bug and the steps to reproduce it
Modern MCP tool calls made through createMCPClient().tools() omit the HTTP headers required by a tool's x-mcp-header input-schema annotations. The JSON arguments and standard Mcp-Name header are present, but the corresponding Mcp-Param-* headers are absent.
This breaks tools on GitHub's remote MCP server that declare owner and repo with x-mcp-header. For example, get_file_contents is rejected with HTTP 400, JSON-RPC error -32020, because Mcp-Param-owner and Mcp-Param-repo are missing. Discovery and tools without those annotated arguments, such as get_me and search_code, can succeed on the same connection. This is therefore easy to miss in a connection or basic tool smoke test.
- Connect using MCP protocol
2026-07-28andStreamableHTTPClientTransport. - Discover a tool whose input schema contains
region: { type: "string", "x-mcp-header": "Region" }. - Execute the discovered TanStack tool with
{ region: "eu" }. - Inspect the outgoing
tools/callheaders.Mcp-Param-Regionis missing. - Repeat with the same transport fixture and native SDK
Client.listTools()/Client.callTool(). The SDK sendsMcp-Param-Region: eu.
Expected: the TanStack adapter preserves the SDK's schema-driven header mirroring, so the same tool can be called successfully through either client.
Reproduced after installing @tanstack/[email protected]. The fixture rejects a missing or mismatched header with HTTP 400 and error code -32020. Each path sent one tools/call:
| Client | Mcp-Name |
Mcp-Param-Region |
Result |
|---|---|---|---|
TanStack 0.9.0 |
lookup |
absent (null) |
Fails with ProtocolError, message Missing or mismatched Mcp-Param-Region header |
Native SDK 2.3.1 |
lookup |
eu |
Succeeds |
Minimal reproducible example
The complete tested example is inline below. Save it as header-repro.mts and run it with Deno after resolving the pinned npm dependencies. It uses fake fetch responses and needs no MCP server, GitHub account, credentials, or AI model.
import { createMCPClient } from "npm:@tanstack/[email protected]"
import { Client, StreamableHTTPClientTransport } from "npm:@modelcontextprotocol/[email protected]"
const tool = {
name: "lookup",
inputSchema: {
type: "object" as const,
properties: { region: { type: "string", "x-mcp-header": "Region" } },
required: ["region"],
},
}
async function reproduce(kind: "tanstack" | "native") {
const calls: unknown[] = []
const transport = new StreamableHTTPClientTransport(new URL("https://fixture.example/mcp"), {
protocolVersion: "2026-07-28",
fetch: async (_url, init) => {
const body = JSON.parse(String(init?.body))
const headers = new Headers(init?.headers)
if (body.method === "tools/call") {
const region = headers.get("Mcp-Param-Region")
calls.push({ method: body.method, name: headers.get("Mcp-Name"), region })
if (region !== body.params.arguments.region)
return Response.json({ jsonrpc: "2.0", id: body.id, error: {
code: -32020, message: "Missing or mismatched Mcp-Param-Region header",
} }, { status: 400 })
}
const result = body.method === "server/discover"
? { supportedVersions: ["2026-07-28"], serverInfo: { name: "fixture", version: "1" }, capabilities: { tools: {} } }
: body.method === "tools/list"
? { tools: [tool] }
: { content: [{ type: "text", text: "ok" }] }
return Response.json({ jsonrpc: "2.0", id: body.id, result: {
resultType: "complete", ttlMs: 0, cacheScope: "private", ...result,
} })
},
})
let client: { close(): Promise<void> } | undefined
try {
if (kind === "tanstack") {
const mcp = await createMCPClient({ transport })
client = mcp
const [remote] = await mcp.tools()
await remote!.execute!({ region: "eu" }, undefined)
} else {
const mcp = new Client({ name: "control", version: "1" }, {
versionNegotiation: { mode: { pin: "2026-07-28" } },
})
client = mcp
await mcp.connect(transport)
await mcp.listTools()
await mcp.callTool({ name: "lookup", arguments: { region: "eu" } })
}
return { kind, success: true, calls }
} catch (error) {
return { kind, success: false, calls, error: String(error) }
} finally {
await client?.close()
}
}
console.log(JSON.stringify(await Promise.all([reproduce("tanstack"), reproduce("native")]), null, 2))
Cause identified in the published source
In @tanstack/[email protected]/src/tools.ts, callMcpTool sends modern calls through rawRequest, which calls transport.send(message) directly without send options. This bypasses Client.callTool, where SDK 2.3.1 derives the Mcp-Param-* headers from the tool definition. The transport adds standard protocol headers but cannot derive argument-specific headers without the schema.
Modern discovery in src/client.ts also uses a raw tools/list request rather than native Client.listTools(). A fix that routes calls through the SDK should therefore also populate its tool-definition cache or pass the explicit tool definition. The Streamable HTTP specification describes these required headers and their encoding.
The same rawRequest call also omits the transport's requestSignal option. It listens for abort to settle its own promise, but does not forward that signal through this send call. This is an adjacent source observation, not needed to reproduce the header failure, and may warrant separate cancellation coverage.
Possible fix and regression coverage
Could modern calls use the native SDK Client.callTool with the discovered toolDefinition and allowInputRequired: true, while preserving the adapter's manual input-required handling? This is a suggested direction, not a tested patch. The current follow-up call carrying inputResponses and requestState needs equivalent handling, and output validation, abort behavior, and retry semantics should remain intentional. Using native aggregated listTools() would also populate the SDK cache and retain its validation of header declarations.
The strict fixture above provides a regression test: a discovered modern tool with an x-mcp-header argument must send the matching Mcp-Param-* header and complete successfully. It currently fails with the latest TanStack release and passes with the native SDK.
- Lingua principale
- TypeScript
- Stelle
- 3.2k
- Fork
- 361
- Merge medio
- 1g 8h
- PR unite (30g)
- 266
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/ai
-
Discriminate status-dependent record and option types (RunRecord, SessionIndexEntry, InputState, durable-only options)Forse già presa @jherr l’ha presa oggi. Apertaenhancement waiting-on: maintainer
TanStack/ai#1799 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
ai-harness: an input with no principal runs with the owner session's principalForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#1797 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
ai-harness: a forwarded command completes with no result, also when the owner rejects itForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#1796 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
ai-harness: recovery runs a turn without the user message when the turn never startedForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#1795 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Responses replay puts assistant text between function_call and function_call_outputForse già presa @tombeckenham l’ha presa 1 giorno fa. Apertawaiting-on: maintainer
TanStack/ai#1792 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
aws/agentcore-cli#2606 ·
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa bug Cosmetic
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa bug claude Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
linagora/twake-mail-admin#301 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
anomalyco/opencode#56038 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno