MCP Email Server
Enables LLMs to read, send, and manage emails via POP3 and SMTP with TLS support.
README
MCP Email Server
A Model Context Protocol (MCP) server for email operations (POP3/SMTP with TLS). Allows an LLM like Claude to read, send, and manage emails.
Quick Start
Option 1: uvx (recommended)
No clone, no install — runs directly from GitHub:
uvx git+https://github.com/ptbsare/email-mcp-server \
--email-user you@example.com \
--email-pass yourpassword \
--pop3-server pop.example.com \
--smtp-server smtp.example.com
First run caches the package; subsequent launches are instant.
Option 2: Clone + run locally
git clone https://github.com/ptbsare/email-mcp-server
cd email-mcp-server
uv pip install -e .
uv run main.py --email-user you@example.com --email-pass yourpassword \
--pop3-server pop.example.com --smtp-server smtp.example.com
Option 3: .env file
Create a .env file in the working directory:
EMAIL_USER=you@example.com
EMAIL_PASS=yourpassword
POP3_SERVER=pop.example.com
SMTP_SERVER=smtp.example.com
Then simply:
uvx git+https://github.com/ptbsare/email-mcp-server
# or
uv run main.py
Configuration
Config Priority (highest → lowest)
- CLI arguments — override everything
- Environment variables — override
.envfile .envfile — fallback defaults
All Config Options
| CLI Argument | Env Variable | Required | Default | Description |
|---|---|---|---|---|
--email-user |
EMAIL_USER |
✅ | — | Email address |
--email-pass |
EMAIL_PASS |
✅ | — | Email password / app password |
--pop3-server |
POP3_SERVER |
✅ | — | POP3 server hostname |
--pop3-port |
POP3_PORT |
995 |
POP3 SSL port | |
--smtp-server |
SMTP_SERVER |
✅ | — | SMTP server hostname |
--smtp-port |
SMTP_PORT |
587 |
SMTP port (auto 465 if --smtp-use-ssl) |
|
--smtp-use-ssl |
SMTP_USE_SSL |
false |
Use SMTP_SSL (port 465) instead of STARTTLS | |
--log-level |
LOG_LEVEL |
INFO |
Logging: DEBUG / INFO / WARNING / ERROR |
Examples: Mixing Config Sources
# CLI args only (no .env needed):
uv run main.py --email-user me@gmail.com --email-pass xxx \
--pop3-server pop.gmail.com --smtp-server smtp.gmail.com
# .env file for credentials, CLI for servers:
# .env: EMAIL_USER=me@gmail.com / EMAIL_PASS=xxx
uv run main.py --pop3-server pop.gmail.com --smtp-server smtp.gmail.com
# Env vars override .env:
EMAIL_USER=other@gmail.com uv run main.py --pop3-server pop.gmail.com ...
Using with Claude Desktop
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
With env vars (in config):
{
"mcpServers": {
"email-mcp-server": {
"command": "uvx",
"args": ["git+https://github.com/ptbsare/email-mcp-server"],
"env": {
"EMAIL_USER": "your-email@example.com",
"EMAIL_PASS": "your-app-password",
"POP3_SERVER": "pop.example.com",
"SMTP_SERVER": "smtp.example.com"
}
}
}
}
With CLI args (in config):
{
"mcpServers": {
"email-mcp-server": {
"command": "uvx",
"args": [
"git+https://github.com/ptbsare/email-mcp-server",
"--email-user", "your-email@example.com",
"--email-pass", "your-app-password",
"--pop3-server", "pop.example.com",
"--smtp-server", "smtp.example.com"
]
}
}
}
Tip: The
envsection and CLI args can be used together. CLI args always take priority.
Features
- Poll Emails: List inbox email headers with configurable limit (
pollEmails) - Fetch Full Emails: Get complete email content by ID, with automatic attachment extraction (
getEmailsById) - Delete Emails: Remove emails by ID (
deleteEmailsById) - Send Emails: Send plain text (
sendTextEmail) or HTML (sendHtmlEmail) emails with optional file attachments - Secure Connections: POP3 over SSL (port 995), SMTP with STARTTLS (port 587) or direct SSL (port 465)
- Attachment Support: Send local files as attachments; received attachments are auto-saved to
/tmp/email_mcp_attachments/<email_id>/
Tools
pollEmails(limit=50)
List recent email headers (no body). Returns newest first. Use this first to get IDs for getEmailsById/deleteEmailsById.
| Parameter | Type | Default | Description |
|---|---|---|---|
limit |
int |
50 |
Max emails to return, newest first |
Returns: [{"id": int, "Subject": str, "From": str, "Date": str, "Message-ID": str}]
pollEmails(limit=10) # 10 most recent
pollEmails() # default 50
getEmailsById(ids)
Fetch full email content (headers + body) by IDs from pollEmails. Attachments auto-saved to /tmp/email_mcp_attachments/<id>/.
| Parameter | Type | Required | Description |
|---|---|---|---|
ids |
list[int] |
✅ | Email IDs from pollEmails(). Example: [1, 3, 5] |
Returns: [{"id": int, "headers": dict, "body": str, "attachments": [{"filename": str, "local_path": str, "size": int, "content_type": str}]}]
getEmailsById(ids=[1, 3, 5])
deleteEmailsById(ids)
Permanently delete emails by IDs. Irreversible. Call pollEmails first.
| Parameter | Type | Required | Description |
|---|---|---|---|
ids |
list[int] |
✅ | Email IDs from pollEmails(). Example: [1, 2, 3] |
Returns: {"deleted": [int], "failed": {"id": "error msg"}}
deleteEmailsById(ids=[1, 2, 3])
sendTextEmail(toAddresses, subject, body, attachments=None)
Send a plain text email. Attachments: list of local file paths like ["/tmp/file.pdf"].
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
toAddresses |
list[str] |
✅ | — | Recipients. Example: ["alice@example.com"] |
subject |
str |
✅ | — | Subject line |
body |
str |
✅ | — | Plain text body |
attachments |
list[str] |
None |
Local file paths. Example: ["/tmp/report.pdf"] |
Returns: {"status": "success"}
sendTextEmail(
toAddresses=["alice@example.com"],
subject="Hello",
body="Hi Alice!",
attachments=["/tmp/report.pdf"]
)
sendHtmlEmail(toAddresses, subject, body, attachments=None)
Send an HTML email. Attachments: list of local file paths like ["/tmp/file.png"].
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
toAddresses |
list[str] |
✅ | — | Recipients. Example: ["alice@example.com"] |
subject |
str |
✅ | — | Subject line |
body |
str |
✅ | — | HTML content. Example: "<h1>Hi</h1><p>Hello!</p>" |
attachments |
list[str] |
None |
Local file paths. Example: ["/tmp/chart.png"] |
Returns: {"status": "success"}
sendHtmlEmail(
toAddresses=["alice@example.com"],
subject="Report",
body="<h1>Report</h1><p>Sales up <b>20%</b>.</p>",
attachments=["/tmp/chart.png"]
)
Development Setup
Prerequisites
- Python 3.12+
- uv
Steps
git clone https://github.com/ptbsare/email-mcp-server
cd email-mcp-server
uv pip install -e .
uv run main.py --help
Important Notes
- App Passwords: If your email provider uses 2FA, generate an App Password for
EMAIL_PASS - Email IDs: POP3 IDs are session-specific. Call
pollEmails()beforegetEmailsById()ordeleteEmailsById() - Attachment Storage: Received attachments are saved to
/tmp/email_mcp_attachments/<email_id>/ - Security: Never commit your
.envfile — it's already in.gitignore - Config Priority: CLI args > environment variables >
.envfile
Project Structure
email-mcp-server/
├── main.py # MCP server entry point (all logic)
├── pyproject.toml # Package config & dependencies
├── uv.lock # Dependency lock file
├── .env # Credentials (create your own)
├── .gitignore
└── README.md
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。