Repository navigation
Description
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_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.- The SDK does not inject it either:
client.beta.messages.createsends exactly thebetasit is given (resources/beta/messages/messages.js,'anthropic-beta': betas?.toString()). - The existing test
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' }] } })- Inspect the
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 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
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity
fix(ai-anthropic): send the mcp-client beta when mcp_servers is set (T…