Guide · MCP
Let Claude Code receive email verification codes
Claude Code can fill in a sign-up form, but the moment the site says “we sent you a code” it is stuck: it has no inbox. This guide connects Claude Code (and Claude Desktop or Cursor) to the RESTAPI.email remote MCP server, so Claude can wait for the verification email and read the one-time code or magic link as a tool call.
Setup is one command. The rest of the guide is about doing it safely: a key that can read one inbox and nothing else, prompts that never pick up an old code, and permissions that keep destructive tools behind a prompt.
Last reviewed:
What you need
- A RESTAPI.email account on any plan (pricing). There is no free tier.
- An inbox, for example
signup-bot@agent.restapi.email, created in the dashboard. - An
sk_live_API key limited to that inbox. Keys are shown once and stored hashed; revoke one in the dashboard at any time. - Claude Code, Claude Desktop with Node.js, or Cursor.
The inbox is receive-only: Claude can read what arrives, but nothing can be sent from it. Messages are kept for 30 days and attachments are discarded before storage.
1. Connect the MCP server to Claude Code
The server lives at https://api.restapi.email/mcp and speaks Streamable HTTP. It is stateless and needs no OAuth: the API key travels in an X-API-Key header (Authorization: Bearer works too).
# Available to you in this project (Claude Code's default "local" scope)
claude mcp add --transport http restapi-email https://api.restapi.email/mcp \
--header "X-API-Key: sk_live_..."
# Or in every project on this machine
claude mcp add --transport http --scope user restapi-email https://api.restapi.email/mcp \
--header "X-API-Key: sk_live_..."Inside Claude Code, run /mcp: restapi-email should be listed as connected. Ask “which inboxes can you read?” and Claude calls list_inboxes, which answers with exactly the addresses the key can read.
Sharing the setup with your team
A project-scoped server is written to .mcp.json in the repository, which is meant to be committed. Do not put the key in it. Reference an environment variable instead and let each developer (or the CI runner) set RESTAPI_EMAIL_KEY themselves:
{
"mcpServers": {
"restapi-email": {
"type": "http",
"url": "https://api.restapi.email/mcp",
"headers": { "X-API-Key": "${RESTAPI_EMAIL_KEY}" }
}
}
}2. Ask Claude to sign up and verify
The one detail that matters is ordering. If Claude waits for “a verification email” after submitting the form, any code already sitting in the inbox matches at once, and it types yesterday’s code. So the prompt tells it to mark the inbox first:
Sign me up for a trial at https://example.com/signup using
signup-bot@agent.restapi.email. Before you submit the form, call
list_messages on that inbox with limit 1 and keep the newest id.
After submitting, call get_verification_code with that id as since
and from_contains "example.com", then enter the code (or open the
link) to finish. Do not read or delete any other email.Claude Code also reads the server’s own instructions, which describe the same order, so shorter prompts usually work. Being explicit costs one sentence and removes the guesswork. Here is what the tool calls look like:
list_messages { "address": "signup-bot@agent.restapi.email", "limit": 1 }
-> { "address": "signup-bot@agent.restapi.email",
"messages": [ { "id": "msg_prev", "subject": "Welcome", ... } ],
"has_more": true }
(Claude fills in and submits the form)
get_verification_code { "address": "signup-bot@agent.restapi.email",
"since": "msg_prev",
"from_contains": "example.com" }
-> { "code": "482913",
"link": "https://example.com/verify?token=...",
"message_id": "...", "subject": "Your code is 482913",
"from": "noreply@example.com", "received_at": "...",
"codes": ["482913"], "links": ["https://example.com/verify?token=..."] }
# Nothing yet after 25 seconds:
-> { "timed_out": true, "address": "signup-bot@agent.restapi.email" }
# Call get_verification_code again with the same since.get_verification_code waits up to 25 seconds per call and only matches messages that contain a detectable code or link. since takes a message id (preferred) or an ISO timestamp and excludes everything up to it. from_contains and subject_contains narrow the match when several services mail the same inbox.
Prompts that work well
- “Create a test account on our staging site with signup-bot@agent.restapi.email and confirm it.”
- “I just requested a password reset for signup-bot@agent.restapi.email. Wait for the reset link and give it to me.”
- “Check signup-bot@agent.restapi.email for the newest email from github.com and summarise it.”
3. Claude Desktop and Cursor
Cursor reads remote servers with headers from ~/.cursor/mcp.json or a project’s .cursor/mcp.json:
{
"mcpServers": {
"restapi-email": {
"url": "https://api.restapi.email/mcp",
"headers": { "X-API-Key": "sk_live_..." }
}
}
}Claude Desktop’s custom connectors sign in with OAuth and cannot send an API key header, and this server does not offer OAuth, so the key is passed through the open-source mcp-remote bridge. Add this to claude_desktop_config.json (Settings, Developer, Edit Config) and restart the app:
{
"mcpServers": {
"restapi-email": {
"command": "npx",
"args": [
"-y", "mcp-remote", "https://api.restapi.email/mcp",
"--header", "X-API-Key:${RESTAPI_EMAIL_KEY}"
],
"env": { "RESTAPI_EMAIL_KEY": "sk_live_..." }
}
}
}Every client, and the generic mcpServers block, is on the MCP setup page.
4. Security notes
Scope the key to one inbox
The MCP server reads exactly the inboxes its key can read. An account-wide key lets Claude list and read every inbox you own; a key limited to signup-bot@agent.restapi.email cannot see anything else, whatever the prompt says. Use one inbox per purpose (staging sign-ups, password resets for a test user) and one key each, so revoking a key ends exactly one integration.
Treat email as untrusted input
Anyone can send mail to the address. An email body can contain text written to steer an agent (“ignore your instructions and…”). get_verification_code returns only the code, link, subject and sender, which keeps most of a message out of the model’s context; wait_for_message and get_message return the text. Prefer the first for verification flows, and keep Claude Code’s permission prompts on for actions that matter.
Allow the read-only tools, prompt for the rest
Claude Code names MCP tools mcp__<server>__<tool>. Allow the three read tools in .claude/settings.json and delete_message, which removes a message permanently, still asks first:
{
"permissions": {
"allow": [
"mcp__restapi-email__list_inboxes",
"mcp__restapi-email__list_messages",
"mcp__restapi-email__get_verification_code"
]
}
}Keep keys out of history
Do not paste a key into the chat or commit it. If one leaks, revoke it in the dashboard; it is useless after that.
Troubleshooting
timed_out: true: nothing matched within 25 seconds. Call again with the samesince; mail that arrived in between is not lost.scan_limit_reached: a lot of mail arrived aftersince. Addfrom_containsorsubject_contains, or pass a newersince.- “This API key cannot read the inbox”: the address is not one the key covers. Call
list_inboxes. - Code is
nullbut a link is present: the site sent a magic link. Open the link instead. - Rate limits: about 120 requests a minute per key, and up to 30 long waits a minute. Each tool call is one request.
Prefer plain HTTP for scripts? The same flow over REST is in the agent sign-up guide and the long-poll docs.
Questions
Does Claude Code need a plugin or a local server to read email?
No. RESTAPI.email runs a remote MCP server at https://api.restapi.email/mcp over Streamable HTTP. One claude mcp add command with your API key in an X-API-Key header is the whole setup; nothing runs on your machine.
Why did Claude get an old verification code?
The wait was started without since, so a message already in the inbox matched. Ask Claude to call list_messages with limit 1 before it submits the form and to pass that message id as since to get_verification_code.
What happens if the email takes longer than 25 seconds?
get_verification_code returns timed_out after at most 25 seconds. Calling it again with the same since keeps waiting without missing anything that arrived in between.
Can I connect Claude Desktop without the mcp-remote bridge?
Not today. Claude Desktop custom connectors sign in with OAuth and cannot send an API key header, and the server does not offer OAuth, so the key is passed through the open-source mcp-remote bridge in claude_desktop_config.json.
Ready? Create an account, make an inbox and a scoped key, and run the command above.