Email MCP setup for Cursor, Codex CLI and Gemini CLI
Published · Updated
To add an email MCP server to Cursor, point it at the hosted Mail for Bots URL, https://mailforbots.com/mcp, and send your API key as an Authorization: Bearer header. The same URL and key work in Codex CLI and Gemini CLI; only the config syntax differs per client.
Create a key first in the webmail under Settings, then API keys & MCP. Keys start with bm_; copy yours when you create it. See API keys and scopes if you want a key limited to some inboxes or permissions. You can start free; the Free plan includes 3 inboxes.
How do I set up the Cursor email MCP server?
Add this to ~/.cursor/mcp.json for every project, or to .cursor/mcp.json inside a project folder to scope it to that project:
{
"mcpServers": {
"mailforbots": {
"url": "https://mailforbots.com/mcp",
"headers": { "Authorization": "Bearer bm_YOUR_KEY" }
}
}
}Replace bm_YOUR_KEY with your key. Treat the file like a password: do not commit a project-level mcp.json that contains it.
What should a Cursor rule tell the agent about waiting for mail?
Tell the agent to block on one call instead of polling the inbox. wait_for_message returns as soon as a matching unread inbound message exists, including one that already arrived, and returns null on timeout. A short rule is enough:
When a flow sends email (signup, password reset, verification):
- Create a throwaway inbox with create_inbox and a short ttl_minutes
(minimum 5).
- After triggering the email, call wait_for_message for that inbox
with subject_contains or from_contains and timeout_seconds 60.
- Read the codes and links from the result.
- Do not poll the inbox in a loop. If wait_for_message returns
null, retry once, then report the failure.How do I add it to Codex CLI?
Export the key as an environment variable, then register the server. Codex reads the bearer token from the variable you name, so the key is not written into the Codex config:
export BOTMAIL_KEY=bm_YOUR_KEY
codex mcp add mailforbots --url https://mailforbots.com/mcp \
--bearer-token-env-var BOTMAIL_KEYExport BOTMAIL_KEY in the shell profile you launch Codex from, or the token will be missing next session.
How do I add it to Gemini CLI?
gemini mcp add --scope user --transport http mailforbots https://mailforbots.com/mcp \
--header "Authorization: Bearer bm_YOUR_KEY"--scope user makes the server available everywhere. Leave it out to add Mail for Bots to the current project only.
Which clients are not supported yet?
ChatGPT connectors that only offer OAuth sign-in cannot connect, because Mail for Bots authenticates MCP with API keys and does not support OAuth for MCP yet. Codex CLI, OpenAI's coding agent, works because it accepts a bearer token.
If you need OAuth-based connectors today, MailSlurp documents a hosted MCP with OAuth and agent roles in its public docs, so it may fit better; check their current docs, since this changes. Claude Code is set up in the quickstart.
How do I check that the connection works?
First list the tools in your client's MCP view. Only search_tools, call_tool and report_issue are listed up front; every other tool is found with search_tools and run with call_tool. Then run a real round trip:
- Ask the agent to create an inbox with a short
ttl_minutes(minimum 5). The result includes the new address. - Send a message to that address from any mail account.
- Ask the agent to call
wait_for_messageon the inbox withtimeout_seconds60. It returns the full message, or null on timeout.
The same flow over REST uses POST /api/v1/inboxes to create the inbox (the response has its id and address) and GET /api/v1/inboxes/:inbox/wait, which returns the message or a 408 on timeout. Details are in the REST docs and the MCP tools reference.
Where does each client keep its config?
| Client | Command or file | Where config lives |
|---|---|---|
| Cursor | Edit mcp.json (url + headers) | ~/.cursor/mcp.json, or .cursor/mcp.json per project |
| Codex CLI | codex mcp add mailforbots --url ... --bearer-token-env-var BOTMAIL_KEY | Codex's own config; key read from BOTMAIL_KEY |
| Gemini CLI | gemini mcp add --scope user --transport http ... --header | User-wide with --scope user, else current project |
| OAuth-only ChatGPT connectors | Not supported | Need OAuth sign-in; Mail for Bots uses API keys |
What to read next
- Email MCP server overview for what the server does
- Email for AI agents for use cases
- Best email for AI agents in 2026 for an honest comparison
- Limits and pricing before you scale up
Ready to try it? Start free, create a key, and paste the snippet for your client.
Frequently asked questions
What URL and auth does the Cursor email MCP server use?
Use https://mailforbots.com/mcp as the url in mcp.json and add an Authorization header with the value Bearer followed by your bm_ API key. Put it in ~/.cursor/mcp.json for all projects or .cursor/mcp.json for one project.
Can I use Mail for Bots with ChatGPT connectors?
Only if the client accepts an API key. ChatGPT connectors that only offer OAuth sign-in cannot connect, because Mail for Bots authenticates MCP with API keys. Codex CLI works with a bearer token passed through an environment variable.
How should an agent wait for a verification email?
Create an inbox, trigger the email, then call wait_for_message with a timeout up to 300 seconds. It returns the full message as soon as a matching unread message exists, or null on timeout, so the agent does not need to poll.