magic-mail-mcp
v1.1.0
Published
Read-only mail archive + MCP server with local-first hybrid retrieval for OpenClaw.
Downloads
63
Maintainers
Readme
magic-mail-mcp
Read-only mail archive for Gmail and Yandex with a local polling worker and an MCP server.
It lets an agent:
- ingest new mail into a local archive automatically
- search archived mail locally with shared hybrid retrieval
- open full messages and threads through MCP
- deliver new-mail events to OpenClaw hooks when enabled
Runtime model
The package has two portable Node entrypoints:
magic-mail-mcp— the polling worker / archive CLImagic-mail-mcp-mcp— the MCP server
By default, magic-mail-mcp-mcp auto-starts one local polling worker per config root.
This keeps behavior consistent across clients without relying on launchd, systemd, or any other platform-specific supervisor.
If you want to disable worker auto-start for a specific host, set MAGIC_MAIL_MCP_AUTOSTART_WORKER=false.
Fast setup
- Create a config:
npx -y magic-mail-mcp init-configFill in
.envin the config directory.Check config:
npx -y magic-mail-mcp doctor- Add the MCP server:
{
"command": "npx",
"args": ["-y", "magic-mail-mcp-mcp"]
}What the agent gets
MCP tools:
mail_todaymail_listmail_searchmail_messagemail_thread
Important behavior:
- if you do not specify an account,
mail_todayandmail_listreturn top-N per mailbox - every result includes mailbox/account context
- the service is read-only
- search is powered by
magic-retrieval
Minimal config
Main settings in .env:
DB_PATH— local SQLite archive path for message stateRETRIEVAL_DB_PATH— optional SQLite path for retrieval storage; defaults toDB_PATHRETRIEVAL_LANCEDB_PATH— local LanceDB directory for vectorsOPENAI_API_KEY— optional, enables semantic retrieval; without it the service falls back to lexical-only searchGMAIL_ENABLED=trueplus Gmail credentialsYANDEX_ENABLED=trueplus Yandex credentialsOPENCLAW_DELIVERY_ENABLED=falseif you only want MCP and no hook delivery
Relative paths are resolved from the config directory.
Useful commands
Validate config:
npx -y magic-mail-mcp doctorRun one polling pass:
npx -y magic-mail-mcp --onceRun the worker explicitly:
npx -y magic-mail-mcp workerBackfill archive:
npx -y magic-mail-mcp backfill --days 365Search archive locally:
npx -y magic-mail-mcp search --query "invoice from alice"Run the MCP server directly:
npx -y magic-mail-mcp-mcpWorker logs
When the worker is auto-started by the MCP server, logs are written under the config root:
logs/worker.out.loglogs/worker.err.log
Notes
- Gmail uses read-only OAuth access
- Yandex uses read-only IMAP access
- mail and retrieval state are stored locally on disk
- the worker and MCP server are plain Node processes with no platform-specific service manager required
- the bridge does not send mail or modify messages
License
MIT
