stalwart-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
stalwart-mcp
A remote MCP server for Stalwart mailboxes, running on Cloudflare Workers.
A mailbox user adds the connector's address in an AI tool (Claude and others), signs in with the mailbox login on the mail server's own page, and the tool can then list folders, search, read conversations, write drafts and send mail in that one mailbox. Unless the deployment switches that off, the tool can also read and write that mailbox's contacts and calendar, including events with participants, whom the mail server then invites by email. The worker sits between the AI tool and Stalwart's JMAP API: it is an OAuth server toward the tool and an OAuth client toward Stalwart. The tool never receives a Stalwart token.
You deploy one copy per Stalwart server, in your own Cloudflare account. This is an independent project and not affiliated with Stalwart Labs.
Status: not yet verified against a live server. Every test runs against an in-memory stand-in for Stalwart (
test/fake-stalwart.ts). The list under Live checks is what still has to be confirmed on a real server. Do not connect real users before you have worked through it.
Why it is built this way, and what its security rests on: docs/design.md.
What an AI tool can do
Tool | What it does |
| Folders with role and message counts, and the address of the connected mailbox |
| Search by text, sender, recipient, subject, date, folder, unread, attachment |
| A whole conversation as plain text |
| Save a new mail or a reply in Drafts |
| Send a new mail or a reply, plain text, from the mailbox's own address |
| Move messages into another folder of the mailbox |
| Move messages to the Trash folder |
| Search the address book by text, name, email, phone, organization or address book (needs |
| One contact: names, emails, phones, organizations, addresses, birthday, notes (needs |
| The mailbox's calendars with id, name and whether they are writable (needs |
| Events that overlap a time window of at most 180 days, one entry per occurrence of a recurring event (needs |
| One event: time, locations, description, participants, meeting links, recurrence (needs |
| Create a contact: names, up to 10 emails and 10 phones, organization, job title, notes, birthday (needs |
| Change a contact; a given field replaces the stored one (needs |
| Delete up to 50 contacts for good (needs |
| Create an event: timed or all-day, location, description, up to 10 participants, a recurrence rule; participants get an invitation by email (needs |
| Change an event or one occurrence; participants get an update by email (needs |
| Delete up to 50 events or occurrences for good; participants of the mailbox's own events get a cancellation by email (needs |
The contacts and calendar tools exist unless the deployment switches their area off with
DISABLED_FEATURES
(see Contacts and calendars). Deleting a contact or an event is
permanent: JMAP has no trash for them. An event write that involves participants makes the mail
server send them mail (invitations, updates, cancellations), and each such write counts as one
of the mailbox's 50 sends per day (one per started ten addresses). The connector never answers
an invitation: a change or deletion of a meeting someone else organized only touches the
mailbox's own copy.
It cannot remove mail for good, flag mail, manage folders, touch filters, or send from another
address. Deleting always means moving to Trash, and move_mail brings a message back. The
connector never empties the Trash; whether the mail server does is its own setting (see Known
limits).
Related MCP server: agent-jmap-mcp
Sign-in flow
The AI tool registers itself and sends the user's browser to
/authorizeon this worker.The worker shows its own intro page: what is about to happen, on which server the sign-in takes place and which login is meant. Its one link leads to Stalwart's sign-in page (PKCE, bound to the browser by a cookie). The page has no form: a password is only ever typed at Stalwart.
The user signs in at Stalwart and confirms its consent screen.
Stalwart returns to
/callback. The worker exchanges the code, reads the mailbox identity from Stalwart (never from the tool), stores the Stalwart tokens encrypted in that mailbox's vault, and shows its own page: "Connect mailbox<address>to<tool>?"On Allow the worker gives the AI tool its own access and refresh token. On Deny the tool gets nothing.
Limits
Constants live in MAIL_LIMITS in src/mail.ts and, for contacts and calendars,
COLLAB_LIMITS in src/collab.ts.
What | Value |
Tool calls per mailbox (mail, contacts and calendar calls together) | 60 per minute |
Messages sent per mailbox ( | 50 per day |
Recipients per message (To, Cc, Bcc together) | 10 |
Messages per | 50 |
Identical send (or identical notifying | 10 minutes (600 s) |
Parallel calls to Stalwart per mailbox | 2 |
Search results per page | at most 25 (default 10) |
Messages returned per thread | at most 25 |
Contacts per | at most 25 (default 10) |
Events per | at most 50 (default 25) |
Window of | at most 180 days |
| 0 to 10,000 |
Ids per | 50 (no daily limit on deleting; deleting is permanent) |
Emails and phones one contact input may carry | 10 each, a phone number 50 characters |
Participants of | 10 |
Longest timed event ( | 31 days / 366 days |
Recurrence rule |
|
Text of a name, title, label, location, participant or other single line | 200 characters |
Postal address of a contact | 500 characters |
Contact notes | 2,000 characters, then |
Event description | 5,000 characters, then |
Emails and phones in a contact summary | 5 each |
Emails, phones, addresses, titles, nicknames, organizations in a contact | 20 each |
Locations, online meeting links, participants of an event | 5, 3 (http and https only), 50 (the rest counted in |
Body text returned per message | 20,000 characters, then cut with a marker |
Body text accepted when writing | 100,000 characters |
Worker access token lifetime | 1 hour |
Worker refresh token | ends after 30 days without use |
Unused Stalwart connection | wiped after 30 days without a tool call |
Abandoned or denied sign-in | cleaned up within 10 minutes |
Connection whose AI tool never redeemed its code | cleaned up within 24 hours |
Application removed at Stalwart | noticed at the next tool call (the tool's grant then ends), otherwise after 30 idle days |
Audit rows are kept | 90 days |
Deploying your own
You need a Stalwart server with its OAuth server and JMAP reachable over public HTTPS, admin access to it, a Cloudflare account, and Bun.
Addresses. In
wrangler.jsoncchangeroutesand thevarsblock:STALWART_ORIGIN: your Stalwart server as an https origin, written the plain way: lower case, no path, no:443(https://mail.example.com).PUBLIC_ORIGIN: the address the connector is served under, written the same way. It must matchroutes; the worker answers under no other host.CONNECTOR_NAME: the name AI tools show (optional, default "Stalwart Mail").STALWART_OAUTH_CLIENT_ID: the id of the OAuth client from step 2. It is not a secret.DATA_JURISDICTION: optional; decide before the first sign-in (see Where the data lives).
OAuth client on Stalwart: confidential, grant types authorization code and refresh, scopes mail, contacts and calendars (without the scope of an area you switch off, see Contacts and calendars), exactly one redirect URI
<PUBLIC_ORIGIN>/callback.Storage. Create the KV namespace and the D1 database once and put their ids into
wrangler.jsonc(they are not secrets):bunx wrangler kv namespace create stalwart-mcp-oauthandbunx wrangler d1 create stalwart-mcp. If the data has to stay in a region, add--jurisdiction euto both now; it cannot be added later (see "Where the data lives"). Then apply the migration:bun run migrate.Connect the repository (Cloudflare dashboard, Workers & Pages, import a repository): worker name
stalwart-mcp(thenameinwrangler.jsonc), deploy commandbun run deploy. From then on every push to the connected branch deploys; nothing is uploaded by hand.Secrets (in the dashboard, or
bunx wrangler secret put <NAME>):STALWART_OAUTH_CLIENT_SECRET: the client secret from step 2.TOKEN_ENC_KEY: 32 random bytes, base64 (openssl rand -base64 32). Changing it later makes every stored mailbox token unreadable: every mailbox is disconnected.
Dashboard variable, optional (kept across deploys by
keep_vars):DISABLED_FEATURES, see Contacts and calendars.Until the client id and both secrets are set, every endpoint answers 503, with
config_error <setting>in the worker's logs. A freshly created worker therefore serves nothing, and it opens by itself once the second secret is in place.Check that the Durable Object migration
v1was applied (theMailboxVaultclass exists with SQLite storage), then work through the live checks below with a test mailbox.
Trying it first
Few people run a second mail server, so a trial usually talks to the real one. For that, set
ENVIRONMENT to staging, for example in a second worker with its own name, storage and OAuth
client. A staging deployment answers under the origin of the request (its workers.dev
address will do) and needs no PUBLIC_ORIGIN, and it obeys two more dashboard variables:
SIGNIN_ALLOWLIST: comma-separated mailbox addresses that may connect.SEND_ALLOWLIST: comma-separated addresses mail may go to. This coverssend_mailand the participants of every event write that makes the mail server notify.
Both lists are enforced in code. If a list is empty, nobody can connect and nothing is sent. This is what makes it safe to point a trial at your one, real mail server. In production both lists are ignored.
Contacts and calendars
Mail is always offered, and so are contacts and calendars unless you switch them off with the
dashboard variable DISABLED_FEATURES: contacts, calendars or contacts,calendars (spaces
are ignored; empty or unset switches nothing off). Any other name, mail included, closes the
worker with 503 and config_error DISABLED_FEATURES in its logs, so a typo never quietly asks
Stalwart for more than you meant. An area that is off has no tools, is not asked of Stalwart
and is not named on the approval page.
Scopes. Each area that is on makes the worker ask Stalwart for one more scope at sign-in:
urn:ietf:params:oauth:scope:contactsandurn:ietf:params:oauth:scope:calendars(STALWART.scopeinsrc/stalwart/endpoints.ts). The OAuth client on Stalwart has to be allowed to grant them. The approval page names each area, so the user knows what the tool gets.After switching an area back on, connected mailboxes must connect again. Their Stalwart token was issued without that scope. Until then the new tools answer with the fixed message "This connection does not include that permission. Remove the connector in your AI tool and connect the mailbox again." (
not_granted, audited asrefused), and send nothing to Stalwart. Mail keeps working.Reach of the token. As with mail, which also opens IMAP and SMTP, the scopes are Stalwart's, not the connector's: according to Stalwart's documentation a vault token with the contacts or calendars scope also reaches CardDAV and CalDAV for that account. The connector sends JMAP
/getand/query, and/setofContactCardandCalendarEventonly; the tests assert that no request contains another/set, a/copyor a/parsemethod, and that the read tools send no/setat all.Writing.
create_*,update_*anddelete_*write into the mailbox's own address books and calendars (the default one unless an id of the account is given). An update replaces each given field as a whole and leaves the others. Deleting is permanent: there is no trash for contacts and events, and the tool descriptions and the approval page say so. Up to 50 ids per delete call, no daily limit on deleting. A create whose outcome is unknown (timeout, network error, 5xx) is never retried: it answers a temporary error (or, when it would notify people,send_unconfirmed), and the tool description says to look before creating again. Single-line text (names, title, location, organization, job title, phone number) may carry no control, line or paragraph separator or bidi control character;notesanddescriptionmay also carry line breaks and tabs.Invitations are mail. An event with participants is created with the mailbox as organizer, and the request asks the mail server to schedule (
sendSchedulingMessages: true): Stalwart itself then sends invitations, updates and cancellations (iTIP) by email from the mailbox. The connector decides per write whether it notifies: a create with participants, an update of an event that has attendees before or after it, a deletion of an event with attendees, each only when the event does not end in the past (a recurring event never counts as past; when unsure, it counts as notifying). Every other write asks the server not to schedule. A notifying write counts as one send against the mailbox's 50 per day, shared withsend_mail, or one per started ten addresses when it involves more than 10 (an existing event created elsewhere); if that many are not left, it is refused withsend_limit_reachedand nothing is written (a deletion of several such events needs the sum, or nothing is deleted). A notifying create or update is deduplicated like a send (the same request within 10 minutes returns the first result and sends nothing). An unknown outcome of a notifying create, update or delete (no readable answer, or an answer that names the event nowhere) issend_unconfirmed: the sends stay counted and, for a create or update, the same request is blocked for the window. Outside production only addresses onSEND_ALLOWLISTmay be notified, checked for every address involved before anything is written, also for an existing event's attendees when it is changed or deleted. The connector's event writes of one mailbox run one after the other, so none of them can change an event between another's check and its write. Audit rows of the event writes carry how many addresses were notified (recipient_count), never an address.Someone else's meetings. The mailbox organizes an event when its organizer (
organizerCalendarAddress) is the mailbox's own address (any case, withoutmailto:) or it has none. For an event organized by someone else,update_eventwithparticipantsorrecurrenceis refused (invalid_input, nothing written); any other change and a deletion only affect the mailbox's own copy: written withsendSchedulingMessages: false, no send counted,invitations: 0/cancellations: 0, and the organizer is not informed.Replacing participants.
participantsinupdate_eventreplaces the list; an attendee whose address is already on the event keeps the answer it gave (participationStatus) and its name when the input gives none. Only new addresses start asneeds-action, asked to reply.Property names. Stalwart 1.x implements the newer JSCalendar names and silently stores any unknown property as inert data, so a wrong name never fails, it just does nothing. The connector writes
calendarAddress(mailto:URI) for participants,organizerCalendarAddress, onerecurrenceRuleobject (withbyDayentries{ "@type": "NDay", "day": "mo" }anduntilas the end of that day in the event's zone), and neveruid(the server makes one),isOrigin,sendTo,replyToorrecurrenceRules. When reading it still acceptsrecurrenceRules, a participant'semailandsendTo.imipas fallbacks.Event time. A timed event is stored as the wall-clock
startof the input instant in itstime_zoneand adurationwhose days are wall-clock days in that zone and whose rest is exact time (so an event across a daylight-saving change ends at the given instant). Withouttime_zone,create_eventusesEtc/UTC;update_eventkeeps the event's stored zone (so a weekly Europe/Berlin meeting stays at its local time after the next daylight-saving change), and only an event without one (floating) getsEtc/UTC.time_zonemust be an IANA name (Area/Location, orUTC); offsets and abbreviations (+01:00,GMT,EST) are refused, and the canonical spelling is written (europe/berlinbecomesEurope/Berlin,UTCbecomesEtc/UTC). A wall-clock time that occurs twice (when the clocks go back) means its first occurrence, as RFC 5545 and RFC 8984 say. Timed events take years 1000 to 9999. An all-day event is a floatingstartat midnight withP<days>DandshowWithoutTime: true. An occurrence id (assearch_eventslists it) changes or deletes that occurrence only.What the tools return. Every result leads with a fixed
content_noticesaying that names, titles, descriptions, notes, locations and addresses may come from third parties (for example the sender of an invitation) and are data, not instructions. Text is stripped of control and bidi characters and capped; an HTML description is reduced to text; a meeting link is kept only when it is an http or https URL.Times.
search_eventstakesafterandbeforeas ISO date-times with an offset, converts them to UTC and sends them to Stalwart as local times inEtc/UTC.startandendin the results are the server'sutcStartandutcEnd;local_startandtime_zoneare the event's own. All-day events carryall_day: true. The recurrence summary ofread_eventis built from the first rule's own fields only (for exampleweekly, every 2, until 2027-01-01); the tool does not expand rules itself, the server does (expandRecurrences).
Branding
The pages a user sees in the browser (the approval page and its error pages) take their look
from src/oauth/theme.ts and the files in public/brand/: wordmark, colours, two fonts, an
icon and the artwork on the right half of wide screens. Both carry exciting IT's branding as
shipped; change the values and replace the files for your own deployment. The fonts are under
the SIL Open Font License (texts next to the files). The pages run no script and load nothing
from another origin, which their Content-Security-Policy enforces.
The same mark is there as a PNG (public/brand/icon.png) and as public/favicon.ico. The
server names the PNG as the connector's icon to AI tools, and its address
(<PUBLIC_ORIGIN>/brand/icon.png) can be entered as the logo of the OAuth client at Stalwart.
Whether a tool shows an icon, and which one, is up to that tool. In the same way the server's
title carries the mailbox address (" ()"), so a tool that shows it
can tell two connected mailboxes apart.
The sign-in page itself is Stalwart's own and is not part of this worker.
Where the data lives
Three stores hold data, and each is pinned to a region in its own way. Decide before the first sign-in; none of them can be changed afterwards without losing what is stored.
Store | Holds | How to restrict it |
Mailbox vaults (Durable Objects) | Encrypted Stalwart tokens, limits, recent sends |
|
D1 database | Audit log, block list, pending approvals |
|
KV namespace | The AI tools' grants and registrations |
|
Vault ids depend on DATA_JURISDICTION, so changing it later orphans every stored connection:
users have to sign in again, and when an orphaned vault expires (30 idle days) it also ends
that mailbox's current grants. A value Cloudflare does not offer
closes the worker (503, config_error DATA_JURISDICTION) instead of running unrestricted.
The local runtime does not implement jurisdictions: wrangler dev and the tests only work
without DATA_JURISDICTION. The tests cover that the vault is looked up through the restricted
namespace; that it really stays there is one of the live checks.
Live checks before real users
These need the OAuth client and a test mailbox on your server:
With
DATA_JURISDICTIONset: sign-in and a tool call work on the deployed worker (the local runtime cannot run this).One grant per account and client; how a second authorization affects the first refresh token.
Whether a rejected Bearer token counts toward Stalwart's address ban.
The JMAP session under the
mailscope includes submission, andEmailSubmission/setwith the identity fromIdentity/getdelivers.Stalwart's sign-in page accepts TOTP and passkeys in this flow.
End to end with an AI tool's custom connector: registration, sign-in, token refresh.
Stalwart returns a refresh token for the mail scope alone. Its documentation says it always does. If not, add
offline_accesstoSTALWART.scopeinsrc/stalwart/endpoints.ts.The callback carries
iss=<STALWART_ORIGIN>(the worker refuses a callback without it).A removed application answers the refresh with
error: "invalid_grant". With a bare 401 instead, the connection is only cleared by the 30-day idle alarm.expires_inin the token response is a number.Bcc recipients are not visible to the To and Cc recipients of a sent message.
move_mailanddelete_mailagainst the real server: a moved message is in the target folder only; a foreign or malformed id is reported as not found.Whether the server empties Trash on its own (Stalwart's auto-expunge), and whether that is what you want now that an AI tool can move mail there.
Whether Stalwart ever reuses an account id (a reused id would meet the old vault).
Remove the application and reconnect with two AI tools: do the earlier tools regain access (see "Known limits")?
How long an issued Stalwart access token keeps working after the application is removed, and after the OAuth client is deleted.
For contacts and calendars (unless both are switched off), also these (the tests cannot tell, because the stand-in is written from the same assumptions as the code):
Stalwart accepts the two extra scope names at sign-in (
urn:ietf:params:oauth:scope:contacts,urn:ietf:params:oauth:scope:calendars), its consent page names them, and the OAuth client is allowed to grant them. Until this passes on staging, leaveFEATURESout of production: a scope the client may not grant fails every sign-in, mail included.A token without the contacts or calendars scope gets a session that does not list that capability (the connector's permission check rests on this).
The JMAP session lists
urn:ietf:params:jmap:contactsandurn:ietf:params:jmap:calendarsas capabilities, and the keys ofprimaryAccountsfor them are those same URNs. The connector reads the capabilities of the token fromprimaryAccounts; a different key means the tools answernot_grantedalthough the scope was granted.A token with only the mail scope really gets none of the two URNs, and its contacts or calendar methods answer
unknownMethod.Which draft revision of JMAP Calendars the server implements, and that
Calendar/getaccepts the properties asked for (id,name,description,color,isDefault,timeZone,myRights) and answersmyRightswithmayWriteAllormayWriteOwn.CalendarEvent/queryacceptsexpandRecurrences: truewithtimeZone: "Etc/UTC", a single filter condition withafterandbeforeas local times without offset, and the filter keyinCalendar(singular). Check that a daily or weekly series gives one id per occurrence, and that the occurrence ids contain only letters, digits,-and_(the tools refuse other ids as input, and an id that fails this makes the search answer a fixed error).CalendarEvent/getreturnsutcStartandutcEndwhen asked for, andread_eventon an occurrence id returns that occurrence (ownstart,recurrenceId, no rules). Asking forutcStarttogether withrecurrenceOverridesis refused by the server, which is why the connector never asks forrecurrenceOverrides.Events in a time zone with a daylight-saving change, all-day events (
showWithoutTime), and events spanning midnight:start,endand the overlap with the window are right.ContactCard/queryaccepts the filter keystext,name,email,phone,organizationandinAddressBook, rejects other keys withunsupportedFilter, and how its string filters match (substring or prefix; the tool description does not promise either).AddressBook/getandCalendar/getwith an id of another account answer a not-found, so a foreignaddress_book_idorcalendar_idgives an empty page.The Stalwart access token of a contacts or calendars grant: how long it keeps working after the application is removed (as for mail above), and that CardDAV and CalDAV accept it.
Contact writes:
ContactCard/setaccepts a client-supplieduid; an update replacing a whole property (a PatchObject with a top-level key) works as assumed; how the default address book and calendar are marked (isDefault).An invitation actually arrives at an allow-listed address and names the mailbox as organizer; an update and a cancellation arrive too.
An attendee on the same Stalwart server is notified (delivered internally, not only by SMTP).
The server does not notify for an event that ended in the past, nor for a write sent with
sendSchedulingMessages: falseon an event with participants.recurrenceRule(withbyDay,count,until) is stored and expanded byCalendarEvent/query;untilwritten as<date>T23:59:59includes that day.The nominal-day
durationthe connector writes (for exampleP2DT1H) ends where intended across a daylight-saving change.Deleting an occurrence id adds an excluded override and leaves the series; changing one changes only that occurrence.
What the server does when it cannot send an invitation:
noSupportedScheduleMethods(the tool answers a fixed refusal), or saving the event silently without sending.An update or a deletion of an event the mailbox was invited to (organized by someone else), which the connector sends with
sendSchedulingMessages: false: the server sends nothing to the organizer or the other attendees, and changes only the mailbox's copy.
Repeat them after a Stalwart upgrade.
Runbook
Block one mailbox. In the D1 database (stalwart-mcp):
INSERT INTO blocked_accounts (key, reason, created_at)
VALUES ('<account id or lower-case address>', '<short reason>', <unix seconds>);key is the Stalwart account id or the address in lower case. To find the account id of an
address, look in the audit log:
SELECT DISTINCT account_id FROM audit_log WHERE lower(email) = lower('<address>');
A blocked mailbox cannot sign in and every tool call is refused.
Unblock. DELETE FROM blocked_accounts WHERE key = '<the same key>';
End all access at once. There is no switch for it; pick by how final it should be:
Stop serving, keep the connections: remove the custom domain from the worker in the Cloudflare dashboard (Settings, Domains & Routes). No request reaches the worker; nothing stored changes. The next deploy puts the domain back, so pause the build connection too.
Cut every mailbox off: replace
TOKEN_ENC_KEY. Every stored mailbox token becomes unreadable, so every tool call fails until the user connects the mailbox again. This cannot be undone.
Deleting the OAuth client on Stalwart does not clear connections or worker grants: a
deleted client answers invalid_client, which the worker deliberately does not treat as a dead
mailbox grant (otherwise one wrong secret would wipe every mailbox). Tool calls then fail with
a temporary error until the client exists again.
A user disconnects. Any one of: remove the connector in the AI tool; remove the application under Connected Applications in their Stalwart account; change the mailbox password.
Where to look when something fails. Table audit_log in D1. Columns: at (unix seconds),
event, account_id, email, client_id, client_name, tool, outcome (ok, refused,
error), error_code, result_count, recipient_count, message_id. Events: sign_in,
sign_in_refused, approval_allowed, approval_denied, tool_call, upstream_revoked,
connection_wiped. The log never holds subjects, bodies, search terms or recipient addresses.
The worker's console output holds only fixed markers such as oauth_error <code> and
config_error <setting>. Invocation logs are switched off in wrangler.jsonc, because they
record request URLs, and /callback?code=…&state=… and /approve?h=… carry codes and handles.
Everything answers 503. Look for config_error <setting> in the worker's logs:
STALWART_ORIGIN or PUBLIC_ORIGIN is missing or not an https origin, DATA_JURISDICTION is
not one of Cloudflare's, DISABLED_FEATURES names something unknown, or
STALWART_OAUTH_CLIENT_ID, STALWART_OAUTH_CLIENT_SECRET or TOKEN_ENC_KEY is not set. In
production a request under a host other than PUBLIC_ORIGIN answers 404.
Known limits
Stalwart's
mailscope also covers IMAP, SMTP submission and ManageSieve and cannot be narrowed to JMAP. Anyone who took over this worker and its secrets could act as every connected mailbox. Mitigations: two secrets per deployment, replacingTOKEN_ENC_KEY, and deleting the OAuth client.Contacts and calendars cover the mailbox's own account: no shared address books or calendars of other accounts, no free/busy lookups, no answering invitations. Deleting a contact or an event cannot be undone. An event update with
participantsreplaces the whole list (kept attendees keep their answers) and is refused for a meeting someone else organized; a contact update rebuilds the name from the parts given. A recurring event is expanded by the server for the requested window only;search_eventspages byoffset, so a change between two pages can shift the entries.A send whose outcome is unknown (a timeout, a network failure or a 5xx on the submit request) answers
send_unconfirmed("Check the Sent folder before sending this message again."). It counts toward the daily limit, and an identical message cannot be sent again for 10 minutes; a different message can. The vault never retries it on its own.A connection the user removed at Stalwart is noticed at its next tool call, which also ends that tool's grant; the daily alarm checks only worker grants and idle time and never asks Stalwart.
After a user removes the application at Stalwart and later connects one AI tool again, the earlier tools' grants for the same mailbox work again, without appearing on the approval page.
delete_mailmoves messages to Trash and the connector never empties it. Whether Trash is emptied after some time is your server's setting (Stalwart's auto-expunge), not the connector's: with it switched on, a deleted message does disappear later.A contacts or calendar tool that answers "This connection does not include that permission" right after a fresh connect does not need another reconnect: the server either does not list the capability for that token or does not implement the method (for example another draft of JMAP for Calendars). The connector cannot tell these apart from a connection made while the area was switched off.
The tool-call limit counts per clock minute, not a sliding minute: up to 120 calls can land within a few seconds around a minute boundary.
/tokenand/registerare limited per source address. AI vendors call them from shared addresses, so many users of one vendor share that limit.Stalwart sees every connected mailbox from Cloudflare's shared egress addresses. If Stalwart bans such an address, the connector stops for everyone until the ban ends.
Development
bun install
bun run test # all tests, in the Workers runtime (real KV, D1 and Durable Objects)
bun run typecheck
bun run lint
bun run depgraph # no circular imports
bun run check:brand # every file the browser pages reference exists in public/Use bun run test, never bun test (Bun's own runner ignores the Vitest setup). Nothing in the
tests contacts a real server: fetch is replaced by the stand-in in test/fake-stalwart.ts.
The end-to-end isolation test is test/isolation.e2e.test.ts; flows are driven by the helpers
in test/oauth-flow.ts.
After an upgrade of @modelcontextprotocol/sdk, re-run test/mcp-handler.test.ts: the way the
advertised tool schemas are built depends on SDK internals. The SDK and
@cloudflare/workers-oauth-provider are security dependencies and pinned to exact versions.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Private, EU-hosted email for AI agents over JMAP: read, search, reply, draft, organize, send.
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Email, calendar and contacts for AI agents: Gmail, Microsoft 365 and IMAP accounts behind one API.
Give AI agents secure access to your email via private aliases with dedicated mailbox storage.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to read, send, and manage emails, calendars, and contacts in a Fastmail account via the JMAP protocol.4738 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to manage email over JMAP, including inspecting mailboxes, searching and retrieving messages, navigating threads, downloading attachments, triaging inboxes, and sending emails atomically via HTTP.23 PyPIMIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to read, search, send, draft, reply to, and organize email, manage contacts, and handle calendar events through the JMAP and CalDAV APIs. It also supports attachments, bulk operations, mailbox/label management, and account statistics.-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to access and manage email, contacts, and calendar data over JMAP/CalDAV/WebDAV, including searching, sending, threading, attachments, contacts, events, and mailbox operations.MIT