Logo: mail-mcp

mail-mcp

Communautéit
kacperkwapisz

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

Editeurkacperkwapisz
Repositorymail-mcp
SproochGo
Forks
4
Stären
13
Disponibel Tools
0
Transporttypstdio, streamable-http
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    mail-mcp bitt MCP-Funktiounen un, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • Disponibel Tools: 0

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an deem MCP-Client ze konfiguréieren, deen Dir am léifste benotzt.

  • Interessi vun der Communautéit um Open-Source-Projet

    Zuele vum verlinkte Repository – Stären: 13, 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.

Installatioun

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

mail-mcp MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal mail-mcp verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dir kënnt MCP lokal op Ärem Apparat ausféieren oder Iech iwwer d'URL mat engem externen MCP-Server verbannen.

Optioun 1: De lokale Connector benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector: D'Optioun „Dësen Apparat“ ass ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Setzt de kopéierte Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

mail-mcp als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a setzt d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Setzt d'MCP-Serverkonfiguratioun fir mail-mcp an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert d'Säit, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "kacperkwapisz-mail-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vun der Integratioun mail-mcp. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vun der Integratioun mail-mcp.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat mail-mcp bei dëser Aufgab hëllefen?
mail-mcp
Jo. Ech hunn et gelies.
Dat hunn ech mat mail-mcp fonnt.

Optioun 2: Eng MCP-Server-URL derbäisetzen

Benotzt dës Optioun, wann mail-mcp schonn op engem externe Server gehost gëtt oder Är Ekipp ee gemeinsame Connector wëllt, op dee méi Benotzer kënne zougräifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbäisetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbäisetzen“.
TypingMind-Formulaire, fir eng benotzerdefinéiert MCP-Server-URL derbäizesetzen
2

Déi kopéiert Server-URL asetzen

Gitt d'MCP-Server-URL vum Ubidder am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinéiert HTTP-Headeren oder OAuth-Clientastellungen derbäi, wann de Server se erfuerdert.

  1. Setzt d'MCP-Server-URL vum Ubidder an d'Feld „Server-URL“ an.
  2. Gitt en Numm fir d'Verbindung mat mail-mcp an.
  3. Wann Dir d'Verbindung méi einfach erëmerkenne wëllt, setzt eng Beschreiwung an e Symbol derbäi.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbäi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zeréck op d'Plugin-Lëscht a kontrolléiert, ob déi nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat mail-mcp als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen, ouni MCP nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivéiert d'Tools vun der Integratioun mail-mcp ënner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-Aarbechtsberäich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. Aktivéiert d'Tools vun der Integratioun mail-mcp ënner „Plugins“.
  4. Biet de Modell, d'Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat mail-mcp bei dëser Aufgab hëllefen?
mail-mcp
Jo. Ech hunn et gelies.
Dat hunn ech mat mail-mcp fonnt.

Heefeg gestallte Froen

Fir wat gëtt den MCP-Server mail-mcp benotzt?

mail-mcp ass en MCP-Server, deen et kompatibele KI-Clienten erlaabt, op extern Tools a Kontextinformatioune zouzegräifen. An TypingMind kënnt Dir dësen MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech mail-mcp MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir mail-mcp mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni den MCP-Server fir all Modell separat anzeriichten.

Firwat mail-mcp MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann mail-mcp verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Ären Aarbechtsoflaf beim Chatten an TypingMind organiséieren.

Wéi verbannen ech mail-mcp MCP mat TypingMind?

Dir kënnt mail-mcp iwwer de lokale MCP-Connector oder iwwer d'URL vun engem Remote-MCP-Server mat TypingMind verbannen. Benotzt de lokale Connector, wann de Server Zougrëff op Fichieren, Apps oder privat Ressourcen op Ärem Apparat brauch, an eng Server-URL, wann den MCP-Server op Distanz gehost gëtt.

Wéi eng Tools stellt mail-mcp MCP an TypingMind zur Verfügung?

mail-mcp stellt MCP-Funktioune zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agente zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir mail-mcp MCP ze benotzen?

Nee. TypingMind ass nom Local-first-Prinzip opgebaut a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann mail-mcp eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir deen MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇