Skip to main content
Glama
jmap-mcp-worker

jmap-mcp-worker

by re-x-agent

jmap-mcp-worker

An MCP server for a mailbox on a JMAP server. It lists mailboxes, searches mail, reads message bodies and sends mail to an allowlist of recipients.

It is written for Mailflare first (multi-mailbox logins, Mailflare's JMAP ids and rights model) and follows RFC 8620/8621 closely enough to work with other JMAP servers.

It runs two ways:

  • Cloudflare Worker: a stateless remote MCP endpoint (Streamable HTTP) at /mcp.

  • stdio: npx jmap-mcp-worker for local MCP clients.

Tools

Tool

What it does

list_accounts

JMAP accounts of the login (primary first)

list_mailboxes

Mailboxes with roles, counts and your rights

search_emails

Text/from/to/subject/mailbox/date/attachment/unread filters, paged

read_email

Headers, plain-text body (HTML only if there is no text part), attachment list

send_email

Plain-text mail. Off unless SEND_ALLOWLIST is set, and only to the recipients it lists

Related MCP server: cypht-mcp

Authentication

The server holds no credentials. Each request carries the caller's Authorization header, which is forwarded as it is to the JMAP server, and only to the origin of JMAP_SESSION_URL (a session whose apiUrl points elsewhere is refused). Use whatever your JMAP server accepts as a Bearer or Basic credential:

  • Now: an app password or API key (Mailflare accepts an app password as a Bearer token).

  • With an identity provider: an OIDC access token from your IdP, if the JMAP server accepts OIDC bearer tokens. Set OAUTH_ISSUER and the Worker answers 401 with a WWW-Authenticate: Bearer resource_metadata=… challenge and serves /.well-known/oauth-protected-resource, so MCP clients that speak the MCP authorization flow can discover the issuer and sign in.

Run it on Cloudflare

npm install
# edit wrangler.jsonc: JMAP_SESSION_URL (and optionally OAUTH_ISSUER, SEND_ALLOWLIST)
npx wrangler deploy

Connect an MCP client to https://<your-worker>/mcp with an Authorization: Bearer <token> header.

Local trial: put JMAP_SESSION_URL=… in .dev.vars (git-ignored), npx wrangler dev, then JMAP_TOKEN=… node test/live.mjs.

Run it over stdio

{
  "mcpServers": {
    "mail": {
      "command": "npx",
      "args": ["-y", "jmap-mcp-worker"],
      "env": {
        "JMAP_SESSION_URL": "https://mail.example.com/.well-known/jmap",
        "JMAP_TOKEN": "your-token",
        "SEND_ALLOWLIST": "you@example.com"
      }
    }
  }
}

JMAP_USERNAME and JMAP_PASSWORD (Basic) work in place of JMAP_TOKEN. Node 22.6 or newer.

Mailflare notes

  • A Mailflare login can own or be delegated several mailboxes. The server reads the account from the session (primaryAccounts); pass accountId to use another one. Older Mailflare versions expose one account per login with the mailboxes as top-level nodes, newer ones one account per mailbox; both work.

  • send_email puts the draft in the Drafts folder of the sending identity's own mailbox before submitting it.

Safety

  • Sending is opt-in and recipient-limited. An unlisted recipient is refused before anything is created.

  • Message bodies are untrusted input to the model. Treat mail content as data, not instructions.

Development

npm test        # node --test, no network
npm run typecheck

License

MIT. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Cloudflare Worker implementation of the Cypht email MCP, providing eight email tools for account management, email sending, listing, viewing, searching, and deletion via IMAP.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Gmail MCP server running on Cloudflare Workers that enables reading, searching, labeling, drafting, sending, and managing Gmail messages, including fetching raw attachment bytes, with per-user OAuth authorization.
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      gmail-mcp is a remote MCP server that exposes Gmail as a set of tools — search, read, label, draft, send — over streamable HTTP with OAuth 2.1. It runs on Cloudflare Workers under your own domain.
      10
      MIT