Skip to main content
Glama
Xallor Email MCP

Xallor Email MCP

Official
by xallor-ai
README.md
<h1 align="center">Xallor Email MCP</h1>

<p align="center">
  <strong>All your mailboxes. One MCP server for AI agents.</strong>
</p>

<p align="center">
  <a href="https://github.com/xallor-ai/email-mcp/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-222222?style=flat-square" alt="MIT license"></a>
  <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20-222222?style=flat-square" alt="Node.js 20 or newer"></a>
</p>

<p align="center">
  <a href="https://github.com/xallor-ai/email-mcp">GitHub</a> ·
  <a href="#quick-start">Quick start</a> ·
  <a href="#tools">Tool reference</a>
</p>

**Xallor Email MCP** is an open-source [Model Context Protocol](https://modelcontextprotocol.io) server that lets AI agents manage Gmail, Outlook, Microsoft 365, and IMAP mailboxes through one unified tool surface. Connect personal and work accounts, then pass an email address — Xallor routes each request to the right provider.

Run it locally over stdio or self-host over Streamable HTTP. MIT licensed.

## What can your agent do?

- **Read and find email** — browse inboxes, search one or all connected accounts, read messages, and download attachments.
- **Write and reply** — compose Markdown emails, reply to threads, forward messages, and create or edit drafts before sending.
- **Organize mailboxes** — archive, trash, move messages, mark them read or unread, and manage folders.
- **Work across accounts** — one tool surface for different providers, with per-account signatures and style preferences.
- **Check for new mail** — poll for new inbox messages on your agent's schedule.

## Supported mailboxes

| Mailbox | Connection | Setup |
| --- | --- | --- |
| **Gmail / Google Workspace** | Gmail API with Google OAuth | Built-in Desktop client by default; custom OAuth clients remain optional. [Gmail](#gmail) |
| **Outlook / Microsoft 365** | Microsoft Graph with device-code sign-in | Personal or work Microsoft account. [Outlook](#outlook) |
| **IMAP mailboxes** | IMAP for reading/managing; SMTP for sending | Provider IMAP/SMTP settings plus password or app password. [IMAP](#imap) |

## Quick start

Requires **Node.js 20+** and an MCP-compatible client.

### 1. Install

```bash
# from this repository (recommended while the npm name is settling)
npm install -g github:xallor-ai/email-mcp
xallor-email-mcp --help

# or once published
# npm install -g xallor-email-mcp
```

### 2. Connect your agent

```json
{
  "mcpServers": {
    "xallor-email": {
      "command": "npx",
      "args": ["-y", "github:xallor-ai/email-mcp"]
    }
  }
}
```

Claude Code:

```bash
claude mcp add xallor-email -- npx -y github:xallor-ai/email-mcp
```

### 3. Add a mailbox

Reload the MCP client, then ask:

> Connect my Outlook account using Xallor Email MCP.

The agent calls `add_account` and walks you through sign-in. Add more accounts to the same server as needed.

### 4. Put it to work

> Search all my connected mailboxes for invoices from last month.

> Draft a reply from my work account. Save it for review; do not send it.

> Move the selected messages to Receipts and mark them as read.

Configure your MCP client to require confirmation for sending or destructive actions.

## Self-hosting

### HTTP server

```bash
xallor-email-mcp --http --port 3847 --host 0.0.0.0
# endpoint: http://<host>:3847/mcp
```

HTTP has **no built-in authentication**. Keep it on a private network or behind an authenticated reverse proxy. See [docs/hosting.md](docs/hosting.md).

### Docker

```bash
docker build -t xallor-email-mcp .
docker run -d \
  --name xallor-email-mcp \
  -p 127.0.0.1:3847:3000 \
  -e XALLOR_KEY \
  -e XALLOR_OUTLOOK_CLIENT_ID \
  -e XALLOR_OUTLOOK_TENANT_ID \
  -v xallor-email-data:/var/lib/mcp \
  xallor-email-mcp
```

### Development

```bash
pnpm install
pnpm dev        # rebuild on save
pnpm dev:http   # HTTP on http://127.0.0.1:3000/mcp
pnpm test
pnpm typecheck
pnpm build
```

## Configuration

Configuration is env-only. CLI flags only override transport, host, port, and data directory.

| Env var | Purpose | Default |
| --- | --- | --- |
| `XALLOR_DATA_DIR` | Account/token store | `${XDG_DATA_HOME:-~/.local/share}/xallor-email-mcp` |
| `XALLOR_KEY` | AES-256-GCM key (hex/base64) or passphrase | Auto-generated local key if unset |
| `XALLOR_TRANSPORT` | `stdio` or `http` | `stdio` (`--http` forces `http`) |
| `XALLOR_HTTP_PORT` | HTTP port | `3000` |
| `XALLOR_HTTP_HOST` | HTTP host | `127.0.0.1` |
| `XALLOR_OUTLOOK_CLIENT_ID` | Optional Entra public client ID | Built-in public client |
| `XALLOR_OUTLOOK_TENANT_ID` | Outlook tenant | `common` |
| `XALLOR_GMAIL_CLIENT_ID` | Optional Google OAuth client override | Built-in Desktop client |
| `XALLOR_GMAIL_CLIENT_SECRET` | Optional Google OAuth secret override | Built-in secret only for the built-in client ID |
| `XALLOR_GMAIL_REDIRECT_URI` | Hosted Gmail OAuth callback | Local loopback callback |
| `XALLOR_TOOLS_ENABLED` | Tool allowlist | Empty = no filtering |
| `XALLOR_TOOLS_DISABLED` | Tool blocklist | Empty = no filtering |
| `XALLOR_DEBUG` | Structured debug logs (`1`/`true`/`yes`/`on`/`debug`) | Off |

Generate a key:

```bash
xallor-email-mcp generate-key
```

## Tools

Most tools take an `account` argument (mailbox email). Omit `account` on `search_emails` / `get_new_emails` to work across all connected accounts.

| Tool | Notes |
| --- | --- |
| `list_accounts` | Registered emails + provider metadata |
| `add_account` / `complete_add_account` | Provider onboarding (OAuth / device code / IMAP config) |
| `remove_account` | Delete stored credentials |
| `get_account_settings` / `set_account_settings` | Signature + style preferences |
| `list_emails` / `search_emails` / `read_email` / `read_attachment` | Browse and read |
| `get_new_emails` | Pull new inbox mail since last checkpoint |
| `send_email` / `draft_email` / `edit_draft` / `send_draft` | Compose (Markdown bodies) |
| `archive_email` / `trash_email` / `move_email` / `mark_read` / `mark_unread` | Organize |
| `list_folders` / `create_folder` / `delete_folder` / `rename_folder` | Folders |

## Pull new emails

`get_new_emails` replaces server-side push. Agents or harnesses call it on their own schedule (for example every 30–60 seconds). First call per account initializes the checkpoint and returns no messages. See [examples/hermes](examples/hermes).

## Add-account flows

### Outlook

1. `add_account({ provider: "outlook" })` → device code + verification URL
2. User completes sign-in in the browser
3. Poll `complete_add_account` until `status: "ready"`

### IMAP

Provide host/user/password (or app password) synchronously. If TCP/TLS succeeds but login fails, verify IMAP is enabled and credentials are correct.

### Gmail

Gmail uses OAuth authorization-code flow (Google rejects device-code for Gmail scopes).

1. `add_account({ provider: "gmail" })` → authorization URL
2. User grants access in the browser
3. Local installs can capture the loopback callback automatically; remote/hosted installs should paste the final redirect URL into `complete_add_account` as `authorizationResponse`

For hosted HTTP, set your own Google Web client and `XALLOR_GMAIL_REDIRECT_URI`.

## Security

- Run locally or on infrastructure you control.
- Account tokens/passwords are encrypted at rest with AES-256-GCM. Protect `XALLOR_KEY` and the data directory.
- Use `XALLOR_TOOLS_ENABLED` / `XALLOR_TOOLS_DISABLED` to shrink the tool surface.
- HTTP mode is not authenticated — put it behind a reverse proxy for any shared network.

## Project layout

```
src/
  cli.ts                 # entry + arg parsing
  server.ts              # MCP server (stdio + HTTP)
  config/                # env-only config loading
  store/                 # encrypted multi-account store
  providers/             # gmail, outlook, imap backends
  tools/                 # MCP tool handlers
```

## License

This project is released under the MIT License. The `LICENSE` file retains the original copyright notice and full MIT text from Mateo Tiedra.

See also [`NOTICE`](NOTICE) for attribution.

---

This project incorporates code from [Hypermail MCP](https://github.com/hypersimple-ch/hypermail-mcp), originally created by Mateo Tiedra and licensed under the MIT License.

TDQS

A3.5/5.0

Scored across 24 tools

Disambiguation4/5

Most tools have clearly distinct resource+action targets (folders, accounts, drafts, message actions). The main mild overlap is the read-side trio list_emails / get_new_emails / search_emails, where the boundaries are semantic (all vs unseen vs filtered) rather than structural, but descriptions make the intent clear enough.

Naming Consistency5/5

All 24 tools follow snake_case verb_noun form (list_accounts, create_folder, send_email, mark_read, edit_draft). No camelCase or stylistic mixing; even the draft family (draft_email, edit_draft, send_draft) reads consistently as verb+object.

Tool Count4/5

24 tools sits at the heavy end of the range, but the email domain genuinely branches into accounts, folders, reading, composition, and message actions, and each tool maps to a real distinct operation. Slightly over what an agent can scan comfortably, but nothing appears redundant.

Completeness4/5

Coverage is broad: account lifecycle (add/list/remove/settings), folder CRUD, read/search/list, compose/draft/edit/send, plus archive/trash/move/mark actions and attachment download. Minor gaps exist — no way to attach files when sending, no permanent delete/purge, and no thread-level view — but agents can work around these for most workflows.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues