outlook-mail-mcp
<img src="assets/icon.svg" width="64" height="64" alt="">
# outlook-mail-mcp
Local, **read + draft only** MCP server for Outlook / Exchange via macOS `Mail.app`.
Works with work and school Microsoft 365 accounts even when your organization blocks third-party Entra ID / Microsoft Graph OAuth apps (*"Need admin approval"*), because authentication is handled natively by Apple Mail.
## Security Model
- **Pinned account:** Strictly scoped to a single `Mail.app` account (`MAIL_ACCOUNT`, default `Exchange`) — other accounts in `Mail.app` (Gmail, iCloud, etc.) cannot be accessed.
- **Read + Draft only:** No `send`, `delete`, or inbox-rule tools exist. Drafts are saved/opened in `Mail.app` for you to review and send manually.
- **No tokens on disk:** Zero OAuth tokens, client secrets, or `.env` credentials stored by this server.
- **Injection-safe bridge:** Calls `osascript -l JavaScript` via `execFile` (no shell) and passes all arguments as JSON via `argv`.
- **Prompt-injection hardening:** Strips invisible/bidi-override Unicode characters and wraps read email bodies in `=== BEGIN UNTRUSTED EMAIL CONTENT ===` markers.
## Prerequisites
- **macOS**
- **Node.js ≥ 20**
- Your Outlook/Exchange account signed into **Apple Mail** (`System Settings → Internet Accounts → Microsoft Exchange`)
## Setup
```bash
git clone https://github.com/YehorMaly/outlook-mail-mcp.git
cd outlook-mail-mcp
npm install
```
Find your exact `Mail.app` account name (usually `Exchange`):
```bash
npm run accounts
```
Verify the server works end-to-end:
```bash
MAIL_ACCOUNT="Exchange" npm test
```
## Client Configuration
### Claude Desktop
1. Run `which node` in Terminal to get your full Node binary path (e.g. `/opt/homebrew/bin/node` or `/usr/local/bin/node`). GUI apps on macOS often do not load `.zshrc`, so using the full path avoids `spawn node ENOENT`.
2. Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"outlook": {
"command": "/opt/homebrew/bin/node",
"args": ["/ABSOLUTE/PATH/TO/outlook-mail-mcp/src/index.js"],
"env": {
"MAIL_ACCOUNT": "Exchange"
}
}
}
}
```
3. Restart Claude Desktop and click **Allow** when macOS asks permission to control **Mail.app** (`System Settings → Privacy & Security → Automation`).
### Cursor / Antigravity / T3 Code
Add the same `mcpServers.outlook` block to:
- **Cursor:** `~/.cursor/mcp.json`
- **Antigravity:** `~/.gemini/config/mcp_config.json`
### Codex
Add to `~/.codex/config.toml`:
```toml
[mcp_servers.outlook]
command = "node"
args = ["/ABSOLUTE/PATH/TO/outlook-mail-mcp/src/index.js"]
[mcp_servers.outlook.env]
MAIL_ACCOUNT = "Exchange"
```
## Available Tools
| Tool | Description |
| --- | --- |
| `list_mailboxes` | List folders and message/unread counts in the configured account |
| `list_emails` | List recent emails (with pagination and `unread_only`) |
| `search_emails` | Search by query, sender, subject, date range, or body (`include_body`) |
| `read_email` | Read headers, attachment list, and sanitized plain-text body by ID |
| `create_draft` | Save a new draft in `Mail.app` (optionally opening the compose window) |
| `create_reply_draft` | Save a threaded reply / reply-all draft in `Mail.app` |
| `mark_as_read` | Mark a message read or unread |
## Limitations
- **macOS only** (requires `Mail.app` and `osascript`).
- **Plain-text drafts only** (Apple deprecated HTML scripting on `outgoing message` in `Mail.app`).
- **No attachment download/upload** yet (`read_email` lists attachment names, sizes, and MIME types).
- **Body search** (`include_body: true`) scans up to the 150 most recent candidate messages to stay within IPC timeouts.
## License
MIT
TDQS
Scored across 7 tools
Most tools target clearly distinct operations: listing mailboxes, listing emails, searching, reading one email, creating drafts (new vs. threaded reply), and toggling read state. The only mild overlap is between list_emails and search_emails, since both enumerate messages in a mailbox with unread filtering, but the query/sender/date parameters make search's purpose clear. An agent can reliably pick the right tool.
All names are snake_case with a leading verb (list_, search_, read_, create_, mark_) followed by a clear noun or object. The pattern is predictable and readable throughout, with create_draft vs. create_reply_draft cleanly disambiguated by the noun.
Seven tools is well-scoped for a read-and-draft email client. Each tool covers a distinct operation with no filler, and the surface stays small enough to reason about quickly.
Core workflows—discover folders, browse, search, read full content, draft new/reply messages, and manage read state—are all covered. Minor gaps remain: no move/archive/delete, no folder creation, and no attachment download (only listing), though the read-only-plus-drafts design suggests some omissions are intentional.