Home / Blog / How to connect an AI agent to email using MCP
MCP guideMCP (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.
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.
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
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_..." }
}
}
}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_domain → create_mailbox → send_email. A coding agent finishes real email setup inside one session.list_messages (threaded), get_thread, get_message, send_email - a full read-reason-reply loop.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.add_forward), signatures (set_identity), vacation replies, usage checks (get_usage) - all tools, no dashboard needed.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.
get_message is attacker-controlled content - agents should work from the text body, and anything rendering HTML must sanitize it.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.
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.
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.