Creativity · MCP — integration
MCP + Anthropic SDK Integration
The Anthropic SDK accepts MCP-style tool definitions natively in 2026. A developer points the SDK at one or more MCP servers, the SDK advertises those servers' tools to Claude, and when Claude chooses to call a tool the SDK routes the request back to the MCP server, streams the result, and feeds it into the next model turn. This is the standard path for building custom agents on top of Claude Opus 4 and Sonnet 4.
MCP facts
- Kind
- integration
- Ecosystem
- anthropic-mcp
- Language
- Python / TypeScript
- Transports
- stdio, http
Capabilities
- Register one or more MCP servers with an Anthropic client session
- Auto-advertise tools and resources to the Messages API
- Route tool calls back to the appropriate MCP server and stream results
- Compatible with prompt caching and extended context windows
Install
pip install anthropic mcp # or: npm i @anthropic-ai/sdk @modelcontextprotocol/sdk Configuration
from anthropic import Anthropic
from anthropic.mcp import StdioServer
client = Anthropic()
fs = StdioServer(command="npx", args=["-y", "@modelcontextprotocol/server-filesystem", "./repo"])
resp = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
mcp_servers=[fs],
messages=[{"role": "user", "content": "Summarise the repo's README."}],
) Frequently asked questions
Does the SDK auto-handle the tool-use loop?
Yes — when you pass mcp_servers, the SDK handles tool_use/tool_result round-trips internally and returns the final assistant message to the caller.
Can I mix MCP and inline tools?
Yes — pass both `tools=[...]` and `mcp_servers=[...]`. The SDK merges them. This is common when you want MCP servers for reusable capabilities and inline tools for app-specific logic.
What about prompt caching?
Anthropic's cache-control blocks still apply. Cache MCP tool schemas alongside system instructions to reduce per-turn token cost in long sessions.
Sources
- Anthropic Python SDK — accessed 2026-04-20
- Anthropic TypeScript SDK — accessed 2026-04-20
- MCP specification — accessed 2026-04-20