Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
CLI and MCP server for Fastmail — email, contacts, masked email, attachments, text extraction. JMAP + CardDAV + GraphQL.
Jump to setup instructionsNo tool list is on record. This does not mean the server has no tools. Tools were not run.
No setup evidence yet No matching config or report on record. This does not mean the server is incompatible.
Same catalog task: Scrape & extract data.
Does an AI crawler see your site? Free registry lookup, x402 pricing; checks paid in USDC on Base.
Same catalog task: Scrape & extract data.
Dependency-probe-gated exit execution with hash-verified extraction and signed receipts.
Same catalog task: Scrape & extract data.
x402 agent tools: invoice/PDF extract, OCR, email risk, web to markdown, domain, FX, time
Fetched from the repository for this visit.
CLI for Fastmail's JMAP API. Read, search, send, manage and watch email from your terminal or AI assistant.
| Feature | Description |
|---|---|
| List, search, read, threads; send, reply, reply-all and forward with HTML bodies, attachments and a choice of identity | |
| Drafts | Save any send, reply or forward as a draft, then edit, send or discard it (MCP) |
| Search | JMAP's whole filter tree: nested and / or / not, keywords, thread-wide keyword conditions, raw header matching, every sort comparator; highlighted snippets of why each result matched |
| Mailboxes | List, create, rename, move, (un)subscribe and delete folders (MCP); move emails, mark read/unread, spam and not spam (both train the filter) |
| Flags & labels | Flag, set any keyword, file an email in several folders or take it out of one, by ID or over a filter (MCP) |
| Deleting | Permanently destroy emails or empty Trash and Junk, previewed first (MCP) |
| Scheduled send | sendAt on any send, list what is pending, cancel back to Drafts (MCP) |
| Mailing lists | Every sender with an unsubscribe header, grouped; one-click (RFC 8058) or mailto unsubscribe |
| Bulk sweeps | Move, mark read or mark spam everything a filter matches, previewed with a count and sample first (MCP) |
| Real-time | fastmail watch streams arriving mail as NDJSON over JMAP push, with a polling fallback; also a GraphQL subscription over SSE |
| Contacts | Search, create, update, delete via CardDAV |
| Attachments | Download, upload, extract text from 56 formats via kreuzberg, resize images to a byte budget, read attached emails; import .eml files (MCP) |
| Masked Email | List, create (with a prefix), enable, disable, delete, edit notes |
| MCP Server | Two tools over one GraphQL schema: a whole question in one query, with nested fields batched into single JMAP calls |
| HTTP | Streamable-HTTP MCP, plain GraphQL and a GraphiQL IDE on one port; per-request credential headers for hosting it for several users |
| Container image | Multi-arch (amd64, arm64) on GHCR, running as non-root |
| Shell Completions | Bash, Zsh, Fish, PowerShell |
| JSON Output | All commands output JSON for scripting |
Fastmail ships an official MCP server
at api.fastmail.com/mcp, authorised by OAuth with read, write and send access
levels. It needs no setup and covers more of Fastmail's suite: calendar
(including answering invitations), notes, message memos and the organisation
directory, none of which fastmail-cli touches. fastmail-cli is a CLI and
an MCP server you run yourself, open source, and goes further on mail:
forwarding, scheduled sends, folder management, attachment contents and
attached emails, masked email, spam training, unsubscribing, bulk sweeps, and
a real-time stream of incoming mail.
fastmail-cli | Fastmail official MCP | |
|---|---|---|
| Interface | CLI and MCP (stdio / HTTP) | MCP only |
| Tools | 2: one GraphQL schema | 29 individual tools |
| Setup | install the binary or run the image | add the URL and authorise |
| Auth | API token (+ app password for CardDAV) | OAuth, or an MCP API token |
| Hosting / data path | your machine or your own server | Fastmail-hosted |
| Source | open source (MIT) | proprietary |
| Email: search / read / threads | ✅ (full JMAP filter tree) | ✅ |
| Several emails, bodies and attachments in one call | ✅ (one GraphQL query) | — |
| Send / reply | ✅ (preview → confirm) | ✅ (drafts; sending needs Send access) |
| Forward | ✅ | — |
| Drafts: create / edit / send / discard | ✅ (MCP) | create |
| Move / archive / mark read | ✅ | ✅ |
| Folders: create / rename / move / delete | ✅ (MCP) | — |
| Delete email | ✅ (MCP, permanent; preview → confirm) | ✅ |
| Message memos | — | ✅ |
| Mark spam / not spam (trains the filter) | ✅ | — |
| Mailing lists: find them, unsubscribe | ✅ (one-click or mailto) | — |
| Bulk move / mark read / flag / label / spam by filter | ✅ (MCP) | — |
| Real-time stream of incoming mail | ✅ (CLI + GraphQL subscription) | — |
| Attachments: download, text from 56 formats, resize | ✅ | — |
Attached emails: read; import .eml files | ✅ (MCP) | — |
| Attachments: upload | ✅ | ✅ |
| Masked Email: create / toggle / delete / edit notes | ✅ | — |
| Identities | ✅ (with signatures; create / edit) | ✅ |
| Scheduled send / cancel | ✅ (MCP) | — |
| Contacts: search / create / update / delete | ✅ (CardDAV) | ✅ |
| Organisation directory search | — | ✅ |
| Calendar: search / create / update / delete / RSVP | — | ✅ |
| Notes: search / read / create / update / delete | — | ✅ |
| Connection check (token valid, capabilities) | ✅ (session) | — |
| GraphiQL IDE | ✅ | — |
Use Fastmail's for zero maintenance and the wider suite; use fastmail-cli
for a scriptable CLI, the mail tooling above, or to keep the data path on a
machine you control. Streaming is the one difference that is not a matter of
scope: MCP tools are request/response, so a hosted MCP server cannot return a
subscription that never ends, whatever tools it adds.
fastmail-cli's column is checked against its GraphQL schema. Fastmail
publishes no tool list of its own; its column follows the 29 tools in its
Claude connector listing and its
help article as
of November 2026, and the set may grow.
# Add to mise config
mise use -g "github:radiosilence/fastmail-cli"
cargo install --git https://github.com/radiosilence/fastmail-cli
ps, and the process environment:# interactive — paste the token at the prompt
fastmail auth
# non-interactive — pipe from a password manager, file, or env var
echo "$FASTMAIL_TOKEN" | fastmail auth
The positional form fastmail auth YOUR_TOKEN still works for backward compatibility, but the stdin form is preferred.
Token is stored in ~/.config/fastmail-cli/config.toml with 0600 permissions (directory 0700). The file is written atomically via rename, and the path is refused if it's a symlink.
Credentials can be set via environment variables or config file. Env vars take precedence.
Environment variables:
export FASTMAIL_API_TOKEN="fmu1-..." # Required for JMAP (email)
export FASTMAIL_USERNAME="you@fastmail.com" # Required for CardDAV (contacts)
export FASTMAIL_APP_PASSWORD="xxxx..." # Required for CardDAV (contacts)
Config file (~/.config/fastmail-cli/config.toml):
[core]
api_token = "fmu1-..."
[contacts]
username = "you@fastmail.com"
app_password = "xxxx..."
The auth command only sets [core].api_token. For contacts, add [contacts] section manually or use env vars.
All output is JSON for easy scripting with jq.
fastmail list mailboxes
# Default: INBOX, 50 emails
fastmail list emails
# Specific mailbox and limit
fastmail list emails --mailbox Sent --limit 10
fastmail get EMAIL_ID
Search uses JMAP filter flags (all filters are ANDed together):
# Full-text search
fastmail search --text "meeting notes"
# Filter by header fields
fastmail search --from "alice@example.com"
fastmail search --to "bob" --subject "project"
# Filter by mailbox
fastmail search --mailbox Sent --limit 10
# Attachments and size
fastmail search --has-attachment
fastmail search --min-size 1000000 # > 1MB
# Date range (ISO 8601)
fastmail search --after 2024-01-01 --before 2024-12-31
# Status filters
fastmail search --unread
fastmail search --flagged
# Combine filters
fastmail search --from "boss" --has-attachment --after 2024-06-01 --limit 20
Available flags: --text, --from, --to, --cc, --bcc, --subject, --body, --mailbox, --has-attachment, --min-size, --max-size, --before, --after, --unread, --flagged
Block and emit one JSON object per line as mail arrives, so a shell loop can act on it:
# Everything that arrives, anywhere in the account
fastmail watch
# Just the inbox
fastmail watch --mailbox inbox
# Pipe into a loop
fastmail watch --mailbox inbox | while read -r line; do
echo "$line" | jq -r '.data.subject'
done
# Include bodies and attachment metadata, not just summaries
fastmail watch --full
# Fall back to polling every 60s where a long-lived connection won't survive
fastmail watch --poll 60
Output is the same {"success":true,"data":{...}} envelope as every other
command, one compact line per email, flushed as it is written — so jq filters
and read loops both work unbuffered.
It uses JMAP's push channel (eventSourceUrl), but treats a notification purely
as a signal to look again: the state cursor lives in the CLI, and each wake-up
runs Email/changes against it. Dropped connections are reconciled on reconnect
and --poll takes the identical path, so a missed notification costs latency
rather than mail; the cursor moves only once the new mail has been fetched, and
failed reads back off rather than retrying at full rate. --poll takes at least
10 seconds. Only new messages are reported — flag and folder changes to
existing mail are not arrivals.
Reconnects, and the rare case where the server has discarded change history and the cursor has to resync, are reported on stderr; stdout stays pure NDJSON.
View available sender identities (useful for --from):
fastmail list identities
fastmail send \
--to "alice@example.com, bob@example.com" \
--subject "Hello" \
--body "Message body here"
# With CC/BCC
fastmail send \
--to "alice@example.com" \
--cc "bob@example.com" \
--bcc "secret@example.com" \
--subject "Hello" \
--body "Message"
# Send from a specific identity/alias
fastmail send \
--to "alice@example.com" \
--from "alias@yourdomain.com" \
--subject "Hello" \
--body "Message"
# HTML email body (inline or from file)
fastmail send \
--to "alice@example.com" \
--subject "Newsletter" \
--body "Plain text fallback" \
--html-body "<h1>Hello</h1><p>Rich content here</p>"
fastmail send \
--to "alice@example.com" \
--subject "Report" \
--body "See attached" \
--html-file ./email.html
# File attachments (repeatable)
fastmail send \
--to "alice@example.com" \
--subject "Documents" \
--body "Please review" \
-a report.pdf -a data.xlsx
fastmail move EMAIL_ID --to Archive
fastmail move EMAIL_ID --to Trash
# Requires confirmation
fastmail spam EMAIL_ID
# Skip confirmation
fastmail spam EMAIL_ID -y
# Back to the inbox, flagged $notjunk so the filter learns from it
fastmail not-spam EMAIL_ID
# Every sender whose mail carries List-Unsubscribe, most prolific first,
# with unread counts and the newest unsubscribe links
fastmail lists
fastmail lists --after 2025-01-01 --limit 2000
# Leave the list an email came from. One-click (RFC 8058) when the sender
# supports it, else an email to its mailto: address, sent from the address
# the list wrote to when that is one of your identities. Senders that only
# offer a web page are reported with the link, to finish in a browser.
fastmail unsubscribe EMAIL_ID # says what it would do
fastmail unsubscribe EMAIL_ID -y # does it
One-click POSTs only go to public HTTPS addresses (the host is resolved and checked, and the connection pinned to what was checked) and never follow redirects: the URL comes from a header anyone can write, and in a hosted deployment the request leaves from the server.
Fastmail's filter rules are not exposed over JMAP, so they can't be managed
here. Over MCP, sweepEmails applies a rule's action — move, mark read, mark
spam — to everything a filter already matches, PREVIEW then CONFIRM.
# Mark as read
fastmail mark-read EMAIL_ID
# Mark as unread
fastmail mark-read EMAIL_ID --unread
# Download to current directory
fastmail download EMAIL_ID
# Download to specific directory
fastmail download EMAIL_ID --output ~/Downloads
# Extract text content as JSON (PDF, DOCX, DOC, TXT)
fastmail download EMAIL_ID --format json
# Resize images to max 500KB
fastmail download EMAIL_ID --max-size 500K
Text extraction uses kreuzberg and supports 56 formats:
# Reply to sender only
fastmail reply EMAIL_ID --body "Thanks for your message"
# Reply all
fastmail reply EMAIL_ID --body "Thanks everyone" --all
# Reply with additional CC/BCC
fastmail reply EMAIL_ID --body "Response" --cc "boss@example.com"
# Reply from a specific identity
fastmail reply EMAIL_ID --body "Thanks" --from "alias@yourdomain.com"
fastmail forward EMAIL_ID \
--to "colleague@example.com" \
--body "FYI - see below"
# Forward from a specific identity
fastmail forward EMAIL_ID \
--to "colleague@example.com" \
--from "alias@yourdomain.com" \
--body "FYI"
# Bash
fastmail completions bash >> ~/.bashrc
# Zsh
fastmail completions zsh >> ~/.zshrc
# Fish
fastmail completions fish > ~/.config/fish/completions/fastmail.fish
CRUD operations for Fastmail contacts via CardDAV. Requires an app password (API tokens don't work for CardDAV).
# Set credentials
export FASTMAIL_USERNAME="you@fastmail.com"
export FASTMAIL_APP_PASSWORD="your-app-password"
# List all contacts
fastmail contacts list
# Search by name, email, or organization
fastmail contacts search "alice"
# Create a new contact
fastmail contacts create --name "Jane Doe" --email "jane@example.com" --organization "Acme Corp"
# Update an existing contact (only provided fields are changed)
fastmail contacts update CONTACT_ID --organization "New Corp" --title "CEO"
# Delete a contact (requires -y confirmation)
fastmail contacts delete CONTACT_ID -y
Generate an app password at Fastmail Settings > Privacy & Security > Integrations > App passwords.
Create disposable email addresses for signups. Requires Fastmail's masked email feature.
# List all masked emails
fastmail masked list
# Create a new masked email
fastmail masked create --domain "https://example.com" --description "Example Site"
# Create with custom prefix
fastmail masked create --prefix "shopping" --description "Shopping sites"
# Enable/disable a masked email
fastmail masked enable MASKED_EMAIL_ID
fastmail masked disable MASKED_EMAIL_ID
# Delete (requires confirmation)
fastmail masked delete MASKED_EMAIL_ID -y
All commands output JSON with this structure:
{
"success": true,
"data": { ... },
"message": "optional status message",
"error": "error message if success=false"
}
# Get unread count for INBOX
fastmail list mailboxes | jq '.data[] | select(.role == "inbox") | .unreadEmails'
# List email subjects
fastmail list emails | jq '.data.emails[].subject'
# Get email body
fastmail get EMAIL_ID | jq -r '.data.bodyValues | to_entries[0].value.value'
If you're using Claude Code, this repo ships skills that teach agents how to use the CLI — no need to explain flags or workflows manually.
Copy the skills into your project's .claude/skills/ directory (or anywhere Claude Code loads skills from), then invoke them:
/fastmail # full command reference + common patterns
/fastmail/search # search filters, date ranges, workflows
/fastmail/compose # send, reply, forward, drafts, identities
/fastmail/conversations # list, get, thread, mark-read, triage
/fastmail/attachments # download, raw vs json, text extraction
/fastmail/masked # masked email CRUD
/fastmail/contacts # CardDAV setup, list/search
Skills are in .claude/skills/ in this repo. Each one includes concrete examples and agent-oriented workflow patterns.
fastmail mcp serves the MCP over stdio by default, or over HTTP with
--http. Which setup fits depends on where the client runs.
Local. Claude Code and Claude Desktop can start the binary themselves on
your machine and talk to it over stdio, using the credentials from
fastmail auth. Nothing listens on a port and nothing needs authenticating
beyond your own login. This is the simplest setup and covers most use.
Remote. Claude on the web and on mobile, and connectors added in Claude
Desktop's settings, are not running on your machine: Anthropic's servers make
the MCP calls, so they can neither start a binary nor reach localhost. They
need an HTTPS URL on the internet, and the only authentication they support is OAuth;
there is no way to give them a fixed header. Exposing fastmail mcp --http
directly would hand your mailbox to anyone who finds the URL, so a remote
setup puts a gateway in front (see Behind a gateway).
The client starts the binary itself. With credentials saved by fastmail auth
(or in the config file) nothing else is needed. Claude Code:
claude mcp add fastmail -- fastmail mcp
Claude Desktop's claude_desktop_config.json, passing credentials as
environment variables instead:
{
"mcpServers": {
"fastmail": {
"command": "mise",
"args": ["x", "--", "fastmail", "mcp"],
"env": {
"FASTMAIL_API_TOKEN": "your-token-here",
"FASTMAIL_USERNAME": "you@fastmail.com",
"FASTMAIL_APP_PASSWORD": "your-app-password"
}
}
}
}
Username and app password are optional: they are only needed for contacts, since CardDAV does not accept API tokens.
One long-running server several clients can share, using your local
credentials. It listens on 127.0.0.1:8080 and accepts only requests addressed
to it (see HTTP transport).
fastmail mcp --http
claude mcp add --transport http fastmail http://127.0.0.1:8080/mcp
The image runs fastmail mcp --http 0.0.0.0:8080 and holds no credentials, so
every request carries its own in headers:
| Header | Needed for |
|---|---|
X-Fastmail-Token | everything over JMAP |
X-Fastmail-Username | contacts (CardDAV) |
X-Fastmail-App-Password | contacts (CardDAV) |
docker run --rm -p 127.0.0.1:8080:8080 ghcr.io/radiosilence/fastmail-cli:latest
claude mcp add --transport http fastmail http://127.0.0.1:8080/mcp \
--header "X-Fastmail-Token: fmu1-..." \
--header "X-Fastmail-Username: you@fastmail.com" \
--header "X-Fastmail-App-Password: xxxx..."
Tags are latest, vX, vX.Y and vX.Y.Z for releases, and main for the
current main branch.
The server trusts these headers unconditionally, so a container reachable by anyone other than you belongs behind a gateway that authenticates the caller and injects the headers itself.
A minimal single-user gateway is a reverse proxy that checks a shared secret and adds your credentials. With Caddy, which also provides TLS:
mail.example.com {
@authed {
path /mcp
header Authorization "Bearer {$GATEWAY_SECRET}"
}
handle @authed {
reverse_proxy fastmail:8080 {
header_up X-Fastmail-Token {$FASTMAIL_API_TOKEN}
header_up X-Fastmail-Username {$FASTMAIL_USERNAME}
header_up X-Fastmail-App-Password {$FASTMAIL_APP_PASSWORD}
}
}
respond 401
}
# compose.yaml
services:
fastmail:
image: ghcr.io/radiosilence/fastmail-cli:latest
caddy:
image: caddy:2
ports: ["80:80", "443:443"]
env_file: .env # GATEWAY_SECRET and the three FASTMAIL_ variables
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy-data:/data
volumes:
caddy-data:
claude mcp add --transport http fastmail https://mail.example.com/mcp \
--header "Authorization: Bearer $GATEWAY_SECRET"
The credentials live only in the proxy's environment, and header_up
replaces any X-Fastmail-* header a client sends rather than passing it on.
Leave them out of the fastmail container's environment: a server holding
local credentials refuses requests whose Host is not its own, and Caddy
forwards the client's mail.example.com.
That proxy is enough for clients that let you set a header, such as Claude Code. It does not work for Claude's remote connectors, which expect OAuth.
A gateway separates two questions this server does not answer itself: who is
calling, and which Fastmail account they may use. fastmail-cli only knows the
second, from the X-Fastmail-* headers on each request, and trusts them
completely. The gateway answers the first, then supplies the second, so the
Fastmail credentials never leave the server side and the client only ever holds
a token for the gateway.
For a remote connector the client side follows the MCP authorization spec, which is standard OAuth 2.1:
fastmail mcp with them as headers.Because credentials are looked up per user, one gateway and one fastmail-cli
container can serve several people, and revoking a connector's token cuts it
off without changing any Fastmail credential. A gateway can also front several
MCP servers under one login, each with its own credentials.
mcp-gateway implements this: an OAuth authorization server for sign-in, a dashboard where each user enters their Fastmail credentials (stored encrypted), and a proxy that injects them per request. Its README covers deployment. Any OAuth-capable gateway or proxy that can set request headers per user works the same way.
Three independent surfaces, each opt-in, sharing one port (default
127.0.0.1:8080, or pass an address to --http):
| Flag | Serves |
|---|---|
--http | MCP streamable-HTTP at /mcp |
--graphql | plain GraphQL-over-HTTP at /graphql, subscriptions at /graphql/stream |
--graphiql | the GraphiQL IDE at /, and its /graphql |
--browser | opens the IDE once the port is bound, implying --graphiql |
fastmail mcp # stdio MCP, no listener
fastmail mcp --browser # just the IDE, opened for you
fastmail mcp --http # just /mcp
fastmail mcp --http 0.0.0.0:8080 --graphql # both, explicit address
Asking for any surface binds the listener; there is nowhere to mount an HTTP
route over stdio. Only --http puts MCP on it — the transport a model connects
through and a browsable endpoint for you are separate things. --browser
implies --graphiql, since the IDE is what it opens.
/graphql is plain GraphQL-over-HTTP, which is what a browser speaks; /mcp is
MCP JSON-RPC, which it doesn't. That is why GraphiQL needs its own route rather
than pointing at the MCP one. Both share the schema, the client cache and the
credential resolution below, so the IDE sees exactly what a model sees.
/graphql/stream carries subscriptions over Server-Sent Events — POST the
operation, read events off the response:
curl -N http://127.0.0.1:8080/graphql/stream \
-H 'Content-Type: application/json' \
-d '{"query":"subscription { emails(mailbox: \"inbox\") { id subject from { email } } }"}'
SSE rather than WebSockets because the only subscription is a server-to-client
firehose: nothing is ever sent back up the socket, and SSE reconnects on its
own. Body fields (textBody, attachments) want full: true, which fetches them
with each arrival; selected without it, each costs a fetch per arrival. A
subscription caches nothing between arrivals, so it does not grow however long
it runs. pollSeconds is the same fallback as the CLI's --poll, at least 10
seconds. MCP has no equivalent: tools are
request/response, and a subscription never returns.
Credential resolution is the same everywhere: the request's own header wins, otherwise the local config (or the matching environment variable) is used. Running it yourself, that means your own credentials with no ceremony. In a hosted deployment there is no local config, so the fallback is absent and every request must carry its headers, injected by a trusted upstream after it has authenticated the caller. Authenticated JMAP clients are cached per token, so the JMAP session handshake runs once per distinct token rather than per call.
| Header | Falls back to | Needed for |
|---|---|---|
X-Fastmail-Token | FASTMAIL_API_TOKEN | everything over JMAP |
X-Fastmail-Username | FASTMAIL_USERNAME | contacts (CardDAV) |
X-Fastmail-App-Password | FASTMAIL_APP_PASSWORD | contacts (CardDAV) |
Contacts take two headers rather than riding on the token because CardDAV is a
separate protocol that rejects API tokens outright. Each resolves on its own: a
request carrying a username header but no password gets exactly that — half a
credential, which session { carddavConfigured } reports as false — rather
than quietly completing itself from the host's local config and mixing two
users together.
With local credentials, requests must be addressed to this server. A
server holding a local token (config or FASTMAIL_API_TOKEN) or local CardDAV
credentials answers a request that brings none with yours, so a web page that
rebinds a hostname of its own to 127.0.0.1 could otherwise reach your mailbox
through the port. Such a server refuses a Host other than the bind address,
localhost, 127.0.0.1 and [::1], and a browser Origin other than its own
(GraphiQL, served from the same port, is its own). Allow another name, such as
a proxy's, with --allowed-host (repeatable, or comma-separated) or
FASTMAIL_MCP_ALLOWED_HOSTS; a port on the name is optional:
fastmail mcp --http 0.0.0.0:8080 --allowed-host fastmail.mcp.svc.cluster.local
A server holding no local credentials, as in a hosted deployment, accepts any
Host and Origin: every request must bring its own credentials, so there is
nothing of yours for a page to reach, and a gateway forwarding its own service
name needs no setting. Which mode applies is logged at start.
Do not expose this to the internet without such an auth layer in front — the header is trusted unconditionally. Equally, do not run it with local credentials present on a non-loopback address: anything that can reach the port gets your mailbox without needing a token at all.
The token is resolved on first query rather than at startup, so an expired one
shows up as an error in the response pane rather than a server that won't boot —
run fastmail auth to refresh it, or ask session first. Introspection needs
no token: it is answered from the schema without touching Fastmail, so
GraphiQL's docs, autocomplete and explorer work before you have working
credentials. Queries that select any real field still authenticate as normal.
session answers whether a token still works, and needs no mail to exist to do
it:
{ session { status username primaryAccountId capabilities carddavConfigured detail } }
One GET /jmap/session — the handshake Fastmail only completes for a request it
has authenticated. status is CONNECTED, INVALID_CREDENTIALS, or
UNREACHABLE, and a bad connection is reported there rather than raised as a
GraphQL error: it is the answer to this question, not a failure to answer it.
The split is the one a UI acts on — tell the user to re-authenticate, or tell
them to wait. A 401 is the only thing that reads as a credential verdict;
everything else (5xx, rate limiting, timeouts, DNS) is UNREACHABLE, because
telling someone their token is dead over an outage would be a lie. detail
carries the reason in prose for a tooltip; branch on status, which won't be
reworded.
It re-runs the handshake rather than reading the cached client — clients are cached per token for the life of the process, so a cached answer would keep reporting success long after a revocation, which is the case this exists to catch. When connected it also reports the accounts the token reaches and the capability URNs it was granted, which is what says whether masked email and sending are available at all.
carddavConfigured is the one thing there that capabilities cannot answer.
Capabilities are what the JMAP server advertises, and contacts go over CardDAV —
a separate protocol, with separate credentials, invisible to the handshake. So
without it the only way to find out that contacts is unavailable is to run it
and fail, halfway through a plan that assumed it. It reports whether a username
and app password are both present, not whether they are correct, and it answers
independently of status: credentials are local configuration, so a dead API
token doesn't make contact reachability unanswerable.
The MCP server exposes 2 tools via a GraphQL interface:
graphql — executes any GraphQL query or mutation. Its description carries a slimmed schema for everyday mail: the queries, the EmailFilter tree, the common Email fields, the connection shape and the PREVIEW→CONFIRM send flowschema_sdl — the full SDL, with an optional types list (e.g. ["MutationRoot", "Attachment"]) returning only those definitionsThe split is about round trips. The SDL is ~27KB, most of it the doc comments
that make it worth reading, and it was previously the only way to learn
anything — so reading mail cost a 27KB fetch first, and cost it again whenever
the connection dropped. The common case is now answered where the model is
already looking, and schema_sdl is for what the sketch explicitly says it
doesn't cover: attachment payloads, masked email, contacts, identities,
moveEmail, markAsRead, markAsSpam, markAsNotSpam, mailingLists,
unsubscribe, sweepEmails, and the remaining filter and sort options. types keeps that second hop small too. Named types come back whole
but their references don't, so name those as well; an unrecognised name is
reported alongside the list of names that do exist, rather than silently
dropped.
Both the worked examples and the inlined sketch are checked by the test suite — the examples are executed against the real schema, and every field name in the sketch must exist in it. A cheat sheet that outlives a rename is worse than no cheat sheet.
This replaces the previous 18 individual tools with a composable interface. The LLM fetches the schema once, then constructs exactly the queries it needs — fetching multiple resources in a single round-trip, requesting only the fields it wants, and using typed arguments for filtering and pagination.
The object graph is fully navigable, so the LLM can get everything it needs in one hit:
Mailbox ──emails──▶ Email ──attachments──▶ Attachment ──base64/image/text──▶
▲ │ │ │
│ └─parent/children┘ ├──thread──▶ Thread ──emails──▶ Email …
└────mailboxes───────┘
Every collection is a Relay connection — mailboxes, identities,
maskedEmails, contacts, attachments, Mailbox.children, Thread.emails —
so each takes first / last / after / before and exposes totalCount,
pageInfo, edges and nodes. Cursors are IDs. Use nodes for the items;
edges only when you want per-item cursors. Default page 25, max 100 — check
pageInfo.hasNextPage rather than assuming you got the lot.
Only emails pages server-side, via JMAP's anchors. The rest arrive whole from
one call, so their paging is slicing: totalCount is free (a length, not
calculateTotal) and a cursor holds only as long as its item is still in the
list — if it goes, you get a "restart pagination" error rather than a quietly
different page. Thread.emails returns the same EmailConnection as the query
does, with queryState null because a conversation is not a query.
Value lists stay plain arrays: from, to, cc, bcc, replyTo, sender,
keywords, mailboxIds, headers, Contact.emails. They belong to the parent,
arrive with it, and paging them would be ceremony.
Attachment payloads are three separate fields, each doing the least work that
answers it. Metadata (name, size, contentType, cid, …) arrives with the
email and downloads nothing at all:
base64 — the raw bytes, base64-encoded. Download only, any type.image(maxBytes:) — resized then encoded, so a model isn't handed a 10MB
photo. Null for non-images.text — extracted document text. The expensive one: it parses the whole
file, is priced far above the other two, and nothing else on Attachment
triggers it. Prefer a small page when selecting it.# Bodies and attachment text for a whole folder — one query, 3 API calls.
# Note the smaller page: `text` parses every document, so a big page means a
# lot of work. Nothing stops you asking for more; the cost is just yours.
{
emails(filter: { inMailbox: "INBOX" }, first: 10) {
nodes {
subject
from { name email }
textBody
attachments {
nodes { name contentType size cid text }
}
}
}
}
# Walk the graph: folder tree → emails → conversation → the folders they live in
{
mailbox(name: "INBOX") {
name
children { nodes { name unreadEmails } }
emails(first: 5) {
nodes {
subject
thread { total emails { nodes { subject textBody } } }
mailboxes { name role }
}
}
}
}
sendEmail, replyToEmail, forwardEmail and updateDraft take
attachments: [AttachmentInput!]. The server usually runs somewhere other than
the client, so a local path means nothing to it; each attachment carries its
content instead, as exactly one of:
base64 — the file's bytes, inline.blobId — a blob already on the server, attached without re-uploading:
one returned by uploadAttachment, or an existing email's
attachments { nodes { blobId } }.name is required; contentType is inferred from the name when omitted.
mutation {
sendEmail(
action: PREVIEW
to: "a@example.com"
subject: "Report"
body: "Attached."
attachments: [{ name: "report.pdf", base64: "JVBERi0xLjQK..." }]
) { preview confirmationToken }
}
PREVIEW lists every attachment's name, type and size, and the confirmation
token covers them: a CONFIRM whose attachments differ in name, type or content
is rejected. Because CONFIRM repeats PREVIEW's arguments, inline base64 travels
twice; uploadAttachment(name:, base64:) sends it once and returns a blobId
to use in both. A blob given by ID is downloaded at PREVIEW to measure it, since
Fastmail does not offer JMAP's Blob/get.
Attachments are capped at 25 MB per message (Fastmail's own limit is 50 MB):
every inline byte passes through a tool argument, a third larger as base64.
updateDraft's attachments replaces the draft's attachments; pass an
existing one's blobId to keep it. Inline images an HTML body refers to are
kept either way.
EmailFilter mirrors JMAP's filter tree (RFC 8620 §5.5) rather than flattening
it into scalar arguments. Fields on one filter object are AND-ed; and / or /
not nest arbitrarily. The same input type is accepted everywhere emails
appear, including Mailbox.emails, where it's AND-ed with the mailbox.
# Unread, from either sender, not in Archive, biggest first
{
emails(
filter: {
unread: true
or: [{ from: "alice@example.com" }, { from: "bob@example.com" }]
not: [{ inMailbox: "Archive" }]
}
sort: [{ property: SIZE, ascending: false }]
first: 20
) {
totalCount
nodes { subject size }
}
}
Mailbox names and roles are resolved to IDs at every depth of the tree in a
single Mailbox/get. collapseThreads: true returns one email per
conversation, for a threaded view.
The filter mirrors JMAP's FilterCondition (RFC 8621 §4.4.1) field for field:
alongside the usual participant/date/size conditions there are
inMailboxOtherThan, hasKeyword / notKeyword, the thread-wide
allInThreadHaveKeyword / someInThreadHaveKeyword / noneInThreadHaveKeyword,
and raw header matching (["List-Id"] for presence, ["List-Id", "rust-lang"]
for a value).
Sorting likewise covers the full comparator set — receivedAt, sentAt, size,
subject, from, to, plus the keyword-based hasKeyword,
allInThreadHaveKeyword and someInThreadHaveKeyword, with collation. The
keyword comparators require a keyword argument and the others reject one;
both are caught before any API call.
Email lists are Relay connections with edges/nodes, pageInfo, totalCount,
position, and queryState.
Cursors are email IDs, mapped onto JMAP's anchor / anchorOffset. This
falls out of what the API already offers, and it's what makes pagination stable:
a positional cursor silently shifts every time mail arrives, so page 2 would
re-show or skip messages. An anchor names a specific message, so the page after
it is the same page whatever else changed. It stays legible for a model
composing the follow-up query too — the cursor is just an ID it has already seen.
{
emails(first: 25, after: "Mabc123") {
totalCount
pageInfo { hasNextPage endCursor }
edges { cursor node { subject } }
}
}
last without before becomes a negative position, which JMAP counts from
the end — "the last N" is one call and never needs a total. last with before
anchors backwards from the cursor.
The trade for stability is that a cursor can go stale: if its message is deleted
or stops matching the filter, JMAP returns anchorNotFound. That surfaces as an
error saying exactly that, and that the fix is to restart pagination. Compare
queryState between pages to detect that the result set moved underneath you.
totalCount maps to JMAP's calculateTotal, which costs the server real work,
so it's only requested when the field is actually selected. The same look-ahead
means a query selecting only totalCount performs one Email/query and
fetches no emails at all:
# "How many unread from this sender?" — one call, zero emails transferred
{ emails(filter: { unread: true, from: "alerts@example.com" }) { totalCount } }
Nothing below a list is fetched eagerly, and every lazy field goes through a DataLoader: the resolvers for a list's elements run concurrently, and their fetches collapse into one batched API call rather than one per element.
Selection on emails(first: 25) { nodes { … } } | JMAP calls |
|---|---|
{ totalCount } alone | 1 (Email/query, no emails fetched) |
{ subject from { email } } | 2 (Email/query + Email/get) |
{ subject textBody } | 3 (+1 batched Email/get for all 25 bodies) |
{ subject textBody attachments { nodes { name } } } | 3 (same batch covers both) |
{ … attachments { nodes { name cid size } } } | 3 (metadata downloads nothing) |
{ … attachments { nodes { base64 } } } | 3 + the blob downloads, issued concurrently |
{ … mailboxes { name } } + mailbox(…) + a name filter | +1 Mailbox/get total, however many ask |
The naive shape — one detail call per email — would be 26. Loader caches are per request, so referencing the same email or mailbox twice in one query costs one fetch; nothing is retained between requests where it could go stale.
Because the graph contains cycles (Email.thread.emails, Email.mailboxes.emails),
nesting is capped at depth 15 — nothing else bounds a cycle. Breadth is not
capped. Resolvers declare a cost (a document parse prices far above a download,
nested lists scale with page size) but that cost is guidance for choosing a page
size, surfaced in the field descriptions; it never refuses a query. Being told
"too complex" without being told the threshold just makes a caller guess.
All operations are available as GraphQL queries and mutations: mailboxes, emails, search, threads, identities (with signatures), attachments (with text extraction and image resizing), contacts, masked email management, and send/reply/forward with the preview/confirm safety pattern.
One subscription, emails, streams arrivals over the same machinery as fastmail watch.
Token can be set via FASTMAIL_API_TOKEN env var or config file.
Enable debug output with RUST_LOG:
RUST_LOG=debug fastmail list mailboxes
This CLI talks directly to Fastmail's JMAP server — the protocol layer is hand-rolled, there's no JMAP client library in the dependency tree. Capabilities are filtered dynamically based on your API token's permissions — read-only tokens work fine for listing/reading, while send and masked email operations require appropriate capabilities.
For more on JMAP: jmap.io
MIT
Loading reviews...
GitHub checked 39h ago - refresh overdue. Recently viewed repositories target hourly refresh.
Find a documented setup for your client. No sign-in, installation, or tool execution.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.