MCP Email Server
An HTTP streaming MCP server for sending emails via Gmail using nodemailer, supporting HTML content and CC/BCC recipients.
README
MCP Email Server (HTTP Streaming)
This is a test service. To ensure security, enable authentication.
An HTTP streaming MCP (Model Context Protocol) server for sending emails via Gmail. Deployable to Cloud Foundry or any Node.js hosting platform.
Features
- HTTP streaming transport for remote MCP connections
- MCP tool:
send_emailfor sending emails - Support for To, CC, and BCC recipients
- HTML body support
- Cloud Foundry ready
- Health check endpoint
Prerequisites
- Node.js 22.x or higher
- Gmail account with App Password enabled
- Cloud Foundry CLI (for CF deployment)
Gmail Setup
To use this server, you need to generate a Gmail App Password:
- Go to your Google Account settings
- Navigate to Security → 2-Step Verification
- Scroll down to "App passwords"
- Generate a new app password for "Mail"
- Save the 16-character password
Installation
npm install
Local Development
- Set environment variables:
export GMAIL_USER=your-email@gmail.com
export GMAIL_PASSWORD=your-app-password
export PORT=3000
- Start the server:
npm start
The server will start on port 3000 (or PORT environment variable).
Endpoints:
- Health check:
http://localhost:3000/health - MCP endpoint:
http://localhost:3000/mcp
Cloud Foundry Deployment
- Log in to Cloud Foundry:
cf login
- Set environment variables:
cf set-env mcp-email-server GMAIL_USER your-email@gmail.com
cf set-env mcp-email-server GMAIL_PASSWORD your-app-password
- Push the application:
cf push
- Get your app URL:
cf app mcp-email-server
Your MCP server will be available at: https://your-app.cfapps.io/mcp
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"email": {
"transport": "http",
"url": "https://your-app.cfapps.io/mcp"
}
}
}
Claude Code CLI
Add to your MCP settings file (~/.claude/mcp_settings.json):
{
"mcpServers": {
"email": {
"transport": "http",
"url": "https://your-app.cfapps.io/mcp"
}
}
}
Custom MCP Client
Send POST requests to the MCP endpoint:
const response = await fetch('https://your-app.cfapps.io/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
})
});
MCP Tool Usage
send_email
Send an email via Gmail with HTML support.
Required Parameters:
to(string): Recipient email address (comma-separated for multiple)subject(string): Email subject linebody(string): Email body (HTML supported)
Optional Parameters:
cc(string): CC recipients (comma-separated)bcc(string): BCC recipients (comma-separated)
Example Usage in Claude:
Send an email to john@example.com with subject "Meeting Tomorrow" and body "<h1>Reminder</h1><p>Don't forget our meeting at 2pm!</p>"
Claude will use the send_email tool to send the email through your deployed server.
API Endpoints
GET /health
Health check endpoint
Response:
{
"status": "ok",
"service": "mcp-email-server",
"gmail_configured": true
}
POST /mcp
HTTP streaming endpoint for MCP protocol communication
This is the main endpoint that MCP clients connect to.
Request format:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
Tool Schema
{
"name": "send_email",
"description": "Send an email via Gmail. Supports HTML content in the body and optional CC/BCC recipients.",
"inputSchema": {
"type": "object",
"properties": {
"to": {
"type": "string",
"description": "Recipient email address"
},
"subject": {
"type": "string",
"description": "Email subject line"
},
"body": {
"type": "string",
"description": "Email body content (HTML is supported)"
},
"cc": {
"type": "string",
"description": "CC recipients (comma-separated)"
},
"bcc": {
"type": "string",
"description": "BCC recipients (comma-separated)"
}
},
"required": ["to", "subject", "body"]
}
}
Testing
Test the health endpoint:
curl https://your-app.cfapps.io/health
Test listing tools:
curl -X POST https://your-app.cfapps.io/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}'
Test sending an email:
curl -X POST https://your-app.cfapps.io/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "send_email",
"arguments": {
"to": "recipient@example.com",
"subject": "Test Email",
"body": "<h1>Hello</h1><p>This is a test email.</p>"
}
}
}'
Security Notes
- Never commit your Gmail credentials to version control
- Use Gmail App Passwords, not your regular password
- Store credentials as environment variables in Cloud Foundry
- Consider adding authentication/authorization for production use
- Add rate limiting to prevent abuse
- Use HTTPS in production (automatic with Cloud Foundry)
Architecture
The server uses:
- Express - HTTP server
- @modelcontextprotocol/sdk - MCP protocol implementation
- nodemailer - Email sending functionality
- HTTP streaming - For MCP communication via POST requests
Troubleshooting
Authentication Errors
- Ensure 2-Step Verification is enabled on your Gmail account
- Generate a new App Password specifically for this application
- Verify environment variables:
cf env mcp-email-server
Connection Issues
- Verify the app is running:
cf app mcp-email-server - Check logs:
cf logs mcp-email-server --recent - Test the health endpoint
Email Not Sending
- Check Cloud Foundry logs for errors
- Verify Gmail credentials are correct
- Ensure recipient addresses are valid
Monitoring
View logs:
cf logs mcp-email-server
View recent logs:
cf logs mcp-email-server --recent
Restart the app:
cf restart mcp-email-server
Scaling
Scale instances:
cf scale mcp-email-server -i 2
Scale memory:
cf scale mcp-email-server -m 512M
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。