Connecting AI Agents to TrekMail via MCP

Connect compatible MCP clients with browser authorization, a universal CLI bridge, or narrowly scoped static tokens. Follow the setup steps.

Article details

Type, difficulty, plans, and last updated info.

▼
Type
Guide
Difficulty
Intermediate
Plans
Nano · Starter · Pro · Agency
Last updated
Oct 24, 2026

Choose and edit app permissions

During OAuth approval, choose Read only or select individual permissions. Sending and changing/deleting messages are separate. Message reading includes contacts, calendars, templates and blocked senders; the required account and mailbox lookup permissions are included automatically. Use your branded dashboard’s MCP address for a White Label connection.

Open API key details or a connected app and choose Edit access, review the changes, then confirm. An API key keeps its secret. Reduced scopes, resource access and expiry also restrict existing mailbox tokens and cancel sends that have not begun. New OAuth connections can be narrowed immediately; adding access requires a new approval. Editing an older connection disconnects it and saves the choices for reconnection. Mailbox message tokens can only lose permissions or have their expiry shortened.

Connect from the Claude directory

TrekMail is published as a Community connector in the Claude directory.

Open TrekMail in Claude, select Connect, sign in to TrekMail and approve the permissions you need. No API token or custom server URL is needed.

If your Claude workspace restricts connectors, ask its administrator to enable TrekMail. You can revoke access in TrekMail under AI Agents & API, Tokens, Connected apps.

Your own White Label brand: use the MCP address shown in your branded dashboard and name the connector after your brand. Add it as a custom connector; the public TrekMail listing signs in on TrekMail and does not replace your branded connection.

Available actions: your plan, membership and approved permissions apply to every connection. The reference below covers the general API and self-hosted MCP too. In directory connections, password and credential setup opens an authenticated dashboard page through a get_*_setup_link tool; do not send secrets in chat. Creating or replacing a mail app password in the ChatGPT/OpenAI and Claude directory profiles returns a secure dashboard link instead of the secret. Purchases and subscription changes stay in the dashboard.

ChatGPT: until public directory installation is available, use the custom connection described in the official quickstart. Enable Developer mode, add your dashboard's MCP URL in Plugins, authenticate, then install the personal plugin and use it in a Work chat. Public installation instructions will be added after publication.

First request and troubleshooting

  • Show my domains.
  • Show the files in my Drive.

If Claude blocks the connector, ask your workspace administrator to enable it. Cancelled sign-in or revoked access? Open the connection steps again to reconnect.

Other connection methods

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. A credential confined to some domains also does not get update_account, set_client_limit or remove_client_limit, and one confined to some mailboxes does not get update_account or drive_folder_stop_sharing: the API would refuse them anyway.

Pick how you want to connect

Path When to use it
Remote MCP client (recommended) Your client accepts a remote MCP URL and supports browser authorization.
CLI or desktop client Your client accepts a command/stdio server, or has its own remote-MCP command.
mcp-remote on any host You need a universal stdio bridge to the hosted MCP endpoint.
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.

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.

  1. Open the MCP, integrations, or connectors settings in your client.
  2. Choose Add remote MCP server or Add custom connector. The exact label depends on the client.
  3. Enter:
    • Name: TrekMail
    • Remote MCP server URL: https://trekmail.net/mcp
  4. Confirm the connection. Your browser opens TrekMail's authorization page.
  5. 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": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://trekmail.net/mcp"]
    }
  }
}

Restart Claude Desktop. When the local bridge starts, follow its browser authorization prompt.

Client-specific example: Cursor

Configure Cursor with a JSON file:

{
  "mcpServers": {
    "trekmail": {
      "url": "https://trekmail.net/mcp"
    }
  }
}

Client-specific example: Windsurf

For Cascade, open …, Open MCP config file and add this entry. This is the Cascade configuration; other agents can use a different file.

{
  "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 four things, all applied before tools/list answers:

  1. Your token's scopes. A tool whose capability your token does not carry is never registered.
  2. 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.
  3. TREKMAIL_READ_ONLY=true, which drops every write tool regardless of scopes and flags.
  4. The connection's domain or mailbox confinement. A token or connector limited to some domains never gets update_account, set_client_limit or remove_client_limit, and one limited to some mailboxes never gets update_account or drive_folder_stop_sharing. The API refuses these tools to such a connection anyway.

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_connect_setup Check one-time Cloudflare DNS setup and, when eligible, get a TrekMail browser link for the customer's approval; otherwise see the blockers. Requires domains:dns:read; a link also requires cloudflare:write on the credential and authorization in the browser. The tool itself never changes DNS or stores a Cloudflare token.
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 23 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, client storage limits, 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
list_client_limits List client storage limits: one budget in MB for the mailboxes and Drive in a client's domains, with what is reserved, shared, and used
set_client_limit Give a client's domains a storage limit, change it, or replace its domain set; needs a connection that reaches every domain (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE=true)
remove_client_limit Remove a client storage limit after confirm_remove=true; its domains go back to the account's storage (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE=true)

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. Client storage limits can be changed only by a connection that reaches every domain of the account; see Give Each Client Their Own Storage Limit. 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; delegated_send_addresses
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 Set a new mailbox password and automatically revoke all mail app passwords
list_mailbox_app_passwords List a mailbox's app passwords without their secrets
create_mailbox_app_password Create a named password for a mail app or device
rotate_mailbox_app_password Replace an app password; the old one stops immediately
revoke_mailbox_app_password Revoke one app password and sign out its app
set_mailbox_client_auth_mode Require app passwords for mail apps, or allow the mailbox password again
update_account Set new_mailbox_client_auth_mode for future mailboxes; existing mailboxes keep their mode. Requires mailboxes:write, an unrestricted owner token or connector, and TREKMAIL_ALLOW_DESTRUCTIVE=true in self-hosted stdio. Not loaded for a token or connector limited to some domains or mailboxes.
update_mailbox Update display name, conversation view, or the mailbox's Drive access level
set_mailbox_storage Move a mailbox between shared storage (null) and a fixed size in MB, checked against the account's free storage and, in a domain under a client storage limit, that limit (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE=true)
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; revoked mail app passwords and file-sync device passwords 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

New mailboxes created by agents, including bulk creation and invites, follow Account settings > New mailboxes > Mail apps need app passwords, on by default. Changing this setting does not switch existing mailboxes. App passwords are for mail apps; Message API tokens still work independently. For scopes, password handoff and mode changes, see Mail App Passwords via API and MCP.

Shared mailbox tools (ops token)

A shared mailbox is a team inbox (support@, sales@) with no direct sign-in or shared password. Read (can_read) opens its inbox and, when available, its shared IMAP folders. Send as (can_send) allows sending as its address. Each member has their own permissions; there are no member roles. When send-only access is enabled, can_read=false with can_send=true lets someone send from their own webmail or mail app without reading the team inbox. The Message API cannot send from this address with send-only access.

Tool Description
list_shared_mailbox_members List members and their member_mailbox_id, email, can_read, can_send, and access (read_send, read_only, send_only).
add_shared_mailbox_member Add a member; can_read and can_send default to true (self-hosted stdio: TREKMAIL_ALLOW_DESTRUCTIVE).
update_shared_mailbox_member Change can_read, can_send, or the personal custom_label; omitted fields stay unchanged (self-hosted stdio: TREKMAIL_ALLOW_DESTRUCTIVE).
remove_shared_mailbox_member Remove a member; at least one active person must keep Read (can_read=true) (self-hosted stdio: TREKMAIL_ALLOW_DESTRUCTIVE).

Permission changes can return 422 no_access_left when both permissions would be off, 422 send_only_disabled when the requested Read change is unavailable, or 422 last_reader when the last active reader would lose access. Use Remove to end all access, and give another active member Read before removing the last reader. Each of these errors also returns shared_mailbox_id, member_id for an existing member, and a hint naming the request that fixes it.

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 and revokes all app passwords so it can no longer sign in directly) (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)

Converting back removes every member. Set a new webmail password, then create app passwords for mail apps on the Security tab.

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. shared_mailboxes.items[] lists shared folders for people with Read. Wait for native_access_ready=true and check send_as_ready before configuring full read-and-send access. SMTP does not save a Sent copy; the app chooses its Sent folder. delegated_send_addresses is a separate list of available team From addresses, not shared folders or a promise that sending is ready. Sign in with the member’s own address and an app password, using the hosts returned by setup, including on White Label. A retryable native_access_sync_failed means the previous state was kept.

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; all app passwords are revoked and restoration does not bring them back

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). Changes only this domain (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. With apply_to_all, every existing domain switches to it now. 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
update_account Set new_mailbox_client_auth_mode for future mailboxes; existing mailboxes keep their mode. Requires mailboxes:write, an unrestricted owner token or connector, and TREKMAIL_ALLOW_DESTRUCTIVE=true in self-hosted stdio. Not loaded for a token or connector limited to some domains or mailboxes.
get_sending_limits View today's sending allowances, why they are lower right now (trial, no payment yet, the first day after the first payment, or a new domain warming up), when they renew, and what the first payment would change
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
update_message_token Narrow a message token in place: drop scopes, bring its expiry forward or rename it (never widens)
revoke_message_token Revoke a message token (self-hosted stdio local control: requires TREKMAIL_ALLOW_DESTRUCTIVE)

Message tools (message token)

The message token unlocks 64 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 64 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)
get_message_delivery Check what happened to a message send_message accepted, using its request_id: pending, sending, sent, failed, or delivery_uncertain
get_mailbox_sending_limits See how many more recipients the mailbox can send to today, the most one message may have, and when the allowance renews
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
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

send_message returns once the message is accepted, before it is actually sent, so confirm it went out with get_message_delivery; a sending_limit_exceeded error says which allowance was reached and when it renews (resets_at), and the agent should not retry before then. get_message_delivery works with any message token for the same mailbox, not only the one that sent the message, so the short-lived tokens of hosted MCP, or a renewed token, can still check earlier sends; an unknown request_id returns 404.

In get_mailbox_sending_limits, remaining_today is how many more recipients this mailbox can reach today. When the lowest allowance is the account-wide total, limit_today is null, and so is remaining_today until that total is spent (then it is 0). An ops token reads the account total with get_sending_limits.

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.

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 scheduled messages, pending ones by default; status=limit_reached shows those a sending limit held back when they came due, each with a failure saying which allowance and when it renews (re-time one with reschedule_message or delete it with cancel_scheduled), and status=all shows both. 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)

The Message API and message tools send from a shared inbox only with both Read and Send as, using shared_mailbox_id and the member’s token. list_identities returns only addresses supported by that API. Team-address entries provided in personal webmail are not listed or accepted as API identities and cannot be changed or deleted through these tools.

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:

  1. Environment gate: TREKMAIL_ALLOW_SENDING=true must be set when starting the MCP server.
  2. Per-call gate: The agent must pass confirm_send=true as 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:

  1. Environment gate: TREKMAIL_ALLOW_MIGRATION=true must be set when starting the MCP server.
  2. Per-call gate: Each tool requires its own confirmation parameter (confirm_start=true, confirm_retry=true, or confirm_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.js path is correct and you ran npm run build after cloning.
  • "Missing bearer token" errors: Check that at least one of TREKMAIL_API_TOKEN or TREKMAIL_MESSAGE_TOKEN is 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=true in 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=true in that MCP process's environment.
  • Send tool returns "Send not confirmed": The agent must pass confirm_send=true on each send_message or schedule_message call.
  • Send tool returns sending_limit_exceeded: A sending allowance is used up. The error says which one (dimension) and when it renews (resets_at); do not retry before then. If the limit is the number of recipients in one message, split the message instead. get_mailbox_sending_limits shows how many more recipients the mailbox can reach today; its remaining_today is null while the lowest allowance is the account-wide total and some of it is left, and an ops token reads that total with get_sending_limits. TrekMail Sending Limits by Plan explains each limit. A message send_message already accepted can still be refused when it leaves the queue; get_message_delivery then shows it as failed with the same details. A failed send can be sent again later with the same content: the API no longer replays the earlier accepted response for it. A retry of a send that is still pending or was delivered still gets the original response.
  • No message tools appear: Ensure TREKMAIL_MESSAGE_TOKEN is set with a valid tm_msg_ token.
  • Self-hosted stdio migration write tools return errors: Set TREKMAIL_ALLOW_MIGRATION=true in 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_attachments returns a base64-encoded ZIP of all attachments.
  • Draft disappeared after update: update_draft deletes the old draft and appends a replacement, so the draft gets a new UID identity. Use both uid and uidvalidity from 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: false to 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.

Sign in to TrekMail

Access your dashboard, mailboxes and DNS.

12 characters

Reset email sent

If an account exists for this email, we've sent password reset instructions.

By continuing, you agree to TrekMail's Terms and Privacy Policy.