Getting started
This page walks from an installed MailFathom to a first successful tool call: provision the credentials, write the mailbox down, start the service, verify it, record the person it serves and their mailbox, connect an MCP client, and read a result correctly. It assumes an installation from installing MailFathom; a developer evaluating from the checkout can run the Aspire orchestration instead, which provisions PostgreSQL and applies the schema on its own.
Somebody evaluating MailFathom on the Compose shape can have steps 1 to 5 and 7 performed for them, and the
mfctl commands of step 6 printed.
scripts/quick-start-compose.sh asks the same questions this page does, writes the same values, prints the mfctl
commands of step 6 — recording the user a deployment serves is yours, so it leaves that step to you — and ends by
printing the two a client needs in step 8 — plus an address the MailFathom client answers on
and a generated username and password to sign in to it with, which it provisions for you. Trying it first, with one
command is that path, including what a deployment
it prepares is missing before anybody depends on it. Read this page anyway, for what each answer means.
The examples write configuration as JSON. Every setting can arrive as an environment variable instead — : becomes
__, so MailSynchronization:Enabled is MailSynchronization__Enabled — and the
configuration reference maps every key used below to the page that
states it.
1. Provision the secrets
MailFathom's configuration never carries a credential. A secret-bearing setting holds a reference — file:/…,
systemd-credential:…, env:… — and the material lives wherever the deployment provisions it. A configuration file
is therefore safe to review and back up: leaking it leaks paths, not passwords.
You need one piece of material before anything is configured:
- The mailbox password or app password of the IMAP account to synchronize. A mailbox whose provider no longer
accepts one — a Google Workspace or Exchange Online account — is authenticated with an OAuth refresh token instead;
obtain it first with mailbox OAuth and substitute that block for the password
below. That account needs a second piece of material as well, the data-encryption key the rotated refresh token is
sealed under:
openssl rand -base64 32, generated once and never regenerated, provisioned as a reference like everything else here. The data-encryption key is the whole of it.
There is deliberately no MCP key to provision here. What a client presents to that endpoint belongs to the person whose mail it reaches rather than to the deployment, so the running service mints it in step 7 and nothing on this machine holds it beforehand.
Where the files go is the deployment's convention: secrets/mailfathom/ for
Compose, a Kubernetes Secret mounted at
/etc/mailfathom/secrets for the chart, LoadCredential=
for systemd, and an encrypted credential under
~/.config/credstore.encrypted/ for the Quadlet. The references
below assume the mounted directory the Compose and Helm shapes share.
2. Write down the mailbox
Synchronization is off until configuration turns it on, and turning it on is the whole of what a deployment's own file says about mail:
{
"MailSynchronization": { "Enabled": true }
}
The mailbox itself is not configuration. Every mail account is a record the deployment holds and assigns to the
people it serves, written while the deployment runs rather than read from a file — so a fresh deployment holds nobody,
reads no mail, and says so at startup.
Step 6 is where this mailbox is recorded, and it is served from that moment
without a restart. What to write now is the account's own JSON object, saved as mailbox.json on the machine you
administer the deployment from:
{
"EmailAddress": "you@example.test",
"DisplayName": "Personal mail",
"Language": "English",
"Host": "imap.example.test",
"Port": 993,
"UserName": "you@example.test",
"Secrets": {
"Password": {
"Name": "imap-primary-password",
"SecretReference": "file:/etc/mailfathom/secrets/imap-primary-password"
}
},
"Folders": [
{ "Alias": "inbox", "SpecialUse": "Inbox" },
{ "Alias": "sent", "SpecialUse": "Sent" }
]
}
The reference is resolved by the deployment rather than by the machine this file sits on, so the path it names is the one the service reads — the mounted directory of step 1, not a path on your workstation.
What goes in Host, Port, and Secrets depends on where the mailbox lives, and so does whether IMAP has to be
switched on first and whether a password is accepted at all. Configuring a mailbox at your
provider has the address and the credential kind for the popular mail services, and what each
one does differently once synchronization is running.
Points worth knowing before you adapt it:
EmailAddressis the mailbox's own address. It is what tells this account apart from every other one the deployment holds: one address is one account, however many people it is assigned to. There is noAccountIdto write — the deployment generates one when the account is created and reports it.Aliasis your name for a folder, not the server's. It is what every tool argument, log line, and error message uses, so pick names you are happy to see in a diagnostic.DisplayNameis the name an assistant reads back to you. It is required and has no default: the generated identifier is a key, and a person hearing "the email came from5b0c…" learns nothing. It travels beside the identifier in every tool result, and either spelling narrows a listing, a search, or a question to that mailbox. No two of your accounts may share one, so a name always names one mailbox; it is compared against your own accounts and against nobody else's.- Folders are best named by role.
SpecialUselets discovery find the folder whatever the server calls it — a German server'sGesendetis stillSent— and configuring no folder at all synchronizes the inbox. Naming an exact server path is the alternative for folders with no role, and you may name both: the path finds the folder and the role says what it is for, so a rule or a tool can go on asking forrole:Junkon a server that advertises nothing. One role belongs to one folder per account. What a role says, beside how a folder is found states what naming a role buys you everywhere else. - A folder left out of the list is a folder MailFathom does not have. The list is not a filter over your mailbox; it is the whole of what this deployment knows about. A folder no entry names is never mirrored, never listed, searched, read, or answered from, never embedded, and never evaluated by a rule — and so is mail an earlier configuration had already stored under an entry you later removed, which stays in the database and stops being reachable. Working out the list below is how to arrive at one you meant.
- A mapped folder is mirrored, embedded, and readable by tools unless you say otherwise.
Synchronize,GenerateEmbeddings, andVisibleToToolseach default totrueon a folder entry, and switching one off is how a folder stays nameable while its mail stays out of the local copy, out of an embedding provider, or out of everything an assistant can read. Mail the folder had already stored is kept when you turn mirroring off, withheld from everything that reads a mailbox, so turning it back on later fetches what arrived meanwhile rather than the whole folder again. What a mapping decides beyond where the folder is states what each one costs, including what happens to mail already stored when you turn mirroring off. - A folder you name is created only if you ask for it. Add
CreateIfMissing: truebeside aRemotePathand MailFathom creates that folder on its first run, when your server has none at it — which is what a rule filing mail into an archive folder you decided on needs, without a detour through a mail client. A mapping that also carriesSynchronize: falsegets its folder the first time something files mail into it. The switch defaults tofalse, so leaving it out keeps a mistyped path reporting itself as an alias that resolves to nothing rather than becoming a folder named after the typo. Nothing a run does changes anything else about your folders: synchronization never renames, deletes, or unsubscribes from one. What does is you, asking for it in the client — creating, renaming, moving, and deleting a folder is one surface there whatever holds the mailbox, and on a mirrored account each act runs on your own server. A folder the mapping asked for is created states when it happens and what a server's refusal reports. - The transport is TLS by default. Port 993 with TLS-on-connect is the default posture, and every weakening — an unencrypted connection, clear-text authentication over one — must be stated explicitly and fails startup otherwise. A server with a private certificate authority is supported by trusting that authority, never by turning validation off; transport security records the rules.
- An older server may be refused before any of this applies. If synchronization reports an authentication failure
wrapping
SSL Handshake failed with OpenSSL error, the password is not the problem: the platform's own TLS policy ended the handshake before a credential was sent. The platform TLS policy covers how to confirm that and the one supported way to relax it. - How far back to synchronize is per account:
EarliestEmailReceivedDatebounds the first synchronization of a large mailbox, and omitting it copies everything the server still holds. - New mail arrives on the next run unless you ask for push. The default reconciles each account every five minutes.
Setting an account's
"Mode": "Push"makes MailFathom hold an IMAP connection open and synchronize the moment the server reports a change. What that costs depends on the server: one connection for the whole account where it supports theNOTIFYextension, one per watched folder where it supports onlyIDLE, and nothing at all where it supports neither — which is polled instead and says so in the log. Push adds to the schedule rather than replacing it — the account still runs on itsInterval, and a notification only starts the next run sooner. Push synchronization records the whole model.
Working out the list
Nothing discovers folders into that list for you, so writing it is a step of its own. From an empty configuration:
- Look at what the server actually holds. Any mail client you already use lists the account's folders, and the paths
it shows are the paths
RemotePathtakes — including their separator, which is/on some servers and.on others. Configuring a mailbox at your provider names the folders the popular services create and which of them carry a role, so a Gmail account is a different starting list from a Fastmail one. - Name by role whatever carries one.
Inbox,Sent,Drafts,Junk,Trash,Archive,All,Flagged, andImportantare the roles a server can advertise; a mapping that names one finds the folder whatever it is called and keeps working when the localization or the path changes. Each role belongs to one folder per account. - Name the rest by path. A project folder, a mailing-list folder, a folder a filter on the server files into —
none of these carries a role, so each takes a
RemotePathand an alias of your own. - Create the folder that is not there yet. A folder you want a rule to file into — an archive of your own, say —
does not have to be made in a mail client first: give the mapping its
RemotePathandCreateIfMissing: true, and MailFathom creates it on the first run that resolves the alias. It is the only thing MailFathom ever changes about your mailbox's shape. - Leave out what you do not want mirrored. Leaving a folder out is the way to keep its mail out of MailFathom entirely, and it stays out until an entry names it.
The account's Folders then grows from the two entries above into the list you meant, mixing the three kinds of entry:
{
"Folders": [
{ "Alias": "inbox", "SpecialUse": "Inbox" },
{ "Alias": "sent", "SpecialUse": "Sent" },
{ "Alias": "spam", "RemotePath": "INBOX.Spam", "SpecialUse": "Junk" },
{ "Alias": "projects", "RemotePath": "INBOX.Work.Projects" },
{ "Alias": "archive", "RemotePath": "INBOX.Archive", "SpecialUse": "Archive", "CreateIfMissing": true }
]
}
Once the service is running, list_accounts reports one entry per folder this deployment mapped and lets tools read,
with when each last synchronized — so a mistyped path shows up as a folder missing from that answer rather than as one
holding no mail. The log names an alias that resolved to nothing or to more than one folder, in both cases naming the
remedy.
MailSynchronization:Enabled above is what a deployment reads from its own file — config/10-mailfathom.json for
Compose, a ConfigMap key for Kubernetes, a file named through
ConfigurationSources for a native process. mailbox.json is read by nothing
until step 6 hands it over: no configuration source names it, and none declares a mail account at all.
3. Point it at the database
The Compose deployment wires the connection and its password for you — skip this step there. Elsewhere, the connection string carries everything but the password, and the password joins it through a reference:
{
"ConnectionStrings": { "mailfathom": "Host=db.example.test;Database=mailfathom;Username=mailfathom" },
"Persistence": {
"Password": {
"Name": "mailfathom-database-password",
"SecretReference": "file:/etc/mailfathom/secrets/mailfathom-database-password"
}
}
}
4. Start it, and apply the schema
Start the service the way the installation shape does. The first start against an empty database fails on purpose, naming the migration it expects:
The database has not applied 1 migration(s) this build defines: 20260731132336_Initial.
That is the explicit schema step described in installing MailFathom: MailFathom verifies the schema and refuses to serve against one it does not recognize, and applying migrations is a step you take, with a backup first once there is data to lose.
What you apply is one SQL file. A release attaches it; from a checkout, generate it:
scripts/build-schema-artifact.sh # artifacts/schema/mailfathom-schema-<version>.sql
Read it, apply it with any PostgreSQL client, and start again — the refusal is gone. The role that applies it needs more privilege than the one MailFathom connects as, which applying the database schema explains along with the grants that leaves behind.
5. Verify it is healthy
curl -fsS http://127.0.0.1:8081/started
curl -fsS http://127.0.0.1:8081/health
/started confirms the startup gates passed — every secret reference resolved, the schema matched. /health is
readiness and includes the database. Both answer on the probe listener, 8081 by default, never on the application
port; health endpoints explains that separation.
Then let the first synchronization run. Its progress is visible in the log — each folder run reports what it stored —
and, once you can call a tool, in the folderFreshness every result carries. A large mailbox takes a while on the
first pass; later runs move only what changed, every five minutes by default.
6. Record the mailbox
A fresh deployment serves no user: the one user its first start records is the default administrator, kept off both
mail endpoints. So the deployment started above serves nobody and reads no mail yet, and said so at
startup — in a line naming mfctl user add and mfctl account add. Who a deployment serves and which mailboxes it reads are its own to keep, and the
administrative endpoint is where both are written;
a deployment that records no user is the
rest of that story.
mfctl is the client for that endpoint; administering a deployment covers reaching it. From there:
$ mfctl user add --display-name "Alex"
$ mfctl account add --from-file mailbox.json
The first records the person this deployment serves, under the label they are told apart by; mfctl user rename
changes it later. The second reads the file written in step 2, creates that mail account,
assigns it to them, and prints the identifier it was generated under. It names no user, because this deployment now holds exactly one: --user is how a deployment serving
several says which of them — mfctl user add records each further person — and an invocation that omits it where there
are several is refused rather than guessed at.
What the person may do is a role, and recording them assigns none. A user no role is assigned to reaches no tool,
whichever credential they later present, so give the person the seeded Mail user role at their own scope, taking
the role's identifier from mfctl role list and theirs from mfctl user list:
$ mfctl role list
$ mfctl assignment add --role <the Mail user role's identifier> --user <their identifier> --scope-user <their identifier>
How a caller's grant is computed is what that role does, and roles, groups, and assignments the rest of the commands. Every replica reads the assignment within thirty seconds.
The mailbox file written in step 2 names the language MailFathom writes about that
mailbox's mail in — the reading on a message row, the statement about a conversation. mfctl account edit is where it
becomes something else, and the language this mailbox is read in is the whole of it.
mfctl user add records the person reading English, which is a second language and a different question: it is what
MailFathom writes for them rather than about a mailbox — the card beside a contact, a message answering no
correspondence. mfctl user edit changes it, and the language this person
reads is the whole of that one. A
person whose mailbox is read in Polish may read English themselves, and the two are set apart.
The mailbox is served from that moment, without a restart. The write that commits the record announces it, so the next synchronization pass reads the account from the records and starts its first run — and the same holds for every user recorded later.
A declaration the deployment will not accept is refused whole rather than committed in part, naming what it refused: an
account identifier the record already carries, a missing Host or UserName, a transport weakening that was not
stated, or a secret reference that resolves to nothing. Correct mailbox.json and run the command again.
7. Enable the MCP endpoint
The endpoint is off by default, and enabling it means stating how it is authenticated:
{
"McpEndpoint": {
"Enabled": true,
"Authentication": [
{ "Method": "api-key" }
]
}
}
That names a method, not a credential. The list says which ways in this endpoint accepts — password, api-key,
public-key, or oauth-subject — and nothing about who holds one. Each key belongs to the person whose mail it reaches
and is minted by the running deployment, over the administrative endpoint, once it is up:
$ mfctl credential create --method api-key
Provisioned api-key credential 9b3e… for user 6f1c….
The client presents this key: mfk_…
It is stored only as a digest, so nothing here or in the deployment can report it again. Copy it now.
The deployment keeps only a digest, so no file, backup, or configuration on this machine holds anything a client could
present — and a key nobody copied is replaced with mfctl credential rotate rather than recovered.
User credentials is the whole command group, including how a key
is disabled the moment it has to stop working.
An empty Authentication list is legal — the reverse-proxy-and-loopback deployment is an ordinary one — but it is
announced with a startup warning, because an unauthenticated endpoint serves your mailbox to whoever can reach its port. Read
the MCP endpoint before widening anything: it records the other three methods — a
mapped OAuth subject, a client's public key, and a user's own username and password
— browser origins, serving your own domain over TLS, client certificates, and the rate limits that apply out of the box.
A credential reaches what its user's roles grant until its provisioning narrows it. The command above named no
--permission, so the key it minted narrows nothing and may do whatever its user's roles grant — with the seeded
Mail user role, everything an agent is offered here: read the local mailbox copy, ask questions of it, and read,
record, amend, and erase the contact books its user reads. A user no role is assigned to holds nothing, whichever
credential they present. Naming --permission once per name keeps less, and mfctl credential list reads back what
each credential names and what that leaves it holding —
what a credential may do has the names and the rules.
A narrowed grant is enforced on the tools themselves: a client connecting with that credential is listed only the tools its grant permits, and a call naming any other is answered as a call naming a tool that does not exist. So a grant is what a credential may reach rather than a note about it.
What the endpoint offers at all is a separate decision, and it needs no attention on a first deployment: every kind
of tool is published unless McpEndpoint:PublishedToolCategories names some. An instance stood up for retrieval can
write ["mailbox"] there and publish the reading tools alone, so a release adding tools does not change what your
endpoint offers without you noticing. What this endpoint publishes
holds the categories and what a client may narrow for its own session.
MailFathom itself serves plain HTTP unless its own TLS termination is configured, so keep the application port on
loopback or behind a TLS-terminating proxy — the Compose deployment's default — and give the proxy the certificate. If
you put a proxy in front, name it in ReverseProxy:TrustedProxies as well. The public scheme and host survive the hop
either way; naming the proxy is what stops anything else that can reach the port from claiming them:
behind a TLS-terminating reverse proxy.
8. Connect an MCP client
The endpoint speaks the MCP Streamable HTTP transport at /mcp — the path is fixed — and the key travels as a
bearer credential. Any client that supports Streamable HTTP connects with two facts:
| The client asks for | The value |
|---|---|
| Server URL | http://127.0.0.1:8080/mcp under the Compose defaults; your proxy's HTTPS address otherwise |
| Header | Authorization: Bearer <the key material> |
Where a client asks for those two values, and whether it will accept the second at all, differs per client. Two of the popular chat clients offer no field for a static header, which decides the deployment's authentication rather than only the setup steps; connecting the chat client you already use has the steps, the address kind, and the authentication shapes for each one by name.
A connected client whose user holds Mail user, as step 6 assigned, should be listed at
least fourteen tools — list_accounts, list_emails,
get_email_content, search_emails, each advertising itself as read-only, non-destructive, and idempotent;
set_mail_flags, which marks, stars, and labels a message and announces itself as neither read-only nor confined to
this process, and as destructive because a keyword replacement states the whole set; and send_email,
reply_to_email, and forward_email, which announce
themselves the same way and are destructive on the other ground — each takes nothing away and nothing takes it back.
Beside those, get_outgoing_email reports what became of a message one of them queued and advertises itself as
read-only, and cancel_outgoing_email stops one that has not left yet, advertising itself as destructive and — unlike
the sending tools — as confined to this process, since stopping a message reaches nobody. Then save_draft,
update_draft, and delete_draft, which write a message into your own Drafts folder and send nothing, and
send_draft, which sends what one of them holds and announces itself exactly as send_email does. Then the six contact
tools over the contact books its user reads — their own, and the collected book of each mail account they are
assigned — of which four change state
and two —
update_contact, which replaces a whole record, and delete_contact, which erases one — announce themselves as
destructive too. ask_mail
appears only once you have configured a chat model and an embedding model and both are working; until then
its absence is the deployment telling you it cannot answer questions yet rather than a fault.
Verifying an enabled endpoint is the checklist form of
this, including what the refusals look like when the key or the origin is wrong.
Signing a person in through your own identity provider instead of sharing a key is the other way to connect, and it is the only way for a client whose dialog takes no header. Most of that work is in the provider rather than here: MCP client OAuth walks it end to end from a deployment in exactly this state.
9. Make the first call, and read it correctly
Ask the connected agent to list recent mail, or have the client call list_emails with a small page. Two parts of the
result matter more than the emails on the first day:
folderFreshnesscarries one entry per folder in scope, stating when synchronization last committed progress there. An empty page whose entries reportwasSynchronized: falsemeans the folder has not synchronized yet — not that the mailbox is empty. This is the field to check before trusting any early result.nextCursoris how the rest of the timeline is read: pass it back unchanged with the same filters. Results are deliberately bounded — at most 100 summaries per page — so an agent reads pages, not mailboxes.
From here, using the tools describes the day-to-day surface: what each tool answers, what it bounds, and
what its errors mean, and administering your deployment covers reaching the running service from
your own machine with the mfctl command.