jmap email tools - mcp server + cli for ai agents.
two interfaces:
- jmapper - token-efficient cli for ai agent email interaction
- mcp server - structured mcp tools for chat uis
# install deno
curl -fsSL https://deno.land/install.sh | sh
# install jmapper
deno install --allow-env --allow-net -n jmapper jsr:@niceyee/jmap-mcp/cli
# or compile standalone binary
deno compile --allow-env --allow-net -o jmapper jmapper.ts
# set credentials
export JMAP_SESSION_URL="https://mail.example.com/.well-known/jmap"
export JMAP_BEARER_TOKEN="user@example.com:password"
# use it
jmapper inbox
jmapper -c unread 10
jmapper read abc123# newline-separated accounts
export JMAP_BEARER_TOKENS="noc@example.com:pass1
billing@example.com:pass2
support@example.com:pass3"
# use specific account with -a flag (prefix match works)
jmapper -a noc inbox
jmapper -a billing unreadjmapper - compact jmap email cli
Commands:
inbox [n] Show inbox summary (default: 5 recent)
unread [n] Show unread emails
search <query> Search emails
read <id> Read email body
from <addr> [n] Emails from address
reply <id> <body> Quick reply
send <to> <subj> Send (reads body from stdin)
mark <id> read|flag Mark email
ids List sender identities
accounts List configured accounts
Options:
-a <account> Use specific account (email or prefix)
-c Compact output (one line per email)
for claude desktop, cursor, or other mcp clients:
{
"mcpServers": {
"email": {
"command": "deno",
"args": [
"run", "--allow-net", "--allow-env",
"jsr:@niceyee/jmap-mcp"
],
"env": {
"JMAP_SESSION_URL": "https://mail.example.com/.well-known/jmap",
"JMAP_BEARER_TOKEN": "user@example.com:password"
}
}
}
}works with any jmap-compliant server:
- stalwart mail server (recommended, easy selfhost)
- cyrus imap 3.0+
- fastmail (commercial)
- apache james
| aspect | jmapper cli | mcp server |
|---|---|---|
| output | compact text | json wrapped |
| tokens | ~100 per inbox | ~400 per inbox |
| latency | faster | more overhead |
| use case | ai agents, scripts | chat uis |
for ai agents doing email work, jmapper uses ~4x fewer tokens.
- Search Emails: Search emails with text queries, sender/recipient filters, date ranges, and keywords
- Get Emails: Retrieve specific emails by ID with full details
- Get Threads: Retrieve email threads (conversation chains)
- Mark Emails: Mark emails as read/unread, flagged/unflagged
- Move Emails: Move emails between mailboxes
- Delete Emails: Delete emails permanently
- Get Mailboxes: List all mailboxes/folders with hierarchy support
- Send Email: Compose and send new emails with support for plain text and HTML
- Reply to Email: Reply to existing emails with reply-all support
- Full JMAP RFC 8620/8621 compliance via jmap-jam
- Comprehensive input validation with Zod schemas
- Pagination support for all list operations
- Rich error handling and connection management
- Functional programming patterns throughout
- TypeScript support with strong typing
- Deno v1.40 or later
- A JMAP-compliant email server (e.g., Cyrus IMAP, Stalwart Mail Server, FastMail)
- Valid JMAP authentication credentials
Add the following to your agent of choice:
{
"mcpServers": {
"fastmail": {
"type": "stdio",
"command": "deno",
"args": [
"run",
"--allow-net=api.fastmail.com",
"--allow-env=JMAP_SESSION_URL,JMAP_BEARER_TOKEN,JMAP_ACCOUNT_ID",
"jsr:@wyattjoh/jmap-mcp@0.1.1"
],
"env": {
"JMAP_SESSION_URL": "https://api.fastmail.com/jmap/session",
"JMAP_BEARER_TOKEN": "API_TOKEN"
}
}
}
}| Variable | Required | Description |
|---|---|---|
JMAP_SESSION_URL |
Yes | JMAP server session URL (usually ends with /.well-known/jmap) |
JMAP_BEARER_TOKEN |
Yes | Bearer token for authentication |
JMAP_ACCOUNT_ID |
No | Account ID (auto-detected if not provided) |
Search for emails with various filters.
Parameters:
query(optional): Text search queryfrom(optional): Filter by sender email addressto(optional): Filter by recipient email addresssubject(optional): Filter by subject textinMailbox(optional): Search within specific mailboxhasKeyword(optional): Filter by keyword (e.g., '$seen', '$flagged')notKeyword(optional): Exclude by keywordbefore(optional): Only emails before date (ISO datetime)after(optional): Only emails after date (ISO datetime)limit(optional): Max results (1-100, default: 50)position(optional): Starting position for pagination (default: 0)
Retrieve specific emails by their IDs.
Parameters:
ids: Array of email IDs (1-50 IDs)properties(optional): Specific properties to return
Get list of mailboxes/folders.
Parameters:
parentId(optional): Filter by parent mailboxlimit(optional): Max results (1-200, default: 100)position(optional): Starting position for pagination
Get email threads by their IDs.
Parameters:
ids: Array of thread IDs (1-20 IDs)
Mark emails with keywords (read/unread, flagged/unflagged).
Parameters:
ids: Array of email IDs (1-100 IDs)seen(optional): Mark as read (true) or unread (false)flagged(optional): Mark as flagged (true) or unflagged (false)
Move emails to a different mailbox.
Parameters:
ids: Array of email IDs (1-100 IDs)mailboxId: Target mailbox ID
Delete emails permanently.
Parameters:
ids: Array of email IDs (1-100 IDs)
Send a new email.
Parameters:
to: Array of recipients withnameandemailcc(optional): Array of CC recipientsbcc(optional): Array of BCC recipientssubject: Email subjecttextBody(optional): Plain text bodyhtmlBody(optional): HTML bodyidentityId(optional): Identity to send from
Reply to an existing email.
Parameters:
emailId: ID of email to reply toreplyAll(optional): Reply to all recipients (default: false)subject(optional): Custom reply subjecttextBody(optional): Plain text bodyhtmlBody(optional): HTML bodyidentityId(optional): Identity to send from
This server should work with any JMAP-compliant email server, including:
- Cyrus IMAP 3.0+
- Stalwart Mail Server
- FastMail (commercial)
- Apache James (with JMAP support)
deno run --allow-env --allow-net --watch src/mod.ts# Test connection
deno run --allow-env --allow-net src/mod.tsThe server is built using:
- Deno: Modern JavaScript/TypeScript runtime
- @modelcontextprotocol/sdk: MCP server framework
- jmap-jam: Lightweight, typed JMAP client
- Zod: Runtime type validation
- All input is validated using Zod schemas
- Environment variables are used for sensitive configuration
- No secrets are logged or exposed in responses
- Follows JMAP security best practices
- Fork the repository
- Create a feature branch
- Make changes following the functional programming style
- Test your changes thoroughly
- Submit a pull request
MIT License - see LICENSE file for details.
- jmap-jam - JMAP client library
- Model Context Protocol - MCP specification
- JMAP RFC 8620 - JMAP core protocol
- JMAP RFC 8621 - JMAP for Mail