# Claude SDK

## Install

```bash
pip install anthropic
```

---

## How it works

The Anthropic SDK's MCP connector is different from other frameworks. Rather than giving you a direct MCP client, it lets the **Anthropic API** act as the MCP client on your behalf. You attach the MCP server to your API call, Claude decides which tools to call, and the API handles the MCP protocol round-trip.

You cannot call `list_tools()` or `call_tool()` imperatively. The model drives all tool use.

That suits MewCP well. Claude sees four tools, `search`, `get_schema`, `list_accounts`, and `call_tool`, and uses them to reach every app you have connected. See [How MewCP works](/mewcp/getting-started#how-mewcp-works).

---

## Example

```python
import anthropic

MEWCP_API_KEY = "API_KEY"

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-5",
    max_tokens=2048,
    messages=[
        {
            "role": "user",
            "content": "What is on my calendar tomorrow?",
        }
    ],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://gateway.mewcp.com/personal/mcp",
            "name": "mewcp",
            "authorization_token": MEWCP_API_KEY,
        }
    ],
    betas=["mcp-client-2025-11-20"],
)

# The response may contain text blocks and mcp_tool_result blocks
for block in response.content:
    if hasattr(block, "text"):
        print(block.text)
```

One server entry covers every app you have connected. Connecting another app in the dashboard needs no change here.

---

## Choosing an account

When you have connected more than one account for the same app, say which one you mean in the prompt. Claude will call `list_accounts` and pick it by alias:

```python
messages=[
    {
        "role": "user",
        "content": "Check my work Gmail for anything from the design team.",
    }
]
```

---

## Important notes

- `authorization_token` sends the value as `Authorization: Bearer <token>`. Do not put `Bearer` in the value.
- The beta header is `"mcp-client-2025-11-20"`. The older `mcp-client-2025-04-04` is deprecated.
- Only MCP **tools** are supported via this connector. Prompts and resources are not exposed.
- The server URL must be `https://`.

---

## Where to find your values

| Value          | Where to get it       |
| -------------- | --------------------- |
| `API_KEY`      | Dashboard -> API Keys |
| Connected apps | Dashboard -> Servers  |
