Anthropic MCP Connector

Connect Claude to the DeepWiki MCP server with the native MCP connector beta.

The source uses a retired Sonnet 4 model and the deprecated mcp-client-2025-04-04 beta. Use the current adaptation below with the MCP connector. Anthropic connects to the remote HTTPS server; you do not need a local stdio client for this example.

mcp_connector.py
"""
Anthropic Mcp Connector
=======================

Cookbook example for `anthropic/mcp_connector.py`.
"""

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.utils.models.claude import MCPServerConfiguration

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=Claude(
        id="claude-sonnet-4-20250514",
        betas=["mcp-client-2025-04-04"],
        mcp_servers=[
            MCPServerConfiguration(
                type="url",
                name="deepwiki",
                url="https://mcp.deepwiki.com/sse",
            )
        ],
    ),
    markdown=True,
)

agent.print_response(
    "Tell me about https://github.com/agno-agi/agno",
    stream=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass

Current Adaptation

mcp_connector_current.py
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.utils.models.claude import MCPServerConfiguration

agent = Agent(
    model=Claude(
        id="claude-sonnet-4-6",
        betas=["mcp-client-2025-11-20"],
        mcp_servers=[
            MCPServerConfiguration(
                type="url",
                name="deepwiki",
                url="https://mcp.deepwiki.com/sse",
            )
        ],
    ),
    tools=[{"type": "mcp_toolset", "mcp_server_name": "deepwiki"}],
    markdown=True,
)
agent.print_response("Tell me about https://github.com/agno-agi/agno", stream=True)

This configuration enables the server's tools. For another server, use its URL and authentication settings, and keep the toolset's mcp_server_name equal to the server's name.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno anthropic filetype

Export your Anthropic API key

export ANTHROPIC_API_KEY="your_anthropic_api_key_here"

Run the example

Save the current adaptation as mcp_connector_current.py, then run:

python mcp_connector_current.py

Full source: cookbook/90_models/anthropic/mcp_connector.py