airun-mailbox-mcp
A read-only Model Context Protocol server that lets AI assistants (Claude Code, Claude Desktop, any MCP client) read an Exchange Online mailbox. It authenticates as an Entra ID application (OAuth client credentials) and talks to Exchange Online over IMAP with XOAUTH2, so no user sign-in is needed.
Folders are opened with EXAMINE and messages are fetched with BODY.PEEK, so the
server never changes the mailbox: it doesn't mark messages as read, move them or delete them.
Tools
| Tool | Purpose |
|---|---|
list_folders |
All folders (Inbox, Sent Items, subfolders, ...) |
list_messages(folder, limit, offset, unread_only) |
Header summaries, newest first, with paging (up to 50 per call) |
search_messages(folder, text, sender, recipient, subject, body, since, before, unread_only, limit) |
IMAP SEARCH; dates are YYYY-MM-DD; non-ASCII text is supported |
get_message(uid, folder, max_chars) |
Headers, readable body (HTML is converted to text) and the attachment list |
Prerequisites (Entra ID / Exchange admin)
-
Register an app in Entra ID and create a client secret.
-
Add the Office 365 Exchange Online → IMAP.AccessAsApp application permission and grant admin consent.
-
In Exchange Online PowerShell, register the app's service principal and give it access to the mailbox:
New-ServicePrincipal -AppId <CLIENT_ID> -ObjectId <ENTERPRISE_APP_OBJECT_ID> Add-MailboxPermission -Identity <MAILBOX_UPN> -User <ENTERPRISE_APP_OBJECT_ID> -AccessRights FullAccess
-
Make sure IMAP is enabled for that mailbox.
See Microsoft's guide: Authenticate an IMAP, POP or SMTP connection using OAuth.
Configuration
| Variable | Description |
|---|---|
TENANT_ID |
Entra ID tenant (directory) ID |
CLIENT_ID |
Application (client) ID |
CLIENT_SECRET |
Client secret value |
MAILBOX_UPN |
Mailbox to read, e.g. support@example.com |
Install and run
uvx airun-mailbox-mcp # run without installing (recommended)
pip install airun-mailbox-mcp # or install into an environment
airun-mailbox-mcp --transport streamable-http --port 8000 # HTTP at http://127.0.0.1:8000/mcp
stdio is the default transport. The streamable-http transport has no authentication, so bind it only to localhost or put it behind an authenticating proxy.
Claude Code
claude mcp add airun-mailbox --scope user \
-e TENANT_ID=... -e CLIENT_ID=... -e CLIENT_SECRET=... -e MAILBOX_UPN=... \
-- uvx airun-mailbox-mcp
To keep the secret out of ~/.claude.json, store the variables in a chmod 600 env file
(see .env.example) and use -- uvx --env-file /path/to/.env airun-mailbox-mcp instead.
Claude Desktop / other MCP clients
{
"mcpServers": {
"airun-mailbox": {
"command": "uvx",
"args": ["airun-mailbox-mcp"],
"env": {
"TENANT_ID": "...",
"CLIENT_ID": "...",
"CLIENT_SECRET": "...",
"MAILBOX_UPN": "support@example.com"
}
}
}
}
Command-line helper
airun-fetch-messages [--mailbox UPN] [--limit 1-10] prints the newest Inbox messages
as JSON. You can use it to check the credentials before you set up an MCP client.
Security notes
- An app with
IMAP.AccessAsAppcan read every mailbox it has been granted access to. GrantFullAccessonly on the mailboxes you need. - Email content is untrusted input. The server tells clients not to follow instructions found in messages, but treat what the model reads with care.
- Never commit secrets.
.envis ignored by git and is not included in the package.
Development
uv sync
uv run pytest
uv build
License
MIT
Metadata
Release files for airun-mailbox-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| airun_mailbox_mcp-0.1.0.tar.gz | 12.3 kB | Without provenance | Details for airun_mailbox_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| airun_mailbox_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for airun_mailbox_mcp-0.1.0-py3-none-any.whl |
Total release size: 25.6 kB
Release files / airun_mailbox_mcp-0.1.0.tar.gz
| Download URL | airun_mailbox_mcp-0.1.0.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e067416b637a01899a5243b7c1116ab8b7378f28513b04b7d91da09dd49ebc8
|
|
BLAKE2b-256 checksum How to use checksums |
56f67256e850ed0ff497dec5170bc9d9ebe9e54da5a381aa4bb9871445a1b6f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / airun_mailbox_mcp-0.1.0-py3-none-any.whl
| Download URL | airun_mailbox_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3eea4e8ddb25db4e54545d816c9669cdc7fdbec7071082f49935a64d30e6c792
|
|
BLAKE2b-256 checksum How to use checksums |
319abae0a09bcd785f409d6f05a6e804a861be881aa3a6cac064da75bcdb6f5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for airun-mailbox-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.