Logo von mail-mcp

mail-mcp

Community
kacperkwapisz

MCP server bridging IMAP/SMTP email accounts to Poke — search, read, send, and watch emails via AI agents

Herausgeberkacperkwapisz
Repositorymail-mcp
SpracheGo
Forks
4
Sterne
13
Verfügbare Tools
0
Transporttypstdio, streamable-http
Kategorien
LizenzMIT
Links
  • Tools mit KI-Workflows verbinden

    mail-mcp stellt MCP-Funktionen bereit, die kompatible KI-Clients und Agenten nutzen können.

  • Verfügbare Tools: 0

    Unten finden Sie die aufrufbaren Aktionen. Namen und Beschreibungen werden angezeigt, sofern der Server sie bereitstellt.

  • Konfiguration zum Kopieren

    Nutzen Sie die Installationsbeispiele, um diesen Server in Ihrem bevorzugten MCP-Client zu konfigurieren.

  • Open-Source-Kennzahlen

    Kennzahlen des verlinkten Repositorys: Sterne (13) und Forks (4).

mail-mcp

An MCP server that gives AI agents controlled access to IMAP and SMTP mailboxes — read, search, organize, and send — without ever handing them your credentials.

Written in Go. Single static binary, no runtime dependencies, ~20 MB resident.

Why credentials stay server-side

The agent never sees a hostname, username, or password. Tools take an opaque account_id; the server resolves it against a local config file and makes the connection itself. Run it remotely and the model has no way to reconstruct how to reach your mailbox, even if it wanted to.

The same idea extends to message handles. A message_id is an opaque token encoding the account, folder, UIDVALIDITY, and UID together — so an agent cannot pair a handle from one mailbox with a different account, and a folder that gets renumbered produces a clear "this handle is stale" error instead of quietly acting on the wrong message.

Install

Docker

bash
docker run -d --name mail-mcp \
  -p 3000:3000 \
  -v "$PWD/config.yml:/config.yml:ro" \
  -e MCP_API_KEY="$(openssl rand -hex 32)" \
  ghcr.io/kacperkwapisz/mail-mcp:latest

From source

bash
git clone https://github.com/kacperkwapisz/mail-mcp.git
cd mail-mcp
make build          # → bin/mail-mcp

Binaries

Download for your platform from Releases.

Setup

1. Write the config.

bash
cp config.example.yml config.yml
yaml
allow_send: false # opt in per account below
allow_delete: false

accounts:
  - id: icloud
    imap:
      host: imap.mail.me.com
      username: you@icloud.com
      password: xxxx-xxxx-xxxx-xxxx # app-specific password
    smtp:
      host: smtp.mail.me.com
      username: you@icloud.com
      password: xxxx-xxxx-xxxx-xxxx
    from_address: you@yourdomain.com
    from_name: Your Name
    allow_send: true

Most providers need an app-specific password rather than your account password — iCloud, Gmail, Fastmail, and Zoho all work this way.

SMTP inherits the IMAP host and credentials when omitted, and connection security is inferred from the port (993 → TLS, 143 → STARTTLS, 465 → TLS, 587 → STARTTLS) unless you set security explicitly.

2. Generate a token and run.

bash
export MCP_API_KEY=$(openssl rand -hex 32)
./bin/mail-mcp --config config.yml

The HTTP transport refuses to start without MCP_API_KEY. There is no unauthenticated mode — this process can read and send your mail.

3. Verify.

bash
npx @modelcontextprotocol/inspector

Connect to http://localhost:3000/mcp over Streamable HTTP with an Authorization: Bearer <MCP_API_KEY> header, then call verify_account to confirm both IMAP and SMTP authenticate.

Local use

For a client on the same machine, stdio skips the network entirely and needs no token:

jsonc
{
  "mcpServers": {
    "mail": {
      "command": "/usr/local/bin/mail-mcp",
      "args": ["--config", "/etc/mail-mcp/config.yml", "--transport", "stdio"]
    }
  }
}

Tools

Discovery

ToolPurpose
list_accountsEvery configured mailbox and what it's allowed to do. No network.
verify_accountLive IMAP + SMTP connectivity and auth check.
get_server_infoVersion and the operational limits governing the other tools.

Reading

ToolPurpose
search_emailsSearch by sender, recipient, subject, body, date, or flags. Paginated.
read_emailOne message: headers, body, attachment metadata. HTML opt-in.
get_attachmentWrite one attachment to disk. Returns file_path and, on HTTP, a 15-minute download_url.

Sending

ToolPurpose
send_emailNew message, with attachments and full threading control.
reply_emailReply with derived subject, recipients, and threading headers.
forward_emailForward, carrying attachments and quoting the original.
create_draftSave to Drafts without sending. Works even when sending is off.

Organizing

ToolPurpose
archive_emailMove to the account's Archive folder.
move_emailMove to any folder.
mark_emailread / unread / flagged / unflagged / answered / unanswered.
delete_emailMove to Trash. Gated, and requires confirm: true.
list_foldersFolders with their normalized roles.
create_folder · rename_folder · delete_folderFolder management.

Design decisions

Attachment bytes never enter the response. read_email returns attachment metadata with a part_id; get_attachment writes the file to disk and returns file_path (on the server) plus, when public_url is set, a 15-minute signed download_url. A remote agent curls that URL onto its own machine. A 7 MB PDF base64-encoded into a tool result would blow the context window without accomplishing anything.

Bodies are truncated and HTML is opt-in. Message HTML is attacker-controlled and enormous. It is sanitized through bluemonday before it is ever returned, and omitted entirely unless include_html is set. Messages with no plain-text part get one derived from the HTML, with paragraph breaks preserved.

One pooled IMAP connection per account. A TLS handshake plus LOGIN on every tool call is the single biggest source of latency in servers of this kind. Connections are kept authenticated, health-checked with NOOP after idling, and reconnected transparently. Operations on one account are serialized, since IMAP's selected-mailbox state makes ordering matter; different accounts run concurrently.

Every network operation is bounded. Separate timeouts for IMAP connect, IMAP command, SMTP connect, and SMTP send — the last one generous, because DATA transmission for a large attachment on a slow uplink legitimately takes minutes. A command that exceeds its budget closes the socket, which is the only thing that reliably unblocks a stuck IMAP read.

Sent copies are the exact bytes that were delivered. Rather than rebuilding an approximation for the Sent folder, the serialized message is captured before transmission and APPENDed verbatim. Whether to append at all is provider-aware: Gmail and Zoho file their own copy on submission, so a second one is redundant or a visible duplicate; iCloud, Office 365, and generic relays file nothing, so skipping it loses the copy.

Send validation happens before a socket opens. Recipients, subject length, header injection via embedded newlines, and body presence are all checked locally. A malformed call fails instantly with a specific message instead of after a TLS handshake.

Tool-call syntax in a body is rejected outright. LLMs periodically concatenate body_text and body_html into one argument and leak the separator markup into the recipient's inbox. Prompt instructions do not reliably prevent this, so the server refuses any send whose fields contain </body_text>, <parameter name="body_html">, and similar markers. Legitimate technical content that merely mentions <parameter> still passes.

Folder roles come from the server, not a name list. SPECIAL-USE attributes are used where available, with a localized name table as fallback — so a Polish "Wysłane" or a Gmail "[Gmail]/Sent Mail" is recognized as Sent rather than triggering the creation of a duplicate folder.

Destructive operations are gated twice. allow_delete is false by default, and even when enabled delete_email requires confirm: true per call and moves to Trash rather than expunging. delete_folder additionally refuses INBOX and any special-use folder.

Configuration reference

Environment

VariableDefaultPurpose
MCP_API_KEY—Bearer token. Required for HTTP; unused for stdio.
CONFIG_PATHconfig.ymlPath to the YAML config.
TRANSPORThttphttp or stdio.
PORT / ADDR3000Listen port or full address.
LOG_LEVELinfodebug, info, warn, error.
TRUST_PROXYfalseTrust X-Forwarded-For for rate limiting.
RATE_LIMIT_GET_RPM60Per-client GET budget per minute.
RATE_LIMIT_POST_RPM240Per-client POST budget per minute.

Flags mirror these: --config, --transport, --addr, --log-level, --trust-proxy, --version.

Config file

See config.example.yml for the annotated version.

KeyDefaultPurpose
allow_sendfalseGlobal send gate.
allow_deletefalseGlobal delete gate.
limits.max_body_chars50000Per-part body truncation.
limits.max_search_results100Largest search page.
limits.max_attachment_bytes26214400Attachment size ceiling.
limits.attachment_dirsystem tempWhere get_attachment writes.
public_urlemptyOrigin used to mint download_url. Empty disables it.
timeouts.*see exampleimap_connect, imap_command, smtp_connect, smtp_send.
accounts[].allow_sendinherits globalPer-account send gate.
accounts[].allow_deleteinherits globalPer-account delete gate.
accounts[].save_sentprovider-awareForce the Sent-folder copy on or off.

Configs written for poke-mail v1 still load: the flat imap_host / smtp_username style keys are folded into the nested form automatically.

Security

  • Authentication is mandatory on HTTP. No token, no start.
  • Credentials never leave the server. Tools receive ids, not connection details.
  • Everything outside /mcp returns an empty 404, revealing nothing to scanners.
  • TLS is mandatory for STARTTLS accounts. No opportunistic fallback to plaintext, which would send your password in the clear.
  • Rate limited per client, with separate GET and POST budgets so polling cannot starve real work. X-Forwarded-For is ignored unless you declare a trusted proxy, since otherwise any caller could spoof it.
  • Attachment filenames are sanitized before touching the filesystem — path separators, traversal segments, and control characters are stripped.
  • HTML is sanitized with bluemonday before it is returned.
  • DNS rebinding protection is on by default via the MCP SDK.

Put it behind TLS in any real deployment — a reverse proxy or a tunnel. The bearer token is the only thing standing between the internet and your mail.

Development

bash
make check    # fmt + vet + test
make test
make race
make cover
make build
make docker

License

MIT — see LICENSE.

Installation

TypingMind
{
  "mcpServers": {
    "kacperkwapisz-mail-mcp": {
      "command": "./bin/mail-mcp",
      "args": [
        "--config",
        "path/to/your/config.yml",
        "--transport",
        "stdio"
      ]
    }
  }
}

mail-mcp MCP mit mehreren KI-Modellen nutzen

TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. Sobald mail-mcp verbunden ist, können Sie die Integration mit verschiedenen KI-Modellen in TypingMind verwenden, statt sie für jedes Modell separat einzurichten. Sie können MCP lokal auf Ihrem Gerät ausführen oder über eine URL eine Verbindung zu einem Remote-MCP-Server herstellen.

Option 1: Lokalen Konnektor verwenden

Nutzen Sie diese Option, wenn der MCP-Server Zugriff auf lokale Dateien, Apps oder private Ressourcen auf Ihrem Computer benötigt.

1

MCP-Einstellungen öffnen

Gehen Sie in TypingMind zu „Einstellungen“, „Erweiterte Einstellungen“ und dann „Model Context Protocol“ und wählen Sie „Konnektor einrichten“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Klicken Sie auf das Symbol „Einstellungen“.
  3. Gehen Sie zu „Erweiterte Einstellungen“.
  4. Öffnen Sie den Abschnitt „Model Context Protocol“.
  5. Klicken Sie auf „Konnektor einrichten“ und wählen Sie „Dieses Gerät“.
Einrichtungsbildschirm des TypingMind-MCP-Konnektors mit ausgewählter Option „Dieses Gerät“
2

Konnektor-Befehl ausführen

Wählen Sie „Dieses Gerät“, kopieren Sie den Befehl aus TypingMind und führen Sie ihn im Terminal aus. Lassen Sie den Prozess laufen, solange Sie MCP verwenden.

  1. Kopieren Sie den in TypingMind angezeigten Einrichtungsbefehl.
  2. Öffnen Sie „Terminal“ (macOS) bzw. „Windows Terminal“ (Windows).
  3. Fügen Sie den Befehl ein und führen Sie ihn aus.
  4. Bestätigen Sie die Paketinstallation, wenn Sie im Terminal zum Fortfahren aufgefordert werden.
  5. Lassen Sie das Terminalfenster geöffnet und den Prozess darin laufen, solange Sie MCP-Tools verwenden.
3

mail-mcp als Server hinzufügen

Wenn der Konnektorstatus „Bereit“ anzeigt, klicken Sie auf „Server bearbeiten“ und fügen Sie die MCP-Server-Konfiguration ein.

  1. Warten Sie, bis der Konnektorstatus „Bereit“ anzeigt.
  2. Klicken Sie auf „Server bearbeiten“.
  3. Fügen Sie die MCP-Server-Konfiguration für mail-mcp ein.
  4. Speichern Sie die Serverliste.
  5. Aktualisieren Sie die Ansicht, um bei Bedarf zu prüfen, ob der Konnektor weiterhin bereit ist.
MCP-Einstellungen in TypingMind mit aktivem Server und der Schaltfläche „Server bearbeiten“
{
  "mcpServers": {
    "kacperkwapisz-mail-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Verbindung modellübergreifend nutzen

Speichern Sie die Serverliste, öffnen Sie „Plugins“ und aktivieren Sie die MCP-Tools von mail-mcp. Wählen Sie dann ein beliebiges unterstütztes KI-Modell in TypingMind und verwenden Sie die Tools im Chat oder weisen Sie sie einem KI-Agenten zu.

  1. Öffnen Sie die Seite „Plugins“ in TypingMind.
  2. Aktivieren Sie die MCP-Tools von mail-mcp.
  3. Starten Sie einen Chat und wählen Sie das KI-Modell, das Sie verwenden möchten.
  4. Nutzen Sie die MCP-Tools im Chat oder weisen Sie sie einem KI-Agenten zu.
  5. Wechseln Sie bei Bedarf zu einem anderen KI-Modell, ohne die MCP-Verbindung erneut herzustellen.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit mail-mcp bei dieser Aufgabe helfen?
mail-mcp
Gerne. Ich habe es gelesen.
Das habe ich mit mail-mcp gefunden.

Option 2: Eine MCP-Server-URL hinzufügen

Nutzen Sie diese Option, wenn mail-mcp bereits auf einem Remote-Server gehostet wird oder Ihr Team einen gemeinsamen Konnektor für mehrere Benutzer verwenden möchte.

1

MCP-Konnektoren öffnen

Gehen Sie in TypingMind zu „Plugins“, öffnen Sie „MCP-Konnektoren“ und wählen Sie dann „URL hinzufügen“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Gehen Sie zu „Plugins“.
  3. Öffnen Sie „MCP-Konnektoren“.
  4. Klicken Sie auf „URL hinzufügen“.
TypingMind-Formular zum Hinzufügen einer benutzerdefinierten MCP-Server-URL
2

Server-URL einfügen

Geben Sie die MCP-Server-URL des Anbieters in das Feld „Server-URL“ ein. Fügen Sie einen Verbindungsnamen, eine Beschreibung, ein Symbol, benutzerdefinierte HTTP-Header oder OAuth-Client-Einstellungen hinzu, falls der Server diese erfordert.

  1. Fügen Sie die MCP-Server-URL des Anbieters in das Feld „Server-URL“ ein.
  2. Geben Sie einen Verbindungsnamen für mail-mcp ein.
  3. Fügen Sie bei Bedarf eine Beschreibung und ein Symbol hinzu, um die Verbindung leichter zu erkennen.
  4. Fügen Sie benutzerdefinierte HTTP-Header oder OAuth-Client-Daten hinzu, falls der Server eine Authentifizierung erfordert.
3

Verbindung erstellen

Klicken Sie auf „Verbindung erstellen“, kehren Sie dann zur Plugin-Liste zurück und prüfen Sie, ob die neue MCP-Verbindung aktiv ist.

  1. Klicken Sie auf „Verbindung erstellen“.
  2. Kehren Sie zur Liste der MCP-Konnektoren zurück.
  3. Prüfen Sie, ob die Verbindung zu mail-mcp als aktiv angezeigt wird.
  4. Aktualisieren Sie die Plugin-Liste, falls die Verbindung nicht sofort angezeigt wird.
4

Modelle ohne erneuten Verbindungsaufbau wechseln

Starten Sie einen Chat mit Ihrem bevorzugten Modell, aktivieren Sie unter „Plugins“ die Tools von mail-mcp und wechseln Sie bei Bedarf zu einem anderen Modell. Die MCP-Verbindung bleibt im TypingMind-Arbeitsbereich verfügbar.

  1. Starten Sie einen neuen Chat in TypingMind.
  2. Wählen Sie das KI-Modell, das Sie verwenden möchten.
  3. Aktivieren Sie die Tools von mail-mcp unter „Plugins“.
  4. Bitten Sie das Modell, das Tool bei Bedarf zu verwenden.
  5. Wechseln Sie zu einem anderen KI-Modell und verwenden Sie dieselbe MCP-Verbindung weiter.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit mail-mcp bei dieser Aufgabe helfen?
mail-mcp
Gerne. Ich habe es gelesen.
Das habe ich mit mail-mcp gefunden.

Häufig gestellte Fragen

Wofür wird der MCP-Server mail-mcp verwendet?

mail-mcp ist ein MCP-Server, über den kompatible KI-Clients auf externe Tools und Kontext zugreifen können. In TypingMind können Sie diesen MCP-Server einmal hinzufügen und seine Tools in Ihrem KI-Arbeitsbereich verfügbar machen.

Kann ich den MCP-Server mail-mcp mit mehreren KI-Modellen in TypingMind verwenden?

Ja. TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. So können Sie mail-mcp mit verschiedenen KI-Modellen wie Claude, ChatGPT, Gemini oder anderen in TypingMind konfigurierten Modellen verwenden, ohne den MCP-Server für jedes Modell separat einzurichten.

Warum den MCP-Server mail-mcp mit TypingMind nutzen?

TypingMind ist eine der besten Oberflächen für LLM-Chats, da es mehrere KI-Modelle, Prompts, Plugins, KI-Agenten, API-Schlüssel und MCP-Tools in einem Arbeitsbereich vereint. Sobald mail-mcp verbunden ist, können Sie die zugehörigen MCP-Tools mit Ihren bevorzugten Modellen nutzen und Ihre Chat-Abläufe in TypingMind übersichtlich organisieren.

Wie verbinde ich den MCP-Server mail-mcp mit TypingMind?

Sie können mail-mcp in TypingMind über den lokalen MCP-Konnektor oder durch Hinzufügen der URL eines entfernten MCP-Servers verbinden. Verwenden Sie den lokalen Konnektor, wenn der Server auf Dateien, Apps oder private Ressourcen auf Ihrem Gerät zugreifen muss. Nutzen Sie eine Server-URL, wenn der MCP-Server extern gehostet wird.

Welche Tools stellt der MCP-Server mail-mcp in TypingMind bereit?

mail-mcp stellt MCP-Funktionen bereit, die Sie auf der Plugins-Seite in TypingMind aktivieren und im Chat verwenden oder KI-Agenten zuweisen können.

Muss ich meine API-Schlüssel mit TypingMind teilen, um den MCP-Server mail-mcp zu verwenden?

Nein. TypingMind arbeitet vorrangig lokal. Sie wählen Ihre Modellanbieter selbst und behalten die Kontrolle über Ihre API-Schlüssel, Prompts und MCP-Konfiguration. Falls mail-mcp eine Authentifizierung erfordert, fügen Sie beim Erstellen der Verbindung die erforderlichen Header, OAuth-Einstellungen oder die lokale Konfiguration für diesen MCP-Server hinzu.

Ähnliche MCP-Server

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇