Email for AI coding agents with MCP
An AI coding agent that tests a sign-up flow gets stuck at the verification email. This guide connects the agent to a remote MCP server that creates a fresh address, waits for the message and hands back the one-time code and link. You need an API key, one configuration file and a prompt.
How it works
The MCP endpoint is https://assertinbox.com/mcp (streamable HTTP, JSON-RPC). It authenticates with the same bearer key as the REST API and offers three tools:
create_addressreturns an address such ask3x9a1bz.agent-1@assertinbox.com.wait_for_emailwaits up to 25 seconds for a message to a tag and returns it withotp,magic_linkandlinks. On timeout it returns an error result, and the agent should call it again.list_messageslists up to 50 recent messages.
Get a key
Get one in a click at /start. An agent can create its own key, or you can. The key is shown once and has no email or card attached.
curl -s -X POST https://assertinbox.com/v1/keys
Store the api_key in an environment variable named ASSERTINBOX_KEY. If this returns 403 signups_closed, the beta is not open for new keys. Use inboxes only for services you own or control; see the terms.
Client configuration
Configuration formats change between client versions, so check your client's documentation if a snippet is rejected. These use the remote-server syntax of each client at the time of writing.
Claude Code
Save as .mcp.json in your project, or run claude mcp add --transport http assertinbox https://assertinbox.com/mcp --header "Authorization: Bearer $ASSERTINBOX_KEY".
{
"mcpServers": {
"assertinbox": {
"type": "http",
"url": "https://assertinbox.com/mcp",
"headers": { "Authorization": "Bearer ${ASSERTINBOX_KEY}" }
}
}
}
Cursor
Save as .cursor/mcp.json.
{
"mcpServers": {
"assertinbox": {
"url": "https://assertinbox.com/mcp",
"headers": { "Authorization": "Bearer ${env:ASSERTINBOX_KEY}" }
}
}
}
VS Code
Save as .vscode/mcp.json. VS Code asks for the key once and keeps it out of the file.
{
"servers": {
"assertinbox": {
"type": "http",
"url": "https://assertinbox.com/mcp",
"headers": { "Authorization": "Bearer ${input:assertinbox-key}" }
}
},
"inputs": [
{ "type": "promptString", "id": "assertinbox-key", "description": "AssertInbox API key", "password": true }
]
}
Check the connection by hand
Before blaming the client, call the server directly. This lists the tools:
curl -s https://assertinbox.com/mcp \
-H "Authorization: Bearer $ASSERTINBOX_KEY" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
An example task prompt
Tell the agent exactly which tools to use and what counts as done. For example:
Test the sign-up flow of the app running at http://localhost:3000.
1. Call create_address to get a fresh email address.
2. Submit the sign-up form with that address.
3. Call wait_for_email with the same tag. If it times out, call it once more.
4. Enter the otp from the result, or open magic_link if there is no code.
5. Report whether the account was verified, with the page text you saw.
Only use this address for the app named above.
What the tools return
Every tool result is a single text block that contains JSON. For wait_for_email that JSON has the message id, tag, from, subject, text, html, otp, magic_link and links. The otp is a string of 4 to 8 digits or an upper-case code that mixes letters and digits, and it is null when the extractor finds no labelled code. The magic_link is the first link that looks like a verification, login or reset link, and it is null otherwise. When both are empty, the agent can still read text and links and decide for itself.
Keep the agent on safe ground
Write into the prompt which service the address may be used for. The terms allow inboxes only for services you own or control, so an agent should never sign up for third-party sites with them. Give each task its own tag, so a retry cannot pick up an email from an earlier attempt, and tell the agent to stop and report after two timeouts instead of looping. Keep the key in an environment variable or a secret store, and never paste it into the prompt or into a file that is committed.
Troubleshooting
- The tools do not appear. The client could not authenticate. A 401 means the key is missing or wrong in the client's environment; a 403
key_disabledmeans the key was switched off. - wait_for_email keeps timing out. The app did not send the mail to the address that was created. Ask the agent to print the address it submitted and check it character by character, including the namespace.
- The agent re-reads an old email. Use a new tag per attempt, or pass
since. - Limits. MCP calls count toward the same 2,000 requests per key per UTC day as the REST API. A 429 includes
Retry-After.
Limits and client files
An agent that works through MCP shares the key's daily allowance with any tests that use the same key; the numbers and the error codes are on the limits page. If the agent writes test code rather than calling tools itself, point it at the client files, which are single files with no dependencies, and at /start for a key.
Related guides: Playwright, Cypress, pytest.