notifications-mcp
notifications-mcp
统一通知 MCP 服务器 — 第一阶段:Gmail 通过模型上下文协议从任何 AI 代理(Claude、LangGraph、GPT)发送电子邮件警报。
功能说明
此 MCP 服务器暴露了一个 mail_send 工具,任何兼容 MCP 的 AI 代理都可以调用它通过 Gmail 发送电子邮件。
使用场景: 工厂机器停止工作 → 你的 AI 监控代理调用 mail_send → 经理、技术人员和员工立即收到警报邮件。
Machine stops → AI Agent → mail_send tool → Gmail → Manager + Technician notifiedMCP 端点: http://localhost:8100/mcp
架构
notifications-mcp/
├── src/
│ ├── server.py ← Entrypoint (Streamable HTTP + OAuth routes)
│ ├── config.py ← Loads config.yaml
│ ├── registry.py ← Dynamically loads channel tools
│ └── channels/
│ ├── mail/ ← Gmail channel (Phase 1)
│ ├── teams/ ← Microsoft Teams (Phase 2 placeholder)
│ └── sms/ ← SMS via Twilio (Phase 3 placeholder)要添加新通道:创建 channels/<name>/tools.py,其中包含一个 register(mcp, cfg) 函数,将通道名称添加到 config.yaml 的 enabled_channels 中。无需更改其他文件。
设置
1. 前提条件
Python 3.11+
一个启用了 Gmail API 的 Google Cloud 项目
2. Google Cloud 设置
为你的项目启用 Gmail API
前往 API 和服务 → 凭据 → 创建凭据 → OAuth 2.0 客户端 ID
应用程序类型:Web 应用程序
添加授权重定向 URI:
http://localhost:8100/auth/gmail/callback下载 JSON → 保存为
credentials/google_credentials.json
3. 安装依赖
pip install -r requirements.txt
# or for development:
pip install -e ".[dev]"4. 启动服务器
python -m src.server你会看到:
{"level": "INFO", "message": "Starting notifications-mcp | host=0.0.0.0 | port=8100"}
{"level": "INFO", "message": "MCP endpoint → http://localhost:8100/mcp"}
{"level": "INFO", "message": "Gmail OAuth → http://localhost:8100/auth/gmail/start"}5. 验证 Gmail(仅首次)
打开浏览器并访问:
http://localhost:8100/auth/gmail/start你将被重定向到 Google 的同意页面
使用你要发送邮件的 Gmail 账户登录
授予“发送邮件”权限
你会看到 ✅ Gmail 已验证!— 关闭标签页
令牌已保存到
credentials/gmail_token.json,此后会自动静默刷新
使用 mail_send 工具
从 MCP Inspector(测试)
npx @modelcontextprotocol/inspector http://localhost:8100/mcp调用 mail_send,参数如下:
{
"to": ["manager@yourcompany.com", "technician@yourcompany.com"],
"subject": "ALERT: Machine #3 stopped",
"body": "Machine #3 on Floor B stopped at 18:02.\nError code: E-404.\nPlease investigate immediately."
}从 AI 代理(Claude / LangGraph)
代理会看到此工具描述:
mail_send — 通过 Gmail 向一个或多个收件人发送电子邮件。对于工厂机器停机警报,请包含机器名称、位置、停机时间和错误代码。
代理调用方式如下:
result = await client.call_tool("mail_send", {
"to": ["manager@factory.com", "tech@factory.com"],
"subject": "ALERT: Machine #3 stopped",
"body": "Machine #3 stopped at 18:02. Error: E-404. Location: Floor B, Line 2."
})从 Antigravity / Claude Desktop
添加到你的 MCP 配置:
{
"mcpServers": {
"notifications": {
"url": "http://localhost:8100/mcp"
}
}
}工具参考
mail_send
通过 Gmail 向一个或多个收件人发送电子邮件。
参数 | 类型 | 必需 | 描述 |
|
| ✅ | 收件人电子邮件地址列表 |
|
| ✅ | 电子邮件主题行 |
|
| ✅ | 电子邮件正文(纯文本) |
|
| ❌ | 抄送收件人 |
|
| ❌ | 密送收件人 |
成功时返回:
{"status": "sent", "message_id": "18b3c...", "recipients": ["manager@co.com"]}失败时返回:
{"status": "failed", "error": "rate_limited", "message": "Gmail rate limit hit. Wait 60s."}配置
编辑 config.yaml 以更改设置:
server:
host: "0.0.0.0"
port: 8100 # Change port here
enabled_channels:
- mail # Add 'teams' or 'sms' here in Phase 2/3
channels:
mail:
credentials_path: "credentials/google_credentials.json"
token_path: "credentials/gmail_token.json"
scopes:
- "https://www.googleapis.com/auth/gmail.send"
oauth_redirect_uri: "http://localhost:8100/auth/gmail/callback"运行测试
pytest tests/ -v预期输出:
tests/channels/mail/test_tools.py::test_mail_send_success PASSED
tests/channels/mail/test_tools.py::test_mail_send_not_authenticated PASSED
tests/channels/mail/test_tools.py::test_mail_send_rate_limited PASSED
tests/channels/mail/test_tools.py::test_mail_send_missing_to_field PASSED
tests/channels/mail/test_tools.py::test_mail_send_missing_subject PASSED
tests/channels/mail/test_tools.py::test_mail_send_multiple_recipients PASSED
tests/channels/mail/test_tools.py::test_mail_send_with_cc_bcc PASSED添加第二阶段(Teams)或第三阶段(短信)
创建通道文件夹:
src/channels/teams/__init__.py src/channels/teams/auth.py src/channels/teams/client.py src/channels/teams/schemas.py src/channels/teams/tools.py ← must have def register(mcp, cfg)添加到
config.yaml:enabled_channels: - mail - teams ← add this channels: teams: tenant_id: "..." client_id: "..."完成。
server.py和registry.py无需任何更改。
安全说明
credentials/已被 gitignore — 切勿提交 Google 凭据OAuth 令牌自动静默刷新 — 你只需同意一次
服务器在 localhost 上运行 — 默认不暴露于互联网
本地使用无需 API 密钥
第一阶段:Gmail ✅ | 第二阶段:Teams 🔜 | 第三阶段:短信 🔜
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Phone, SMS & email for AI agents — one remote MCP endpoint, OAuth login, zero install.
Push notifications for AI agents - send instant iPhone notifications from any MCP client.
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Manojbonthu/Custom_MCP_Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server