TanStack AI version
@tanstack/ai 0.56.0, @tanstack/ai-anthropic 0.18.8 (current main, bffdd18)
Framework/Library version
Any (server-side, framework-independent). @anthropic-ai/sdk 0.112.4.
Describe the bug and the steps to reproduce it
modelOptions.mcp_servers is forwarded to the Messages API body, but the required beta header is never sent. This is the same shape as #1074 (context_management forwarded without context-management-2025-06-27), which #1080 fixed.
mcp_servers is in the validKeys allowlist in packages/ai-anthropic/src/adapters/text.ts, so it reaches the request body.
computeAnthropicBetas in the same file only looks at thinking, context_management, and the code-execution / skills tools. It never adds mcp-client-2025-11-20.
- The SDK does not inject it either:
client.beta.messages.create sends exactly the betas it is given (resources/beta/messages/messages.js, 'anthropic-beta': betas?.toString()).
- The existing test
forwards container, mcp_servers, service_tier, ... to the beta client asserts the body but not payload.betas, so nothing catches it.
Anthropic's MCP connector docs require the header: https://platform.claude.com/docs/en/agents-and-tools/mcp-connector (anthropic-beta: mcp-client-2025-11-20).
Steps to reproduce (no API key needed):
chat({ adapter: anthropicText('claude-sonnet-4-5'), messages, modelOptions: { mcp_servers: [{ type: 'url', name: 'x', url: 'https://mcp.example.com' }] } })
- Inspect the
betaMessagesCreate payload (or the outgoing request): mcp_servers is present, betas is undefined.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Reproduces in the package's own test suite — add expect(payload.betas).toContain('mcp-client-2025-11-20') to the mcp_servers test in packages/ai-anthropic/tests/anthropic-adapter.test.ts and it fails on main.
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes — PR incoming: add the beta in computeAnthropicBetas when mcp_servers is a non-empty array, assert payload.betas in the test, patch changeset.
Terms & Code of Conduct
TanStack AI version
@tanstack/ai0.56.0,@tanstack/ai-anthropic0.18.8 (currentmain, bffdd18)Framework/Library version
Any (server-side, framework-independent).
@anthropic-ai/sdk0.112.4.Describe the bug and the steps to reproduce it
modelOptions.mcp_serversis forwarded to the Messages API body, but the required beta header is never sent. This is the same shape as #1074 (context_managementforwarded withoutcontext-management-2025-06-27), which #1080 fixed.mcp_serversis in thevalidKeysallowlist inpackages/ai-anthropic/src/adapters/text.ts, so it reaches the request body.computeAnthropicBetasin the same file only looks atthinking,context_management, and the code-execution / skills tools. It never addsmcp-client-2025-11-20.client.beta.messages.createsends exactly thebetasit is given (resources/beta/messages/messages.js,'anthropic-beta': betas?.toString()).forwards container, mcp_servers, service_tier, ... to the beta clientasserts the body but notpayload.betas, so nothing catches it.Anthropic's MCP connector docs require the header: https://platform.claude.com/docs/en/agents-and-tools/mcp-connector (
anthropic-beta: mcp-client-2025-11-20).Steps to reproduce (no API key needed):
chat({ adapter: anthropicText('claude-sonnet-4-5'), messages, modelOptions: { mcp_servers: [{ type: 'url', name: 'x', url: 'https://mcp.example.com' }] } })betaMessagesCreatepayload (or the outgoing request):mcp_serversis present,betasisundefined.Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Reproduces in the package's own test suite — add
expect(payload.betas).toContain('mcp-client-2025-11-20')to themcp_serverstest inpackages/ai-anthropic/tests/anthropic-adapter.test.tsand it fails onmain.Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes — PR incoming: add the beta in
computeAnthropicBetaswhenmcp_serversis a non-empty array, assertpayload.betasin the test, patch changeset.Terms & Code of Conduct