# Create a mailbox (operations token)
curl -X POST https://trekmail.net/api/v1/mailboxes \
-H "Authorization: Bearer tm_live_…" \
-H "Idempotency-Key: support-acme-2026" \
-H "Content-Type: application/json" \
-d '{ "domain_id": 1, "local_part": "support" }'
# Read unread messages (message token)
curl https://trekmail.net/api/v1/messages?unread_only=true \
-H "Authorization: Bearer tm_msg_…"
import os, requests
base = "https://trekmail.net/api/v1"
ops = {"Authorization": f"Bearer {os.environ['TM_OPS']}"}
msg = {"Authorization": f"Bearer {os.environ['TM_MSG']}"}
# Provision a mailbox
requests.post(f"{base}/mailboxes", headers=ops,
json={"domain_id": 1, "local_part": "support"})
# Pull the inbox
unread = requests.get(f"{base}/messages", headers=msg,
params={"unread_only": True}).json()
// Node 20+ — native fetch, no SDK required
const headers = {
"Authorization": `Bearer ${process.env.TM_OPS}`,
"Idempotency-Key": "support-acme-2026",
"Content-Type": "application/json"
}
const mbox = await fetch("https://trekmail.net/api/v1/mailboxes", {
method: "POST", headers,
body: JSON.stringify({ domain_id: 1, local_part: "support" })
}).then(r => r.json())
# 1. clone & build the open-source MCP server
git clone https://github.com/trekmail/mcp-server trekmail-mcp
cd trekmail-mcp && npm install && npm run build
# 2. add to 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_…",
"TREKMAIL_MESSAGE_TOKEN": "tm_msg_…",
"TREKMAIL_ALLOW_SENDING": "false",
"TREKMAIL_ALLOW_DESTRUCTIVE": "false"
}
}
}
}