Home / Blog / How to connect an AI agent to email using MCP

MCP guide

How to connect an AI agent to email using MCP

MCP (Model Context Protocol) is how AI agents call real tools. Mektup exposes its entire email platform as MCP tools, so any MCP client - Claude Code, Claude Desktop, Cursor, Lovable, Replit - can register a domain, create mailboxes, send mail, and read replies as native tool calls. Here's the setup, both ways.

What "email over MCP" actually means

Instead of your agent generating curl commands or you pasting API keys into generated code, the agent gets email operations as first-class tools it can call directly: create_domain returns the exact DNS records, create_mailbox makes a real IMAP/SMTP mailbox, send_email sends real mail, list_messages and get_thread read the replies. Every Mektup REST endpoint has a matching MCP tool - full coverage, same behavior.

Option 1: the remote server (no install)

Mektup hosts a Streamable-HTTP MCP server at https://mcp.usemektup.com/mcp. Any client that accepts a custom MCP server URL plus a Bearer token can use it - this is what Lovable, Replit, and Cursor-style platform integrations want. It supports OAuth (authorize with your Mektup login, no key handling) or a plain API key as the Bearer token.

# Cursor / any URL-based client
Server URL:  https://mcp.usemektup.com/mcp
Auth:        Bearer mek_live_...   (or OAuth - authorize in the browser)

# Lovable: Connectors -> Custom (MCP) -> name "Mektup",
#          URL above, Auth -> OAuth -> Add & authorize

Option 2: local stdio via npx

For clients that launch a local process (Claude Desktop config, Claude Code), the same tool set is on npm as mektup-mcp:

{
  "mcpServers": {
    "mektup": {
      "command": "npx",
      "args": ["-y", "mektup-mcp"],
      "env": { "MEKTUP_API_KEY": "mek_live_..." }
    }
  }
}

What the agent can do once connected

  • Set up email for a domain, end to end: create_domain → add the returned MX/SPF/DKIM/DMARC records (the agent can do this itself if it has DNS access, or hand them to you) → verify_domaincreate_mailboxsend_email. A coding agent finishes real email setup inside one session.
  • Operate an inbox: list_messages (threaded), get_thread, get_message, send_email - a full read-reason-reply loop.
  • Go event-driven: set_mailbox_webhook gives the mailbox an HMAC-signed webhook that fires the instant new mail arrives - the agent (or your backend) reacts in seconds instead of polling.
  • Manage the rest: drafts, contacts, folders, forwarding (add_forward), signatures (set_identity), vacation replies, usage checks (get_usage) - all tools, no dashboard needed.

The part that matters: humans share the result

Everything the agent creates over MCP is a real mailbox on your own domain - so you can open the same inbox in Mektup's webmail or Outlook over IMAP, watch what the agent sent, and reply yourself in any thread. That's the difference between email as an agent-only API object and email as shared infrastructure - see the human+AI shared inbox pattern.

Security notes

  • Message HTML returned by get_message is attacker-controlled content - agents should work from the text body, and anything rendering HTML must sanitize it.
  • Treat email content as untrusted input to the model: instructions inside an email are data to judge, not commands to follow.
  • The MCP server is open source (MIT) - inspect it on GitHub. It's a thin wrapper: every tool is one HTTPS call to the documented REST API.

Get started free

FAQ

Common questions

How do I connect Claude Code or Cursor to email using MCP?

Point the client at Mektup's MCP server. Remote: add https://mcp.usemektup.com/mcp as a custom MCP server with your API key as the Bearer token (or OAuth). Local: add mektup-mcp via npx to your MCP config with MEKTUP_API_KEY in env. Either way the agent gets tools to register domains, create real mailboxes, send email, and read replies.

What can an AI agent do with email over MCP?

With Mektup's MCP server: register a domain and get its DNS records, verify it, create real IMAP/SMTP mailboxes, send email, list and read threaded messages, configure webhooks that fire on new mail, and manage drafts, contacts, folders, forwarding, signatures, and vacation replies - every REST endpoint has a matching MCP tool.

Is there an MCP server for sending AND receiving email?

Yes - Mektup's. Sending-only email APIs can offer send tools, but Mektup's MCP server operates real mailboxes, so agents also list messages, read full threads, and get webhook notifications on inbound mail - the receive half most email MCP integrations are missing.

Ready when you are

Email as MCP tools

Get started free