ai-anthropic: modelOptions.mcp_servers is forwarded without the mcp-client beta header
@tombeckenham is already working on this.
Since Sep 19, 2026.
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 331
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 160
Description
TanStack AI version
@tanstack/ai 0.56.0, @tanstack/ai-anthropic 0.18.8 (current main, bffdd186)
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.