Skip to content

MCP Server

Connect AI clients to Pigeon over stdio or Streamable HTTP.

Pigeon ships an MCP server exposing eight mail tools. Run it over stdio for local clients, or use the /mcp HTTP endpoint of pigeon serve.

stdio

{
  "mcpServers": {
    "pigeon": {
      "command": "pigeon",
      "args": ["mcp"]
    }
  }
}

The process reads MCP JSON-RPC on stdin/stdout and logs to stderr. It opens the same data directory as pigeon serve (~/.pigeon by default); pass --data DIR in args if you use a custom location.

Streamable HTTP

pigeon serve mounts the MCP endpoint at /mcp. It is stateless and replies with JSON (application/json, not SSE). Authenticate exactly like the REST API — bearer token required for non-loopback clients:

{
  "mcpServers": {
    "pigeon": {
      "type": "http",
      "url": "http://127.0.0.1:8787/mcp",
      "headers": { "Authorization": "Bearer pigeon_xxx" }
    }
  }
}

Tools

Tool Parameters Description
list_accounts — Accounts with unread counts
list_mailboxes account? Mailboxes with unread/total counts and attributes
list_messages account?, mailbox?, limit?, query?, unseenOnly? Message summaries, newest first
read_message id, includeHtml? Full message; fetches the body if uncached
search_messages query?, from?, subject?, body?, since?, until?, account?, limit? Search cached mail; metadata by default
sync_mailbox account?, mailbox? Fetch new mail over IMAP
set_message_flags id, seen?, flagged? Change read/starred state on server and locally
send_email account?, to, cc?, bcc?, subject, text, html?, inReplyTo?, attachments? Send over SMTP and archive to Sent

Parameter notes:

  • account accepts an account ID, email address or name. It may be omitted when exactly one account is configured.
  • mailbox accepts a path or display name and defaults to INBOX.
  • list_messages defaults to 20 results, maximum 100; search_messages the same for hits.
  • search_messages requires at least one of query, from, subject, since or until, and searches all accounts unless account is given. query matches subject and sender/recipient metadata; set body=true to also match snippet and cached body text (bodies are fetched lazily, and body searches are slower). since/until accept YYYY-MM-DD (local time, until inclusive through end of day) or RFC3339 timestamps.
  • read_message returns text truncated to 64 KiB and, with includeHtml, HTML up to 256 KiB. It does not mark the message as read. When the message has attachments, an attachments array of {id, filename, contentType, size} metadata is included — bytes download through the REST endpoint GET /api/attachments/{id}. Stored attachments are capped at 25 MB each; larger files are skipped and do not appear in the array.
  • send_email accepts an attachments array of {filename, contentType?, content} objects, where content is standard base64. It requires explicit user intent. It is annotated as non-idempotent and OpenWorld, so MCP clients that surface confirmations will ask first.

Output shapes

MCP outputs are JSON-friendly variants of the REST objects. Dates are ISO-8601 UTC strings (e.g. 2026-12-01T08:30:00Z) rather than Unix seconds. Examples:

// list_messages
{
  "account": "someone@qq.com",
  "mailbox": "INBOX",
  "messages": [
    {
      "id": 42,
      "accountId": 1,
      "subject": "Invoice for November",
      "from": [{"name": "Billing", "address": "billing@example.com"}],
      "date": "2026-11-30T10:00:00Z",
      "snippet": "Your invoice is attached…",
      "seen": false,
      "flagged": false,
      "hasAttachments": true
    }
  ]
}
// sync_mailbox
{"mailbox": "INBOX", "mailboxes": 6, "newMessages": 2, "total": 128, "unread": 3}
// send_email
{"ok": true, "messageId": "b2f4…@qq.com", "appended": true}

The server’s built-in instructions suggest this pattern to agents:

  1. list_accounts → list_mailboxes to learn what exists.
  2. If a mailbox looks empty or stale, sync_mailbox.
  3. list_messages / search_messages to find mail, read_message for the body.
  4. Use set_message_flags only when the user wants read/starred state changed.
  5. Call send_email only with clear user intent, after confirming recipients and content.