Claude Agent SDK
Getting started
The Claude Agent SDK is Anthropic’s framework for building agents on Claude, available for TypeScript and Python. It connects to external tools through MCP, and AgentMail runs a hosted MCP server, so a Claude agent gets a full email inbox with a few lines of configuration and no extra packages.
To give your Claude agent an email inbox, add the AgentMail server at https://mcp.agentmail.to/mcp to the mcpServers option of query(), authenticate with your AgentMail API key in the x-api-key header, and allow the AgentMail tools with allowedTools. There is no AgentMail package to install or update: the server always exposes the current tool set.
Use cases
- Give agents their own inboxes: Provision a dedicated email address per agent so it can send and receive mail independently.
- Triage and reply: Read recent threads and reply inside the same thread, with threading handled automatically.
- Stage and send: Compose drafts iteratively and send them when they’re ready.
- Inbound-driven agents: Pair the server with AgentMail webhooks so your agent reacts the moment mail arrives.
- Durable email identity: Give long-running Claude agents an address they keep across sessions, so contacts and threads persist between runs.
Prerequisites
- An AgentMail account with an API key from the AgentMail Console.
- The Claude Agent SDK (
@anthropic-ai/claude-agent-sdkfor TypeScript orclaude-agent-sdkfor Python) and an Anthropic API key.
Setup
Install the Claude Agent SDK for your language:
Set your API keys:
Quickstart
Connect the AgentMail MCP server and allow its tools:
Configuring the connection
Authentication
Pass an API key from the AgentMail Console in the x-api-key header, as in the quickstart. The MCP server also supports OAuth sign-in, but that flow is for end-user clients like Claude Desktop. For agents built with the SDK, use the API key header.
Allowing tools
AgentMail tools surface in the SDK as mcp__agentmail__<tool_name>, for example mcp__agentmail__send_message. The mcp__agentmail__* wildcard in allowedTools auto-approves every AgentMail tool.
allowedTools is required. Without it, Claude sees the AgentMail tools but can’t call them.
For production, list only the tools the agent needs:
Available tools
The server exposes 43 tools covering inboxes, threads, messages, drafts, attachments, allow and block lists, and agent sign-up. See the MCP integration for the full list.
Claude Code
If you use the Claude Code CLI rather than the SDK, add the same server with one command:
See MCP setup for Claude Code for details.
Resources
- AgentMail MCP server: docs.agentmail.to/integrations/mcp
- Claude Agent SDK MCP docs: code.claude.com/docs/en/agent-sdk/mcp
- AgentMail Console: console.agentmail.to
