TanStack / TanStack/ai

ai-anthropic: modelOptions.mcp_servers is forwarded without the mcp-client beta header

Open
#1,424 0 comments 0 reactions 1 assignee View on GitHub

@tombeckenham is already working on this.

Since Sep 19, 2026.

has-pr waiting-on: maintainer
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_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):

  1. chat({ adapter: anthropicText('claude-sonnet-4-5'), messages, modelOptions: { mcp_servers: [{ type: 'url', name: 'x', url: 'https://mcp.example.com' }] } })
  2. 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
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.