Skip to content
,

Claude MCP Connector API: Connect Remote MCP Servers in Python

11โ€“17 minutes
Woman in a brick-walled loft holding a tablet with an MCP CONNECTOR card, hook no MCP client needed

Claude can now talk to a remote MCP server straight from a Messages API request. You add an mcp_servers list and a matching mcp_toolset, and Anthropic handles the MCP connection for you. No MCP client code is needed on your side.

This guide shows the whole thing in Python. You get working examples, tool allow and deny lists, OAuth tokens, the response blocks, prices, limits and fixes for common errors.

TLDR

  • What: the MCP connector lets Claude call tools on a remote MCP server inside one API request.
  • Status: still beta (checked 4 Dec 2026). Send mcp-client-2025-11-20, or the newer mcp-client-2026-09-15 for tool list pinning.
  • Two parts: mcp_servers (URL, name, token) plus one mcp_toolset per server in tools.
  • Limits: tool calls only, public HTTPS servers only (Streamable HTTP or SSE). Local stdio servers do not work.
  • Cost: no separate MCP fee is listed. You pay normal tokens, and tool definitions and results count as input.

What the MCP Connector Is (and When to Use It)

MCP (Model Context Protocol) is an open standard for exposing tools to AI models. Normally your app runs an MCP client, lists the server’s tools, passes them to Claude and runs each call itself.

With the MCP connector, Anthropic’s side does that work. You give the server URL in the request, and Claude can list and call its tools during the same response. Anthropic launched the feature in beta on 22 May 2025, and it has stayed in beta since.

Use it when:

  • The server is remote: it is reachable over public HTTPS, like most hosted MCP servers in our best MCP servers list.
  • You only need tools: the connector supports MCP tool calls, not prompts or resources.
  • You want less code: no MCP SDK, no session handling and no tool loop for those tools.

Note: If you have not made a basic Claude call yet, start with our Claude API Python tutorial. For normal function tools you run yourself, see the Claude tool use tutorial.

Beta Status, Beta Headers and Supported Platforms

The MCP connector is not GA. The official page marks it as beta on every model. In Python you call client.beta.messages.create() and pass a beta flag.

Beta header Status What it adds
mcp-client-2025-11-20 Current mcp_servers plus mcp_toolset with allow, deny and per-tool configs
mcp-client-2026-09-15 Current (newer) Everything above, plus mcp_tool_listing blocks and pinned tool lists
mcp-client-2025-04-04 Deprecated Old tool_configuration inside the server object

The docs list four platforms for the Messages API connector:

  • Claude API (both headers)
  • Claude Models on Google Cloud (Anthropic managed) (both headers)
  • Claude Platform on AWS (mcp-client-2025-11-20 only)
  • Microsoft Foundry (mcp-client-2025-11-20 only)

Supported models include Claude Fable 5.2, Opus 5.5, Sonnet 5.5, Haiku 5.5 and older 4.x models back to Opus 4.5. The examples here use claude-opus-5-5, the anthropic Python SDK 2.17.0 (PyPI, needs Python 3.10+) and API version 2026-10-21.

Claude Platform Docs MCP connector Limitations section: only tool calls supported, server must be public HTTP (Streamable HTTP or SSE), no local STDIO servers
Official Claude Platform Docs MCP connector page: limits and the two request parts (checked 4 Dec 2026).

Setup in 6 Steps

  1. Get an API key. Create one in the Claude Console (our API key guide walks through it). Save it as the ANTHROPIC_API_KEY environment variable.
  2. Install the SDK. Run pip install -U anthropic in a Python 3.10+ virtual environment.
  3. Pick a remote MCP server. Note its HTTPS URL. It must end in an endpoint that speaks Streamable HTTP or SSE. To host your own, follow our build an MCP server in Python guide.
  4. Get a token if needed. If the server uses OAuth, get an access token first (see OAuth below). Store it in an environment variable such as MCP_TOKEN.
  5. Add both halves to the request. One entry in mcp_servers and one mcp_toolset in tools with the same name.
  6. Send the beta flag. Pass betas=["mcp-client-2025-11-20"] and read the mcp_tool_use and mcp_tool_result blocks in the reply.

Example 1: Connect One Remote MCP Server

This is the smallest working call. It enables every tool the server offers.

import os
import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=2000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://example-server.modelcontextprotocol.io/sse",
            "name": "example-mcp",
            "authorization_token": os.environ.get("MCP_TOKEN"),
        }
    ],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "example-mcp"}],
    messages=[{"role": "user", "content": "What tools do you have available?"}],
)

for block in response.content:
    if block.type == "text":
        print(block.text)

The server object has four fields:

  • type: always "url" for now.
  • url: must start with https://.
  • name: a unique label that exactly one toolset must reference.
  • authorization_token: optional OAuth bearer token. Leave the key out if the server is open.

Tip: Claude calls MCP tools only when the request maps to a tool. A general question like “how do Notion databases work?” gets a plain answer even with a Notion server attached.

Example 2: Allow and Deny Specific Tools

The mcp_toolset controls which tools Claude can see. It has two optional parts: default_config for all tools, and configs for single tools by name.

Allowlist: only the tools you name

calendar_toolset = {
    "type": "mcp_toolset",
    "mcp_server_name": "calendar",
    "default_config": {"enabled": False},
    "configs": {
        "search_events": {"enabled": True},
        "list_events": {"enabled": True},
    },
}

Denylist: everything except risky tools

calendar_toolset = {
    "type": "mcp_toolset",
    "mcp_server_name": "calendar",
    "configs": {
        "delete_all_events": {"enabled": False},
        "share_calendar_publicly": {"enabled": False},
    },
}

Settings merge in this order, highest first:

  1. Per-tool settings in configs
  2. Set-level default_config
  3. System defaults (enabled: true, defer_loading: false)

Warning: A misspelled tool name in configs does not raise an error. The API only logs a backend warning, because servers can change tools. So in an allowlist, a typo silently leaves you with fewer tools, and in a denylist it silently leaves a risky tool on.

Reading mcp_tool_use and mcp_tool_result Blocks

When Claude uses an MCP tool, the response gets two new block types. You do not send a tool_result back, because the call already ran on Anthropic’s side.

Block Key fields Meaning
mcp_tool_use id (starts mcptoolu_), name, server_name, input Claude’s call to a server tool
mcp_tool_result tool_use_id, is_error, content What the server returned
mcp_tool_listing mcp_server_name, tools Server’s tool list (only with mcp-client-2026-09-15)

This loop prints a simple trace of what happened:

for block in response.content:
    if block.type == "mcp_tool_use":
        print(f"CALL  {block.server_name}.{block.name} {block.input}")
    elif block.type == "mcp_tool_result":
        status = "ERROR" if block.is_error else "OK"
        texts = [c.text for c in block.content if c.type == "text"]
        print(f"RESULT {status}: {' '.join(texts)[:200]}")
    elif block.type == "text":
        print("CLAUDE:", block.text)

print("stop_reason:", response.stop_reason)
print("input tokens:", response.usage.input_tokens)

For a multi-turn chat, append response.content as the assistant message, unchanged, then add the next user message. Do not rebuild the blocks by hand.

Claude Platform Docs MCP connector validation rules (server must exist, must be used, one toolset per server, unknown tool names only warn) and the mcp_tool_use response block
Official Claude Platform Docs: validation rules and the mcp_tool_use block (checked 4 Dec 2026).

Example 3: Several Servers and Deferred Tool Loading

You can attach more than one server. Each one needs its own entry in mcp_servers and exactly one matching toolset.

import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=4000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[
        {"type": "url", "url": "https://mcp.example1.com/mcp",
         "name": "docs", "authorization_token": os.environ["DOCS_TOKEN"]},
        {"type": "url", "url": "https://mcp.example2.com/sse",
         "name": "tickets", "authorization_token": os.environ["TICKETS_TOKEN"]},
    ],
    tools=[
        {"type": "tool_search_tool_bm25_20251119", "name": "tool_search_tool_bm25"},
        {"type": "mcp_toolset", "mcp_server_name": "docs"},
        {
            "type": "mcp_toolset",
            "mcp_server_name": "tickets",
            "default_config": {"defer_loading": True},
            "configs": {"delete_ticket": {"enabled": False}},
        },
    ],
    messages=[{"role": "user",
               "content": "Find the refund policy doc and list open refund tickets."}],
)

With defer_loading: true, tool descriptions are not sent to the model up front. The tool search tool finds the right ones when needed. This helps when servers expose dozens of tools, since every definition costs input tokens.

A toolset can also take a cache_control breakpoint, so repeated tool definitions are billed at the cheap cache rate. See our prompt caching guide for how breakpoints work.

Example 4: Pin a Server’s Tool List (2026-09-15 Beta)

An MCP server can change its tools at any time. The newer mcp-client-2026-09-15 header lets you freeze the list, so a server update does not change what Claude sees in the middle of a conversation.

import anthropic

client = anthropic.Anthropic()
BETA = ["mcp-client-2026-09-15"]
servers = [{"type": "url",
            "url": "https://example-server.modelcontextprotocol.io/sse",
            "name": "example-mcp"}]
msgs = [{"role": "user", "content": "What tools do you have available?"}]

first = client.beta.messages.create(
    model="claude-opus-5-5", max_tokens=1024, betas=BETA,
    mcp_servers=servers,
    tools=[{"type": "mcp_toolset", "mcp_server_name": "example-mcp"}],
    messages=msgs,
)

listing = next(b for b in first.content if b.type == "mcp_tool_listing")
pinned = [{"name": t.name, "description": t.description,
           "input_schema": t.input_schema} for t in listing.tools]

second = client.beta.messages.create(
    model="claude-opus-5-5", max_tokens=1024, betas=BETA,
    mcp_servers=servers,
    tools=[{"type": "mcp_toolset", "mcp_server_name": "example-mcp",
            "tools": pinned}],
    messages=msgs,
)
print([b.type for b in second.content])  # no mcp_tool_listing now

Note: With this header the reply can start with an mcp_tool_listing block. If your code reads content[0] as text, it will break. Loop over the blocks by type instead.

The Same Call with curl

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "anthropic-beta: mcp-client-2025-11-20" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1000,
    "messages": [{"role": "user", "content": "What tools do you have available?"}],
    "mcp_servers": [{
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse",
      "name": "example-mcp",
      "authorization_token": "'"$MCP_TOKEN"'"
    }],
    "tools": [{"type": "mcp_toolset", "mcp_server_name": "example-mcp"}]
  }'

OAuth Bearer Tokens: How Authentication Works

The connector does not run the OAuth flow for you. Your app must get the access token, pass it as authorization_token, and refresh it before it expires.

For testing, the official MCP Inspector can fetch a token:

  1. Start the inspector. Run npx @modelcontextprotocol/inspector (needs Node.js).
  2. Pick the transport. In the left sidebar set Transport type to SSE or Streamable HTTP, and enter the server URL.
  3. Open auth settings. Click “Open Auth Settings”, then “Quick OAuth Flow”, and approve on the provider’s screen.
  4. Finish the flow. Click Continue in “OAuth Flow Progress” until you see “Authentication complete”.
  5. Copy the token. Copy the access_token value into your environment variable, not into code.

In production, use a normal OAuth library in your backend and store refresh tokens on your server. If you need managed credential storage, Claude Managed Agents can declare MCP servers on the agent and pull credentials from a vault instead.

Pricing and a Worked Cost Example

The pricing page lists no extra per-call fee for the MCP connector. You pay normal token prices. The MCP tool definitions, tool calls and tool results all add input tokens, and any tool use adds a hidden tool system prompt (286 tokens on Opus 5.5, Sonnet 5.5 and Haiku 5.5 with tool_choice auto).

Model Input / 1M Output / 1M Cache read / 1M
Claude Opus 5.5 $4.00 $20.00 $0.20
Claude Sonnet 5.5 $2.00 $10.00 $0.10
Claude Haiku 5.5 (prompts up to 100K) $0.10 $0.50 $0.01

Worked example (Sonnet 5.5). Say one request uses 6,000 input tokens in total (system prompt, 286 tool prompt tokens, tool definitions and one tool result) and 800 output tokens.

  • Input: 6,000 x $2 / 1,000,000 = $0.012
  • Output: 800 x $10 / 1,000,000 = $0.008
  • Total: about $0.02 per request, or about $20 for 1,000 requests

The same request on Opus 5.5 costs about $0.04. MCP calls in the Message Batches API are priced the same as normal calls, and batches get the usual batch discount. Full tables are in our Claude API pricing guide.

Limits and What Is Not Supported

Area Rule
MCP features Tool calls only. No MCP prompts or resources.
Transport Public HTTPS with Streamable HTTP or SSE. No local stdio servers.
Server URL Must start with https://
Toolsets Each server needs exactly one mcp_toolset
Private networks Not reachable directly. MCP tunnels (research preview, request access) can bridge them.
Data retention Not eligible for ZDR or HIPAA. Data is kept under standard policy.
Batches Supported, same per-token pricing
Request size Normal Messages API limits apply (413 request_too_large if exceeded)

MCP Connector vs Running Your Own MCP Client

The Python SDK also has client-side MCP helpers. Install them with pip install "anthropic[mcp]". They convert tools from your own MCP session for the SDK tool runner.

Need MCP connector Own client + SDK helpers
Local stdio server No Yes
MCP prompts and resources No Yes (mcp_message, mcp_resource_to_content)
Code you maintain Very little MCP session, tool loop, retries
Who connects to the server Anthropic Your app
Approval step before each call No built-in pause; use deny lists Yes, you run each call
Token handling Token sent to Anthropic in each request Token stays in your app

Here is the client-side version for a local server:

import asyncio
from anthropic import AsyncAnthropic
from anthropic.lib.tools.mcp import async_mcp_tool
from mcp import ClientSession
from mcp.client.stdio import StdioServerParameters, stdio_client

client = AsyncAnthropic()

async def main():
    params = StdioServerParameters(command="mcp-server")
    async with stdio_client(params) as (read, write):
        async with ClientSession(read, write) as mcp_client:
            await mcp_client.initialize()
            tools = (await mcp_client.list_tools()).tools
            runner = client.beta.messages.tool_runner(
                model="claude-opus-5-5",
                max_tokens=1024,
                messages=[{"role": "user", "content": "What tools do you have?"}],
                tools=[async_mcp_tool(t, mcp_client) for t in tools],
            )
            print(await runner.until_done())

asyncio.run(main())
Quick answer: Use the connector for hosted, tool-only servers you trust. Run your own client when the server is local, private, needs prompts or resources, or when a human must approve each call.

Security Checklist for the MCP Connector

The connector gives Claude a live line to another system, so treat each server like a third-party API with write access. Our MCP security best practices post goes deeper.

  • Trust the server: only connect servers you or a known vendor run. Tool results can carry prompt injection text.
  • Least privilege tokens: request the smallest OAuth scopes, and prefer short-lived tokens you refresh.
  • Allowlist by default: start with default_config.enabled: false and switch on only the tools you need.
  • Deny destructive tools: delete, share and payment tools should be off unless you add your own approval step.
  • Keep secrets out of code: read tokens from environment variables or a secret manager, and never log the request body.
  • Check retention needs: the connector is not ZDR or HIPAA eligible, so do not route regulated data through it.
  • Log tool calls: store each mcp_tool_use name and input so you can audit what Claude did.

Troubleshooting: Common Problems and Fixes

Problem Likely cause Fix
400 invalid_request_error about the MCP server or toolset A server in mcp_servers has no toolset, a toolset name does not match, or one server has two toolsets Make each name match exactly one mcp_server_name
Python TypeError for mcp_servers Called client.messages.create() or an old SDK Use client.beta.messages.create() and upgrade anthropic
Request rejected or server not reached URL uses http:// or points to localhost Serve over public HTTPS, or use your own client for local servers
mcp_tool_result with is_error: true The server rejected the call (bad input, expired token, server bug) Read the error text in content, refresh the token, test the tool in MCP Inspector
Claude never calls the tool Tool disabled, misspelled in configs, or the question did not need it Check spelling, ask a direct task, steer in the system prompt
Old tool_configuration ignored Using the deprecated 2025-04-04 shape Move settings into mcp_toolset and switch headers
Code crashes on content[0].text First block is mcp_tool_listing or mcp_tool_use Loop over blocks and check block.type
429 rate_limit_error or 529 overloaded_error Rate limit or busy API Let the SDK retry, back off, see our 429 and 529 fix guide
401 authentication_error Your Anthropic API key, not the MCP token, is wrong Check ANTHROPIC_API_KEY

Frequently Asked Questions

Is the Claude MCP connector generally available?

No. As of 4 December 2026 the official docs still mark it as beta on every model. You must send mcp-client-2025-11-20 or mcp-client-2026-09-15 through the beta Messages endpoint.

Can I connect a local stdio MCP server?

Not with the connector. It only reaches public HTTPS servers using Streamable HTTP or SSE. For local servers, run your own MCP client and use the SDK’s anthropic[mcp] helpers.

Does the MCP connector cost extra?

The pricing page lists no separate MCP fee. You pay normal input and output tokens, and tool definitions, calls and results all count as input.

Do I need to send tool results back myself?

No. Anthropic runs the MCP call and puts the mcp_tool_result block in the same response. You only send the assistant content back unchanged in later turns.

How do I block a dangerous tool?

Add it to configs with "enabled": false. For tighter control, set default_config.enabled to false and enable only the tools you name.

Can I use more than one MCP server in a request?

Yes. Add each server to mcp_servers and give each one exactly one mcp_toolset. Use defer_loading with the tool search tool when there are many tools.

Does the MCP connector work on Amazon Bedrock or Vertex AI?

The docs list the Claude API, Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed) and Microsoft Foundry. Bedrock and Google-managed Vertex AI are not on that list.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a brick-walled loft holding a tablet with an MCP CONNECTOR card, hook no MCP client needed