Mails.ai
for Claude Code
Built in
Email tools inside Claude Code
Claude Code calls the mails tools when a task needs email, and shows you each call and what came back.
❯ Send a test from the hello agent to reply@test.mails.ai and show me the answer
- tool mails_sendagent: "hello"to: "reply@test.mails.ai"subject: "Test"body_text: "Hello from Claude Code"
{ "id": "msg_01K…", "status": "delivered", … }
- tool mails_list_repliesagent: "hello"
{ "data": [{ "type": "reply.received", "data": { "subject": "Re: Test", … } }] }
The test address answered in the same thread: “This is an automatic reply from the mails.ai test address.”
Setup
Add mails to Claude Code
Add to ~/.claude.json under mcpServers, then restart Claude Code.
{
"mcpServers": {
"mails": {
"command": "npx",
"args": ["-y", "@mailsai/mcp-server"],
"env": {
"MAILS_API_KEY": "mk_live_..."
}
}
}
}Claude Code reads the whole thread first, then replies from the agent’s own address.
Hosted or local
Or sign in to the hosted server
One command adds https://api.mails.ai/mcp. Then type /mcp in Claude Code and choose mails, or run claude mcp login mails, and sign in. No key sits in a file. The MCP server page has the rest.
claude mcp add --transport http mails \
https://api.mails.ai/mcp
# then type /mcp in Claude Code and choose mails,
# or sign in from your shell:
claude mcp login mailsKnow-how
Teach Claude Code about email
Three open-source skills teach Claude Code to send, receive and safely act on email. The command asks which to add.
npx skills add mailsai/skills -a claude-codeIn action
See the skills
in action
With the skills added, Claude Code checks a message before it answers it, and replies in the same thread.
This guide shows you how to give Claude Code email capabilities. Your agent can send and receive email without any extra tooling. You’ll need a mails.ai API key and about ten minutes.
Claude Code is an MCP-capable runtime. The mails.ai MCP server is an npm-distributed process that exposes email primitives as tools. Drop the snippet above into ~/.claude.json, restart Claude Code, and your session can send, read, and manage email without any SDK install or glue code on your end.
Why Claude Code + mails.ai
Claude Code already runs the Anthropic Sonnet/Opus models with a tool-calling loop. Adding email as an MCP tool means the model picks mails_send or mails_list_threads autonomously when the user’s request implies email work — no per-task prompt engineering, no separate API client to wire up. The same Claude Code session that edits your code can also reply to support tickets, send out scheduled communications, and parse inbound replies.
And because the MCP server runs client-side via npx, there is nothing to host on your end. The server is a thin tool-shape over the public REST API, with auth and retries handled in one place.
Setup — three steps
- Get an API key. Sign in at
app.mails.ai/api-keysand mint one — self-serve, free tier, no card. A key can be bound to one agent. - Add the MCP server config. Open
~/.claude.jsonin your editor of choice and add the snippet from the install card above (replacingmk_live_...with your key). IfmcpServersalready exists, just addmailsas a sibling key. - Restart Claude Code. The next session starts the MCP server via
npxat startup. Tool discovery is automatic — you can verify by typing/mcpin Claude Code and looking for themailsentry.
First commands to test
After restart, prompt your Claude Code session naturally — the model will reach for the right tool:
# Verify the integration
> What mails_* tools do I have access to?
# Send a test email
> Use mails_send to email myself a hello message.
# Check replies
> List the most recent threads from the last day.For each prompt, Claude Code calls the appropriate mails_* tool, returns the structured result, and presents it back. No glue code, no manual JSON wrangling.
Common patterns
These built-in tools cover most agent workflows:
mails_send— send an email from a named agent. Returns the messageid, itsthread_idandstatus, and the cold-email firewall’sclassifier_score, from 0 (clean) to 1 (cold or spam), which shows how the send was graded.mails_list_replies— list an agent’s typed reply events (reply.received), withsincefor polling. For push delivery, register a webhook.mails_list_threads— query the agent’s conversation history. Filter by agent or status (open, closed, archived). Read-only, free.mails_check_suppression— check whether an address is suppressed;mails_allowlist_addressoverrides that for one address with a written reason. Sends to suppressed addresses return a structured error rather than firing.mails_get_reputation— query an agent’s reputation score (0-1), workspace-scoped. Useful to catch an at-risk agent before the 0.3% complaint auto-suspend. For a high-stakes inbound, check the event’ssender_reputationandinjection_score.
Security considerations
- Key scope. A key bound to one agent can act only as that agent, so a leak stays with it. Rotate keys via
app.mails.ai/api-keys. - Tool refusal under injection. The reply.received event includes
injection_score. Hold the event for a person instead of acting when it isquarantined, has no score (it was not scanned) or scores 0.5 or more — the prompt-injection RCE class is real (see that post) and Claude Code reading instructions from the body and following them is exactly the failure mode the score is designed to gate. - High-stakes confirmation. If your Claude Code agent has both
mails_sendand tools for irreversible actions (database writes, money movement), require an explicit human-in-the-loop confirmation before sending on behalf of those actions. The MCP tool surface itself does not enforce this; your agent prompt and runtime configuration do. - Project vs user scope. Add the server at local scope (the default) so only this project sees the key, or commit
.mcp.jsonwith"MAILS_API_KEY": "${MAILS_API_KEY}"and set the variable in CI. User-scope servers in~/.claude.jsonapply to all your projects.
What ships next
The tools above ship today on the Free, Pro and Scale plans, billed monthly or yearly. The hosted server at https://api.mails.ai/mcp signs in with OAuth, so no key sits in a file. Per-agent hourly and daily send limits, when you set them, are enforced; a send past the limit gets a 429.
Read the MCP-native email post for the broader distribution thesis, or the architecture page for what the server calls under the hood.
Read next: MCP-native email — distribution wedge and Typed reply events for agents.
Questions developers ask after wiring this up.
Where do I get an API key?
Does this work with Claude Code’s task tool / sub-agents?
How do I read replies in Claude Code?
What about secrets — my MAILS_API_KEY in ~/.claude.json?
“Replies come back as events with an injection score already on them. We deleted a whole layer of parsing code the week we switched, and we gate on the quarantine flag, so our agent never sees the ones that look like attacks.”
“Moving our agent onto our own domain was a few DNS records at the registrar. No nameserver move, and our existing mail kept working. Replies to the agent still come back to its inbox, threaded with the message they answer.”
“Our agent writes every reply as a draft, with a key that can’t send. Someone on the team reads it and hits Send now in the dashboard.”
“Our tests send to the test address and wait for the real reply, so the whole loop is covered before a customer ever writes in. It answers in about a second, which keeps the suite fast.”
“Adding the MCP server was one JSON block. Claude Code could send and read its own inbox a minute later.”
“A reputation score per agent tells us exactly which one needs attention, instead of one number for the whole account. It comes from each agent’s own replies, bounces and complaints, and we read it from the API.”
“Sends and replies have separate allowances, so a busy inbox never eats our sending quota. Pricing was the easy part.”
“Half our agents are LangGraph in Python and half are Node. Both SDKs make the same calls, so the team doesn’t have to think about it.”
“Signed webhooks, retries with backoff and an event id to dedupe on. The boring plumbing, done properly.”
“We signed up, made a key and sent our first message without talking to anyone, and the free tier never asked for a card. That’s how infrastructure should feel.”
Give your first agent an inbox
Free covers 3,000 emails and 3,000 inbound replies a month, with no card. Upgrade when your agents get busy.
Get your API key