MCP Server

The mails0 MCP (Model Context Protocol) server gives AI assistants like Claude Desktop, Cursor, and Windsurf 11 email tools. It can start without credentials and create a safe temporary inbox on its first tool call.

Installation

Run the MCP server directly with npx (no global install needed):

npx mails-agent-mcp

Or install globally:

npm install -g mails-agent-mcp
mails-agent-mcp

Configuration

Claude Desktop

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "mails-agent": {
      "command": "npx",
      "args": ["-y", "mails-agent-mcp@2.2.0"]
    }
  }
}

Config file locations:

Cursor

Add the MCP server in Cursor settings under Features → MCP Servers:

{
  "mcpServers": {
    "mails-agent": {
      "command": "npx",
      "args": ["-y", "mails-agent-mcp@2.2.0"]
    }
  }
}

Windsurf

Add to your Windsurf MCP configuration (~/.windsurf/mcp_config.json):

{
  "mcpServers": {
    "mails-agent": {
      "command": "npx",
      "args": ["-y", "mails-agent-mcp@2.2.0"]
    }
  }
}

Self-hosted API

If you self-host mails0, add the API URL to the environment:

{
  "mcpServers": {
    "mails-agent": {
      "command": "npx",
      "args": ["mails-agent-mcp"],
      "env": {
        "MAILS_WORKER_TOKEN": "your_worker_token",
        "MAILS_MAILBOX": "[email protected]",
        "MAILS_API_URL": "https://your-worker.your-domain.workers.dev"
      }
    }
  }
}

Tools

The MCP server exposes 11 tools. It starts without credentials: call get_inbox, wait_for_code, or any other tool and the server automatically establishes a safe first mailbox.

create_temporary_mailbox

Create or reuse a random 72-hour receive-only mailbox without browser approval. The API key is stored locally with 0600 permissions and is never returned to the model.

send_email

Send an email from your mailbox.

ParameterTypeRequiredDescription
tostring[]YesRecipient email addresses
subjectstringYesEmail subject
bodystringYesPlain text body
htmlstringNo*HTML body
ccstring[]NoCC recipients
bccstring[]NoBCC recipients
in_reply_tostringNoMessage ID for threading

get_inbox

List recent emails.

ParameterTypeRequiredDescription
limitnumberNoMax results (default 20)
offsetnumberNoPagination offset

search_inbox

Semantic search across emails.

ParameterTypeRequiredDescription
querystringYesNatural language search query
limitnumberNoMax results (default 10)

get_email

Get a single email by ID.

ParameterTypeRequiredDescription
idstringYesEmail message ID

delete_email

Delete a single email.

ParameterTypeRequiredDescription
idstringYesEmail message ID

get_attachment

Download an attachment by its ID.

ParameterTypeRequiredDescription
idstringYesAttachment ID

wait_for_code

Wait for a verification code to arrive. Polls the inbox until a code is extracted or the timeout is reached.

ParameterTypeRequiredDescription
timeoutnumberNoMax seconds to wait (default 60)
sincestringNoOnly return codes after this ISO timestamp

get_threads

List email threads.

ParameterTypeRequiredDescription
limitnumberNoMax results (default 20)
offsetnumberNoPagination offset

get_thread

Get all messages in a thread.

ParameterTypeRequiredDescription
idstringYesThread ID

extract_data

Extract structured data from an email using AI.

ParameterTypeRequiredDescription
email_idstringYesEmail message ID
typestringYesExtraction type: order, shipping, calendar, receipt, or code

Usage Examples

Once configured, you can ask your AI assistant to perform email tasks in natural language:

How It Works

The MCP server runs as a local process and communicates with the AI client via the Model Context Protocol (stdio transport). It translates tool calls from the AI into mails0 API requests.

AI Assistant  --MCP-->  mails-agent-mcp  --HTTP-->  mails-agent API
   (Claude)            (local process)            (Cloudflare Worker)

Mailbox data lives in the mails0 API. Local credentials are stored in ~/.mails/config.json; environment variables can override MAILS_API_URL, MAILS_API_KEY, MAILS_MAILBOX, and MAILS_WORKER_TOKEN.

Troubleshooting

Tools not appearing

Authentication errors

Timeout on wait_for_code