Logo di mail-mcp

mail-mcp

Community
kacperkwapisz

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

Pubblicato dakacperkwapisz
Repositorymail-mcp
LinguaGo
Fork
4
Stelle
13
Strumenti disponibili
0
Tipo di trasportostdio, streamable-http
Categorie
LicenzaMIT
Link
  • Collega gli strumenti ai flussi di lavoro IA

    mail-mcp mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • Strumenti disponibili: 0

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni se il server li fornisce.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse della comunità open source

    Stelle: 13; fork: 4 (repository collegato).

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.

Installazione

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

Usa mail-mcp MCP con più modelli AI

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso mail-mcp, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Puoi eseguire MCP localmente sul tuo dispositivo o connetterti all'URL di un server MCP remoto.

Opzione 1: usa il connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura connettore.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura connettore e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con l’opzione «Questo dispositivo» selezionata
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi mail-mcp come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di mail-mcp.
  4. Salva l'elenco dei server.
  5. Se vuoi verificare che il connettore sia ancora pronto, aggiorna la pagina.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "kacperkwapisz-mail-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di mail-mcp, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di mail-mcp.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare mail-mcp per aiutarmi con questa attività?
mail-mcp
Certo. L’ho letto.
Ecco cosa ho trovato con mail-mcp.

Opzione 2: aggiungi l'URL di un server MCP

Usa questo metodo se mail-mcp è già ospitato in remoto o se il tuo team vuole un unico connettore condiviso accessibile a più utenti.

1

Apri Connettori MCP

In TypingMind, vai su Plugin, apri Connettori MCP e scegli Aggiungi URL.

  1. Apri TypingMind nel tuo browser.
  2. Vai a Plugin.
  3. Apri Connettori MCP.
  4. Fai clic su Aggiungi URL.
Modulo di TypingMind per aggiungere l'URL di un server MCP personalizzato
2

Incolla l'URL del server

Inserisci l'URL del server MCP fornito dal provider nel campo URL del server. Aggiungi un nome per la connessione, una descrizione, un'icona, header HTTP personalizzati o le impostazioni del client OAuth se richiesti dal server.

  1. Incolla l'URL del server MCP fornito dal provider nel campo URL del server.
  2. Inserisci un nome per la connessione a mail-mcp.
  3. Se vuoi riconoscere più facilmente la connessione, aggiungi una descrizione e un’icona.
  4. Aggiungi header HTTP personalizzati o i dati del client OAuth se il server richiede l'autenticazione.
3

Crea la connessione

Fai clic su Crea connessione, poi torna all'elenco dei plugin e verifica che la nuova connessione MCP sia attiva.

  1. Fai clic su Crea connessione.
  2. Torna all'elenco dei connettori MCP.
  3. Verifica che la connessione mail-mcp risulti attiva.
  4. Aggiorna l'elenco dei plugin se la connessione non appare subito.
4

Cambia modello senza dover ristabilire la connessione MCP

Avvia una chat con il tuo modello preferito, abilita gli strumenti di mail-mcp dalla sezione Plugin e passa a un altro modello quando serve. La connessione MCP rimane disponibile nell'area di lavoro di TypingMind.

  1. Avvia una nuova chat in TypingMind.
  2. Seleziona il modello IA che vuoi usare.
  3. Abilita gli strumenti di mail-mcp dalla sezione Plugin.
  4. Chiedi al modello di usare lo strumento quando serve.
  5. Passa a un altro modello IA e riutilizza la stessa connessione MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare mail-mcp per aiutarmi con questa attività?
mail-mcp
Certo. L’ho letto.
Ecco cosa ho trovato con mail-mcp.

Domande frequenti

A cosa serve il server MCP mail-mcp?

mail-mcp è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare il server MCP mail-mcp con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare mail-mcp con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP mail-mcp con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando mail-mcp, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego il server MCP mail-mcp a TypingMind?

Puoi collegare mail-mcp a TypingMind con il connettore MCP locale oppure aggiungendo l'URL di un server MCP remoto. Usa il connettore locale quando il server deve accedere a file, app o risorse private sul tuo dispositivo; usa invece l'URL del server quando il server MCP è ospitato in remoto.

Quali strumenti offre il server MCP mail-mcp in TypingMind?

mail-mcp mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare il server MCP mail-mcp?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se mail-mcp richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇