MCP server that connects AI agents to IMAP
Project description
Emancipation MCP Server
emancipation is a MCP server that lets AI agents read IMAP mailboxes
and send plain-text emails over SMTP.
Features
- No external dependencies besides the MCP SDK
- MCP server over stdio
- IMAP mailbox listing, search, message listing, and message retrieval
- SMTP plain-text email sending with optional
cc,bcc, andreply_to - TLS/SSL options for both IMAP and SMTP transports
- Environment-variable configuration for runtime credentials and behavior
Requirements
- Python 3.11+
- IMAP server credentials
- SMTP server credentials
Installation
pip install emancipation
Running the server
Transport is a positional argument and defaults to stdio.
emancipation
This starts the MCP server over stdio (same as emancipation stdio).
For SSE transport:
emancipation sse --host 127.0.0.1 --port 8143
For streamable HTTP transport:
emancipation streamable-http --host 127.0.0.1 --port 8143
Network transports (sse, streamable-http) support:
--host(optional, default:127.0.0.1)--port(optional, default:8143)
Equivalent invocation patterns:
emancipation [stdio]
emancipation sse [--host HOST] [--port PORT]
emancipation streamable-http [--host HOST] [--port PORT]
You can register multiple entries with different credentials and
SERVER_NAME values.
Agent Configuration
Example
Register the server in your MCP client configuration:
{
"mcpServers": {
"emancipation": {
"command": "emancipation",
"env": {
"SERVER_NAME": "mail-primary",
"IMAP_HOST": "imap.example.com",
"IMAP_PORT": "993",
"IMAP_TIMEOUT": "15",
"IMAP_USERNAME": "agent@example.com",
"IMAP_PASSWORD": "your-imap-password",
"IMAP_MAILBOX": "INBOX",
"IMAP_ENABLED": "true",
"SMTP_HOST": "smtp.example.com",
"SMTP_PORT": "587",
"SMTP_USERNAME": "agent@example.com",
"SMTP_PASSWORD": "your-smtp-password",
"SMTP_FROM": "agent@example.com",
"SMTP_ENABLED": "true",
"SMTP_TIMEOUT": "15",
"SMTP_USE_TLS": "true",
"SMTP_USE_SSL": "false"
}
}
}
}
Environment Variables
Set these environment variables to configure the server:
Global configuration:
SERVER_NAME(optional, default:emancipation)SERVER_LOG_LEVEL(optional, default:info; accepted values:debug,info,warning,error,critical)
For IMAP email access:
IMAP_ENABLED(optional, default:true; set tofalse,no, or0to disable IMAP tool export)IMAP_HOST(required)IMAP_PORT(optional, default:993)IMAP_TIMEOUT(optional, timeout in seconds; must be greater than0)IMAP_SESSION_TTL(optional, default:120; reuse IMAP connections for this many seconds; set to0to disable reuse and reconnect per call)IMAP_USERNAME(required)IMAP_PASSWORD(required)IMAP_MAILBOX(optional, default:INBOX)
For sending emails:
SMTP_ENABLED(optional, default:true; set tofalse,no, or0to disable SMTP tool export)SMTP_HOST(required)SMTP_PORT(optional, default:587;465when SSL is enabled)SMTP_TIMEOUT(optional, timeout in seconds; must be greater than0)SMTP_USERNAME(required)SMTP_PASSWORD(required)SMTP_FROM(required)SMTP_USE_TLS(optional, default:true)SMTP_USE_SSL(optional, default:false)
SMTP_USE_TLS and SMTP_USE_SSL cannot both be true.
IMAP_ENABLED and SMTP_ENABLED accept only true, yes, 1, false,
no, and 0; any other value raises a startup error.
About SERVER_NAME
SERVER_NAME sets the MCP server identity exposed to the client/LLM.
Common use cases:
- Run multiple
emancipationinstances at once, each with a different IMAP/SMTP account (for example:mail-primary,mail-finance,mail-support). - Make tool provenance clearer in multi-server setups, so logs and MCP UIs show which server handled each tool call.
- Separate environments (for example:
mail-stagingvsmail-production) while reusing the same binary and tool set.
If omitted, the server name defaults to emancipation.
Available MCP tools
emcp_list_mailboxes: list available mailboxesemcp_search_messages: search message IDs (query,limit,offset)emcp_list_messages: list message metadata (id,subject,sender,date) using query and pagingemcp_get_message: fetch one message by ID, with optional plain-text bodyemcp_send_email: send a plain-text email (to,subject,text_body) with optionalcc,bcc, andreply_toemcp_delete_message: mark one message as deleted (message_id, optionalmailbox, optionalexpunge)emcp_move_message: move one message to another mailbox (message_id,destination_mailbox, optionalsource_mailbox, optionalexpunge)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emancipation-0.1.0.tar.gz.
File metadata
- Download URL: emancipation-0.1.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba71b6dd240d7b417846ea535869c26b4e90d6228801ba9283c111af40fd7912
|
|
| MD5 |
80d5a49bc4258643773e0aa95c6ba6da
|
|
| BLAKE2b-256 |
eabec966bc72570ad65dc816409dcf8758bf1e54ba2b9b24a4354da50033925f
|
File details
Details for the file emancipation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: emancipation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.34.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be4a172523e89d6d7d6463985135b519914b9752b47a5ecb7da5f8be92364735
|
|
| MD5 |
d830f9282142ebd17bbb3f2a048ed576
|
|
| BLAKE2b-256 |
def663ad768d44866db35756f37e0eaa634193ba85829f3e5752e87134d295de
|