Connecting AI Agents to TrekMail via MCP
Connect compatible MCP clients with browser authorization, a universal CLI bridge, or narrowly scoped static tokens.
Article details
Type, difficulty, plans, and last updated info.
▼
Article details
Type, difficulty, plans, and last updated info.
- Type
- Guide
- Difficulty
- Intermediate
- Plans
- Nano · Starter · Pro · Agency
- Last updated
- Aug 23, 2026
The TrekMail MCP server lets compatible AI clients manage your email infrastructure through natural language. Its catalog covers domains, mailboxes, White Label branding and teams, Drive, email, calendar, migrations, support, billing, and related services through the same TrekMail API.
The full catalog is not loaded into every conversation. TrekMail builds tools/list from the active credential: tools outside its scopes are omitted, as are tools excluded by a selected toolset, read-only mode, transport limits, or a local safety setting. A narrowly scoped email credential therefore advertises a compact email tool list.
Pick how you want to connect
| Path | When to use it | Setup time |
|---|---|---|
| Remote MCP client (recommended) | Your client accepts a remote MCP URL and supports browser authorization. | ~30 seconds |
| CLI or desktop client | Your client accepts a command/stdio server, or has its own remote-MCP command. | ~1 minute |
| mcp-remote on any host | You need a universal stdio bridge to the hosted MCP endpoint. | ~1 minute |
| Self-host the stdio package | You want to point at a private TrekMail instance, run inside a container, or use static tm_live_ tokens instead of OAuth. |
~5 minutes |
Paths 1–3 use OAuth 2.1: the first time you connect, your browser opens TrekMail's consent page, you review the requested permissions, and the client gets a token scoped to your account. No long-lived tm_live_ token is copied into the client. Revoke any connection from AI Agents & API → Tokens → Connected apps at any time.
What you get
- A connection-specific toolset, filtered before registration to the permissions and safety settings of the current connection.
- OAuth 2.1 + dynamic client registration: your AI client registers itself, walks you through a browser consent page, and gets a scoped token. No copy-paste of long-lived tokens for the web, desktop, or CLI paths.
- Dual-token architecture: separate ops token (infrastructure) and message token (full webmail operations). When you connect via OAuth, message tokens are minted automatically per mailbox as needed.
- Automatic idempotency on operations that require it, so a retry does not repeat the same operation.
- Two-step delete: mailbox deletion requires explicit intent and confirmation, then moves the mailbox to Recently deleted for recovery.
- Self-hosted safety controls: an administrator running their own stdio MCP server can require approval for delete, send, and migration actions.
- Full audit logging: every API and MCP operation is logged with 90-day retention.
Before you start
- All plans can connect agents.
- Nano: Email Verifier tools. Adding Drive Storage also gives the agent the Drive capabilities the account is entitled to use, including browsing, upload, sharing, restore, and purge.
- Starter: Full Drive, full Email Verifier, and read-only access across the remaining areas (domains, mailboxes, migrations, tickets, and more). Use the dashboard for write actions that Starter does not expose through the API, such as creating migrations, replying to tickets, or changing auto-reply.
- Pro / Agency: Full read and write access across every family.
- White Label trial or add-on: Adds branding, client/team, and activity tools while its entitlement is active. Without it, those schemas are omitted. During cancellation grace, only the owner receives the read tools.
- First time? The Start tour button on the AI Agents & API page walks through connecting an agent, the per-client steps, manual tokens, connected apps, and the audit log.
- For the OAuth paths (1, 2, 3) you do not need to create a token by hand. Your client creates it through the browser authorization flow. For the self-hosted stdio path (4), create a
tm_live_token in the dashboard first.
1. Remote MCP client (recommended)
Use this path when your AI client supports remote MCP servers and browser authorization.
Shortcut: the Connect Agent tab of the AI Agents & API page asks which client you use and then shows that client's exact route, the menu path, or the config file and a ready snippet with your address already in it. If your client is listed there, follow that instead of the generic steps below.
- Open the MCP, integrations, or connectors settings in your client.
- Choose Add remote MCP server or Add custom connector. The exact label depends on the client.
- Enter:
- Name:
TrekMail - Remote MCP server URL:
https://trekmail.net/mcp
- Name:
- Confirm the connection. Your browser opens TrekMail's authorization page.
- Sign in, review the requested permissions, and approve access. Return to the client when the browser confirms the connection.
The first authorization issues a time-limited token. Compatible clients refresh it automatically. To disconnect, use the client's disconnect action or revoke the app from TrekMail's Tokens → Connected apps.
2. CLI or desktop client
For a client that accepts an stdio command, use the client-neutral bridge below:
npx -y mcp-remote https://trekmail.net/mcp
Configure that command as an MCP server in your client. The first connection opens your browser for authorization.
Some clients also provide their own command for adding a remote MCP server. That is equally valid; use https://trekmail.net/mcp as the server URL and follow the client's prompts.
Client-specific example: Claude Code
claude mcp add trekmail https://trekmail.net/mcp -t http
Client-specific example: Claude Desktop
Edit your config file (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json · Windows: %APPDATA%\Claude\claude_desktop_config.json) and add:
{
"mcpServers": {
"trekmail": {
"url": "https://trekmail.net/mcp",
"transport": "http"
}
}
}
Restart Claude Desktop. The first time you mention TrekMail in a chat, the OAuth popup opens.
Client-specific example: Cursor
Cursor has no screen for a remote server. It reads ~/.cursor/mcp.json (or .cursor/mcp.json
inside a project):
{
"mcpServers": {
"trekmail": {
"url": "https://trekmail.net/mcp"
}
}
}
Client-specific example: Windsurf
Windsurf reads ~/.codeium/windsurf/mcp_config.json. Note the key is serverUrl, not url, a
remote server configured with url is ignored:
{
"mcpServers": {
"trekmail": {
"serverUrl": "https://trekmail.net/mcp"
}
}
}
Save the file and restart the client so it picks up the change. The first connection opens your browser to approve access.
3. mcp-remote (CLI)
Useful for testing or for non-Anthropic MCP clients that don't yet support remote OAuth servers directly, mcp-remote is a small Node bridge from stdio to remote HTTP.
npx -y mcp-remote https://trekmail.net/mcp
The first run opens your browser for OAuth. After that the token is cached under ~/.mcp-auth/ and used automatically.
You can wire this into any stdio MCP client by pointing it at the mcp-remote command instead of a local Node entry point.
4. Self-hosted stdio (Claude Desktop / Docker / npm)
If you want static tm_live_ tokens instead of OAuth (e.g. for unattended servers, private TrekMail instances, or container deploys), clone and run the stdio MCP package on your own host.
Create an API token on the AI Agents & API → Tokens page first. For email read/send, also create a message token via the API using your ops token (see the Connect Agent tab for instructions).
Install the MCP server
git clone https://github.com/trekmail/mcp-server trekmail-mcp
cd trekmail-mcp
npm install
npm run build
Claude Desktop (stdio)
Add this to your Claude Desktop MCP configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"trekmail": {
"command": "node",
"args": ["./trekmail-mcp/build/index.js"],
"env": {
"TREKMAIL_BASE_URL": "https://trekmail.net",
"TREKMAIL_API_TOKEN": "tm_live_your_token",
"TREKMAIL_MESSAGE_TOKEN": "tm_msg_your_token",
"TREKMAIL_ALLOW_SENDING": "false",
"TREKMAIL_ALLOW_MIGRATION": "false"
}
}
}
}
Update the args path to point to where you cloned the repository. Replace the tokens with your own. You can omit TREKMAIL_MESSAGE_TOKEN if you only need infrastructure tools, or omit TREKMAIL_API_TOKEN if you only need message tools. At least one token is required.
Claude Code (stdio)
Add this to your Claude Code MCP settings (.claude/settings.json or project-level config):
{
"mcpServers": {
"trekmail": {
"command": "node",
"args": ["./trekmail-mcp/build/index.js"],
"env": {
"TREKMAIL_BASE_URL": "https://trekmail.net",
"TREKMAIL_API_TOKEN": "tm_live_your_token",
"TREKMAIL_MESSAGE_TOKEN": "tm_msg_your_token",
"TREKMAIL_ALLOW_SENDING": "false",
"TREKMAIL_ALLOW_MIGRATION": "false"
}
}
}
}
Docker
If you prefer Docker, build the image from the repo and run it:
git clone https://github.com/trekmail/mcp-server trekmail-mcp
cd trekmail-mcp
docker build -t trekmail-mcp .
docker run -i \
-e TREKMAIL_BASE_URL=https://trekmail.net \
-e TREKMAIL_API_TOKEN=tm_live_your_token \
-e TREKMAIL_MESSAGE_TOKEN=tm_msg_your_token \
-e TREKMAIL_ALLOW_SENDING=false \
-e TREKMAIL_ALLOW_MIGRATION=false \
trekmail-mcp
Local npm (development)
git clone https://github.com/trekmail/mcp-server trekmail-mcp
cd trekmail-mcp
npm install && npm run build
TREKMAIL_BASE_URL=https://trekmail.net \
TREKMAIL_API_TOKEN=tm_live_your_token \
TREKMAIL_MESSAGE_TOKEN=tm_msg_your_token \
TREKMAIL_ALLOW_SENDING=false \
TREKMAIL_ALLOW_MIGRATION=false \
npm start
Stdio environment variables
These controls apply only to the self-hosted stdio MCP process that you run. They do not turn a TrekMail product feature on or off.
| Variable | Required | Default | Description |
|---|---|---|---|
TREKMAIL_BASE_URL |
Yes | None | Your TrekMail URL (https://trekmail.net) |
TREKMAIL_API_TOKEN |
At least one token | None | Ops token starting with tm_live_ (infrastructure tools) |
TREKMAIL_MESSAGE_TOKEN |
At least one token | None | Message token starting with tm_msg_ (email read/send tools) |
TREKMAIL_TIMEOUT_MS |
No | 30000 |
Request timeout in milliseconds |
TREKMAIL_ALLOW_DESTRUCTIVE |
No | false |
Enable high-impact write and delete tools, including White Label access changes, branding, domain-alias connect/remove, delete intents, domain deletion, forwarding changes, passwords, mailbox access, SMTP, Cloudflare, Drive trash/purge, and message deletion |
TREKMAIL_ALLOW_SENDING |
No | false |
Enable actions that send externally, including real email and White Label member invitations |
TREKMAIL_ALLOW_MIGRATION |
No | false |
Enable migration write tools (start_migration, retry_migration, delete_migration, delete_bulk_migration, update_bulk_migration_job_password, test_migration_connection). Note: cancel_migration and cancel_bulk_migration are always available as safety operations. |
Drive tools for agents
With an ops token that includes Drive scopes, the MCP server provides tools for spaces, usage, browsing, uploads, files, folders, Trash, bulk operations, public share links, sync-device password management, and Drive Add-on status. Your connection sees the tools allowed by its scopes.
For a Drive-only agent, set TREKMAIL_API_TOKEN and grant only the scopes the workflow needs. If you run self-hosted stdio, keep destructive actions disabled unless the agent is running a reviewed purge or empty-trash job. Drive Add-on purchase, resize, and cancel are not MCP tools; agents can read add-on status and pricing, but billing changes stay in the dashboard.
See Drive MCP Tools Overview and Connecting AI Agents to TrekMail Drive.
Available tools
The MCP server exposes these tools to connected agents. Tools are registered conditionally based on which tokens are provided.
Which of them an agent can actually see is decided by three things, all applied before tools/list answers:
- Your token's scopes. A tool whose capability your token does not carry is never registered.
- Local stdio safety controls. When you run the self-hosted stdio server, its administrator can require approval for write, sending, or migration actions. Hosted MCP uses the scopes approved during OAuth instead.
TREKMAIL_READ_ONLY=true, which drops every write tool regardless of scopes and flags.
So a self-hosted connection can be deliberately limited even when its token has broader scopes. Hosted MCP remains limited to the permissions approved during OAuth.
Domain tools (ops token)
| Tool | Description |
|---|---|
list_domains |
List domains with optional status/search filters |
get_domain |
Get details for a specific domain |
get_domain_alias |
Read a domain-alias connection and whether it is delivering now |
set_domain_alias |
Connect matching receive-only addresses to a primary domain (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
remove_domain_alias |
Disconnect a domain alias after confirm_remove: true (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
create_domain |
Add a new domain to the account |
delete_domain |
Delete a domain (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
update_domain_catch_all |
Configure or clear the catch-all address |
set_domain_mail_hosting |
Choose whether TrekMail hosts the domain's incoming mail, or it stays with the customer's provider and the domain is used for sending only |
list_forwarding_addresses |
List mailbox-less forwarding addresses on a domain |
get_forwarding_address_log |
What recent mail to one address did, delivered, deferred, rejected, or blocked as spam before forwarding |
create_forwarding_address |
Create a forwarding address (no mailbox, nothing stored) (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
update_forwarding_address |
Replace recipients, or pause / resume an address (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
delete_forwarding_address |
Delete a forwarding address (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
retry_domain_dkim |
Retry DKIM key provisioning |
update_domain_note |
Update the admin note on a domain |
get_domain_signature |
Read per-domain email signature settings |
update_domain_signature |
Set per-domain email signature (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
bulk_add_domains |
Add up to 20 domains in one call |
See Domain Aliases via API and MCP for plan behavior, response states, safe removal, and receive-only routing rules.
White Label tools (ops token)
The white_label toolset contains 20 tools and appears only when the account entitlement, current membership, and credential scopes allow it. Branding is configured per domain; the remaining tools manage setup, clients, team access, and activity. Active White Label is required for writes. During cancellation grace, only the owner keeps the read tools.
| Tool | Description |
|---|---|
get_domain_branding |
Read branding state: mode, add-on status, brand fields, mail-zone state, hosts, and the dns_records to create |
set_domain_branding |
Partial-merge update of the brand: mode, name, colors, dashboard/webmail/mail-zone toggles and labels, support/sender, scope |
set_domain_brand_logo |
Upload a base64 logo to the light, dark, or favicon slot (PNG/JPG, ICO for favicon, ≤1 MB, no SVG) |
verify_domain_branding_dns |
Queue DNS verification for the enabled branded hosts |
create_branding_preview |
Create a 72-hour preview URL of the branded experience |
remove_domain_brand_logo |
Remove a logo slot |
remove_domain_branding |
Clear branding for the domain or the whole account |
get_white_label |
Read entitlement, account brand, setup progress, and reachable domain status |
get_white_label_access_catalog |
Read roles, permissions, and domains the caller may grant |
list_white_label_members |
Search or filter clients, team members, and invitations |
get_white_label_member |
Read one member, effective permissions, and allowed next operations |
invite_white_label_member |
Invite a client or teammate; local stdio also requires sending to be enabled |
update_white_label_member |
Change role, domains, custom permissions, or note |
suspend_white_label_member |
Stop access and revoke the member's credentials |
resume_white_label_member |
Resume membership without reviving old credentials |
resend_white_label_invitation |
Replace and email a pending invitation; local stdio also requires sending to be enabled |
remove_white_label_member |
Remove access after confirm_remove=true |
restore_white_label_member |
Restore membership without reviving old credentials |
list_white_label_activity |
Read White Label account activity |
get_white_label_member_activity |
Read one member's actions and sign-ins; requires activity and member read scopes |
An agent can run brand setup end to end: set the brand, copy the returned dns_records, publish them with apply_cloudflare_dns, then verify and check the status. Access-changing calls are capped by the caller's live membership and domain boundary even when the token requested broader scopes. See the White Label Branding API and MCP Guide and Manage White Label Teams with API and MCP.
DNS tools (ops token)
| Tool | Description |
|---|---|
get_dns_requirements |
Get required DNS records for a domain |
dns_recheck |
Trigger DNS verification (returns check ID) |
get_dns_check |
Poll DNS check results |
Mailbox tools (ops token)
| Tool | Description |
|---|---|
list_mailboxes |
List mailboxes with optional filters |
get_mailbox |
Get details for a specific mailbox |
get_mail_client_setup |
Get password-free IMAP/SMTP settings, the safe DAV URL and readiness, actual sending readiness, localized app guides, and delegated shared-mailbox folders for a regular member mailbox |
get_apple_mail_profile |
Generate a password-free Apple Mail profile as a Base64 file |
create_mailbox_generated_password |
Create a mailbox with auto-generated password (optional storage_allocation_mb carves out dedicated storage from the account pool) |
change_mailbox_password |
Change the password for a mailbox |
update_mailbox |
Update display name, conversation view, or the mailbox's Drive access level |
set_mailboxes_drive_access |
Set Drive access on many mailboxes at once, by list, by domain, or account-wide |
update_mailbox_note |
Update the admin note on a mailbox |
suspend_mailbox_login |
Stop someone signing in to a mailbox while its mail keeps arriving (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
resume_mailbox_login |
Lift a sign-in suspension; device passwords it revoked are not restored |
set_mailboxes_login_access |
Suspend or restore sign-in across many mailboxes, an explicit list, a whole domain, or all |
pause_mailbox |
Disable a mailbox entirely, delivery included, senders get their mail back. Use suspend_mailbox_login to stop only sign-in |
resume_mailbox |
Re-enable a paused mailbox |
enable_imap |
Enable IMAP access for a mailbox (required for Message API) |
create_invite |
Send a setup invite to a recipient (optional storage_allocation_mb pre-allocates dedicated storage that the recipient inherits at redeem) |
create_invites_bulk |
Send up to 100 invites in one call (per-item storage_allocation_mb supported) |
bulk_create_mailboxes |
Create up to 100 mailboxes in one call (per-item storage_allocation_mb supported) |
get_forwarding |
Get forwarding config for a mailbox |
set_forwarding |
Configure forwarding rules |
Shared mailbox tools (ops token)
A shared mailbox is a team inbox (support@, sales@) that members open through their own regular mailbox account in Webmail and, when enabled, delegated native IMAP/SMTP access. It has no direct password login. Access is flat, everyone can read, and can_send is the only toggle (reply-capable vs read-only). There are no member roles.
| Tool | Description |
|---|---|
list_shared_mailbox_members |
List who can access a shared mailbox in Webmail and delegated native IMAP (each: member_mailbox_id, email, can_read, can_send) |
add_shared_mailbox_member |
Add Webmail/native access; can_send defaults to true (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
update_shared_mailbox_member |
Toggle Webmail/native send-as access (can_send) without removing read access (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
remove_shared_mailbox_member |
Revoke Webmail/native access, a shared mailbox always keeps at least one member (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
Shared mailbox lifecycle (ops token)
| Tool | Description |
|---|---|
create_shared_mailbox |
Create a new shared mailbox from a domain, local part, display name, and a list of member mailbox IDs (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
convert_mailbox_to_shared |
Turn an existing mailbox into a shared one (rotates the old password so it can no longer sign in) (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
convert_shared_mailbox_to_regular |
Convert a shared mailbox back to a regular one, revokes member Webmail/native access and sets a fresh sign-in password (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
The three lifecycle tools and the three member-write tools change access. A locally hosted stdio administrator can require TREKMAIL_ALLOW_DESTRUCTIVE=true before they are available; list_shared_mailbox_members is read-only and always available.
After creating, converting, or changing membership, call get_mail_client_setup with a regular member mailbox id. Read shared_mailboxes.items[], wait for native_access_ready=true, and check send_as_ready before configuring sending. The response supplies exact Inbox/Sent/Archive/Junk paths and operation flags; SMTP does not save the shared Sent copy. A retryable native_access_sync_failed from permission removal, permission update, or conversion means the service deliberately kept the previous state.
Sieve tools (ops token)
| Tool | Description |
|---|---|
get_sieve_script |
Get the raw Sieve script for a mailbox |
upload_sieve_script |
Upload a raw Sieve script for a mailbox |
Delete tools (ops token)
| Tool | Description |
|---|---|
create_delete_intent |
Step 1: create a time-limited delete intent |
confirm_delete_intent |
Step 2: confirm deletion and move the mailbox to Recently deleted |
Migration tools (ops token)
| Tool | Description |
|---|---|
test_migration_connection |
Validate IMAP credentials and discover source folders with counts |
list_migrations |
List migrations with optional status/mailbox filters |
get_migration |
Get detailed migration status with per-folder breakdown |
start_migration |
Start a new email migration (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_start) |
cancel_migration |
Cancel a running migration (always available, safety operation, requires confirm_cancel) |
retry_migration |
Retry a failed or cancelled migration (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_retry) |
delete_migration |
Delete a completed/failed migration record (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_delete) |
preview_bulk_migration |
Validate and preview a bulk migration batch (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION) |
start_bulk_migration |
Start a bulk migration batch (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_start) |
list_bulk_migrations |
List bulk migration batches with optional status filter |
get_bulk_migration |
Get details of a bulk migration batch |
cancel_bulk_migration |
Cancel an active bulk batch (requires confirm_cancel) |
retry_bulk_migration |
Retry failed jobs in a batch (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_retry) |
resume_bulk_migration |
Resume a paused batch (requires confirm_resume) |
delete_bulk_migration |
Delete a terminal bulk migration batch (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION + confirm_delete) |
update_bulk_migration_job_password |
Update source password for a failed job (self-hosted stdio local control: TREKMAIL_ALLOW_MIGRATION) |
Ticket tools (ops token)
| Tool | Description |
|---|---|
list_tickets |
List support tickets with optional filters |
get_ticket |
Get ticket details |
get_ticket_messages |
Get messages in a ticket thread |
create_ticket |
Create a new support ticket |
reply_to_ticket |
Reply to an existing ticket |
close_ticket |
Close a ticket |
SMTP / domain-routing tools (ops token)
SMTP is configured per domain: each domain points at managed platform sending or at a saved SMTP profile (your own provider, reusable across domains), and a single account-wide default decides what new domains start on.
| Tool | Description |
|---|---|
get_domain_smtp |
View a domain's SMTP route (smtp_mode plus effective_smtp_mode, which resolves inherit to the account default), and its profile |
set_domain_smtp |
Set a domain's route, platform, profile (with a profile id), not_configured, or inherit (live-follow the account default). Supports the set_account_default and apply_to_all switches (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
list_domain_smtp_profiles |
List the account's saved SMTP profiles |
get_domain_smtp_profile_usage |
Show the exact domains and Send As addresses using one profile, without credentials |
create_domain_smtp_profile |
Create a profile and use it for this domain (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
update_domain_smtp_profile |
Update a profile, affects every domain using it (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
delete_domain_smtp_profile |
Delete a profile; domains using it are reassigned to the account default (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
test_domain_smtp |
Start an async SMTP test for a route (returns a job ID) (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
get_domain_smtp_test_status |
Poll a domain SMTP test job |
get_account_smtp_default |
View the account-wide default route (default_smtp_mode, the plan-baseline effective_default_smtp_mode, and its profile) |
set_account_smtp_default |
Set the account-wide default, platform, profile, or not_configured; decides what new domains start on. Pair with set_domain_smtp mode inherit to have a domain live-follow it (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
The write and test tools above change settings or make a connection test. A locally hosted stdio administrator can require TREKMAIL_ALLOW_DESTRUCTIVE=true before they are available; get_domain_smtp, list_domain_smtp_profiles, get_domain_smtp_test_status, and get_account_smtp_default are read-only and always available.
Legacy SMTP tools (deprecated)
These account-level tools remain for backward compatibility but no longer control per-domain routing: use the domain-routing tools above instead.
| Tool | Description |
|---|---|
get_smtp_config |
(deprecated) View the legacy account-level SMTP mode and connection details |
update_smtp_config |
(deprecated) Update the legacy account-level SMTP configuration |
delete_smtp_connection |
Delete a custom SMTP connection |
test_smtp |
Start an async SMTP connection test (returns job ID) |
get_smtp_test_status |
Poll SMTP test results |
Spam metrics tools (ops token)
| Tool | Description |
|---|---|
get_spam_metrics |
Get daily spam protection metrics for a domain (inbound, spam caught, rejected, clean) |
get_spam_summary |
Get aggregated spam protection summary for a domain (spam rate, status, top triggered rules) |
Account tools (ops token)
| Tool | Description |
|---|---|
get_account |
View account info, plan, limits, and usage |
get_billing_status |
View billing status and subscription details |
list_invoices |
List invoice history |
Message token management (ops token)
| Tool | Description |
|---|---|
create_message_token |
Create a message API token for a mailbox (returns the plaintext token once) |
list_message_tokens |
List all message tokens for a mailbox |
revoke_message_token |
Revoke a message token (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
Message tools (message token)
The message token unlocks 62 tools covering the full webmail surface, including connected external accounts. Tools are organized by feature area.
Hosted OAuth and local stdio identify the mailbox differently. On hosted HTTP MCP, every message-tool schema includes a required mailbox_id; the server uses it to mint a short-lived token for that mailbox. On local stdio MCP, TREKMAIL_MESSAGE_TOKEN is already bound to one mailbox, so those same tools do not accept mailbox_id. A connected inbox is a second level of selection: pass external_account_id in addition to mailbox_id on hosted MCP, or in addition to the bound message token on stdio.
Seven of the 62 message tools manage connected accounts, and five manage From identities and reply policy. Use both families for the Gmail-style workflow where an agent reads a connected Gmail inbox but sends an authorized business address through a domain route or saved SMTP profile. See Send As Addresses via API and MCP.
Core messages
| Tool | Description |
|---|---|
list_messages |
List messages in a folder with cursor pagination |
read_message |
Get a single message with full body and inline attachments |
send_message |
Send an email from the mailbox (requires dual safety gates) |
delete_message |
Delete a message permanently (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
move_message |
Move a message to a different IMAP folder |
update_message_flags |
Mark read/unread, starred/unstarred on a message |
get_raw_message |
Download the full RFC822 raw source of a message |
If the mailbox has a Default CC or Default BCC set in Settings → Profile, it is added to what send_message and schedule_message send, exactly as it is to mail written in the web app, an address already on the message is not added twice. Pass apply_default_recipients: false to leave it off a single message. This does not reach mail sent through a desktop or phone mail client over SMTP, which never passes through the API.
| report_spam | Report a message as spam, moves to Junk and trains the filter |
| report_ham | Mark a Junk message as not spam, moves to Inbox and trains the filter |
| bulk_action | Apply an action (read, star, delete, move, spam) to up to 50 messages at once |
Folders
| Tool | Description |
|---|---|
list_folders |
List all IMAP folders for the mailbox |
create_folder |
Create a new IMAP folder |
rename_folder |
Rename an existing folder |
delete_folder |
Delete a leaf folder and its messages; delete child folders explicitly first (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
empty_folder |
Permanently delete all messages in Trash or Junk (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Attachments
| Tool | Description |
|---|---|
download_attachment |
Download a single attachment by index, returns base64 content |
download_all_attachments |
Download all attachments from a message as a base64 ZIP |
Drafts
| Tool | Description |
|---|---|
save_draft |
Save a new draft and return its uid + uidvalidity identity |
update_draft |
Replace a draft using both its uid and required uidvalidity |
Both return the draft's uid and uidvalidity. Keep that pair together: update_draft requires the epoch so an old, reused UID can never delete a different message after the Drafts folder is recreated. A draft found with list_messages should first be opened with read_message, which returns its current uidvalidity. An update returns a new pair and the old UID stops working. On a server without UIDPLUS, both values can be null even though a new draft was saved; refresh Drafts and open the draft before updating it.
Both also accept an optional idempotency_key. Leave it out and every call is treated as a new one, so saving the same draft twice gives you two drafts. Pass the same key when you are retrying a call that may already have gone through, and you get the first result back instead of a duplicate.
Scheduled send
| Tool | Description |
|---|---|
schedule_message |
Schedule a message for future delivery (requires TREKMAIL_ALLOW_SENDING + confirm_send; accepts optional IANA timezone for naïve datetimes) |
list_scheduled |
List pending scheduled messages; follow pagination.next_cursor to enumerate every page |
reschedule_message |
Re-time a pending scheduled message in place (no resend; uses lighter messages:read throttle so batch re-times don't burn the send rate-limit) |
cancel_scheduled |
Cancel a pending scheduled message (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Contacts
| Tool | Description |
|---|---|
list_contacts |
List contacts with optional search filter |
create_contact |
Create a contact, upserts if email already exists |
update_contact |
Update a contact's fields |
delete_contact |
Delete a contact (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
import_contacts |
Import contacts from base64-encoded CSV or VCF content |
export_contacts |
Export all contacts as CSV or VCF, returns base64 content |
Contact groups
| Tool | Description |
|---|---|
create_contact_group |
Create a named contact group |
update_contact_group |
Rename a contact group |
delete_contact_group |
Delete a contact group (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
add_contact_group_members |
Add contacts to a group by ID |
remove_contact_group_members |
Remove contacts from a group |
Calendar
| Tool | Description |
|---|---|
list_calendar_events |
List calendar events in a date range |
create_calendar_event |
Create a new event with title, start/end, location, and notes |
update_calendar_event |
Update an existing event |
delete_calendar_event |
Delete a calendar event (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Compose helpers
These tools prepare the data for a reply or forward. They do not send anything. Pass the returned data directly to send_message or save_draft.
| Tool | Description |
|---|---|
prepare_reply |
Pre-populate a reply (To, Re: subject, quoted body, In-Reply-To header) |
prepare_reply_all |
Pre-populate a reply-all (To + Cc from all original recipients) |
prepare_forward |
Pre-populate a forward (Fwd: subject, forwarded body, original attachment metadata) |
Identities (send-from addresses)
| Tool | Description |
|---|---|
list_identities |
List source-specific From addresses, Send As routes, and reply policy; pass external_account_id for a connected inbox |
create_identity |
Configure a managed identity or create a Send As identity bound to one connected inbox |
update_identity |
Update identity name, reply-to, signature, or Send As route |
delete_identity |
Delete a Send As identity; managed mailbox/alias identities remain authorized (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
set_reply_from_policy |
Reply from the address that received the message or always use the default (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Templates
| Tool | Description |
|---|---|
list_templates |
List all saved message templates |
create_template |
Create a template with name, subject, and HTML body |
update_template |
Update a template |
delete_template |
Delete a template (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Blocked senders
| Tool | Description |
|---|---|
list_blocked_senders |
List all blocked email addresses and domains |
block_sender |
Block a specific email address or entire domain (e.g., @spam.com) |
unblock_sender |
Remove a block (self-hosted stdio local control: TREKMAIL_ALLOW_DESTRUCTIVE) |
Email Verifier tools (ops token)
| Tool | Description |
|---|---|
verify_email |
Verify a single email address |
verify_email_bulk |
Submit a bulk verification job |
verify_job_status |
Check job progress and results |
verify_job_download |
Download job results as CSV |
verify_credits |
Check remaining credit balance |
verify_list_jobs |
List all verification jobs |
verify_cancel_job |
Cancel a running job and refund unprocessed credits |
verify_delete_job |
Permanently delete a job and all results (GDPR) |
Email Verifier tools are available on all plans, including Nano. The only limitation is your credit balance.
Cloudflare tools (ops token)
| Tool | Description |
|---|---|
validate_cloudflare_token |
Validate a Cloudflare API token |
list_cloudflare_zones |
List DNS zones accessible by a Cloudflare token |
connect_cloudflare_domains |
Connect domains to a Cloudflare account |
preview_cloudflare_dns |
Preview DNS changes that would be applied via Cloudflare. Pass an optional included_records allowlist ({ domain_id: [record_ids] }) to preview only specific records |
apply_cloudflare_dns |
Apply DNS changes to Cloudflare-managed zones. Use included_records to write only chosen records and skip the rest (e.g. MX now, DKIM later); omit it to apply everything. Use confirmed_conflicts to authorise replacing records preview flagged as conflicting |
list_cloudflare_tokens |
List stored Cloudflare tokens |
delete_cloudflare_token |
Delete a stored Cloudflare token (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE) |
Cloudflare tools are available on Pro and Agency plans.
Safety controls for self-hosted stdio
When you run the stdio MCP server yourself, TREKMAIL_ALLOW_DESTRUCTIVE controls whether that local process permits delete and other write actions. Set it to true only if you trust the agent to handle mailbox deletion. This setting does not change feature availability in hosted TrekMail.
Even with destructive operations enabled, deletion always requires two steps and the agent must explicitly set confirm: true. See Safety Rails and Delete Intents for details.
Sending safety gates
The send_message and schedule_message tools have two independent safety gates that must both pass:
- Environment gate:
TREKMAIL_ALLOW_SENDING=truemust be set when starting the MCP server. - Per-call gate: The agent must pass
confirm_send=trueas a parameter on every call.
This dual-gate design prevents accidental email sends from a self-hosted process. Set TREKMAIL_ALLOW_SENDING=false when your agent should only read messages. list_scheduled works without this control; it applies only to creating or sending scheduled messages.
Migration safety gates
Migration write tools (start_migration, retry_migration, delete_migration, delete_bulk_migration, update_bulk_migration_job_password, test_migration_connection, preview_bulk_migration, start_bulk_migration, retry_bulk_migration) have two independent safety gates:
- Environment gate:
TREKMAIL_ALLOW_MIGRATION=truemust be set when starting the MCP server. - Per-call gate: Each tool requires its own confirmation parameter (
confirm_start=true,confirm_retry=true, orconfirm_delete=true).
cancel_migration, cancel_bulk_migration, and resume_bulk_migration are always available regardless of the self-hosted environment control because they are safety or resumption operations. They still require per-call confirmation parameters.
Read-only migration tools (list_migrations, get_migration, list_bulk_migrations, get_bulk_migration) work without any gates.
Quick fixes
- Agent cannot connect: Verify the
build/index.jspath is correct and you rannpm run buildafter cloning. - "Missing bearer token" errors: Check that at least one of
TREKMAIL_API_TOKENorTREKMAIL_MESSAGE_TOKENis set. - Read-only tools work but writes fail: Your token is on a Starter plan. Drive writes work on Starter (full Drive surface). For other writes, provisioning mailboxes, starting migrations, replying to tickets, upgrade to Pro, or use the dashboard.
- Delete tools return errors in self-hosted stdio: Set
TREKMAIL_ALLOW_DESTRUCTIVE=truein that MCP process's environment. This applies to delete and other write actions, including messages, folders, contacts, calendar, identities, templates, blocked senders, and scheduled messages. - A self-hosted stdio send tool returns "Sending is disabled": Set
TREKMAIL_ALLOW_SENDING=truein that MCP process's environment. - Send tool returns "Send not confirmed": The agent must pass
confirm_send=trueon eachsend_messageorschedule_messagecall. - No message tools appear: Ensure
TREKMAIL_MESSAGE_TOKENis set with a validtm_msg_token. - Self-hosted stdio migration write tools return errors: Set
TREKMAIL_ALLOW_MIGRATION=truein that MCP process's environment. - 503 on migration start: The server is at migration capacity. Retry in a few minutes.
- Attachment download fails: Attachments are returned as base64. Large attachments (up to 25 MB) may take a few seconds.
download_all_attachmentsreturns a base64-encoded ZIP of all attachments. - Draft disappeared after update:
update_draftdeletes the old draft and appends a replacement, so the draft gets a new UID identity. Use bothuidanduidvalidityfrom the response for anything that follows; the pair you passed in no longer identifies the replacement. - A copy of every message arrives somewhere you did not put it: the mailbox has a Default CC or Default BCC set in Settings → Profile. It applies to what this mailbox sends, including through the API. Clear it there, or pass
apply_default_recipients: falseto leave it off one message. - Calendar event not found: Events are scoped to the specific mailbox. Confirm the message token was issued for the correct mailbox.
Related articles
Jump to nearby guides that continue the workflow.