issue-collector
send_issue_email MCP
把用户转人工时留下的联系邮箱和问题描述,通过 SMTP 发到固定服务邮箱。
Agent 只看到一个工具:send_issue_email(email, question)。
三个邮箱分别是什么
角色 | 来源 | 用途 |
发件人 |
| 登录 SMTP 真正寄出的账号 |
收件人 |
| 你们固定用来收问题的服务邮箱 |
用户邮箱 | 工具参数 | 写入主题、正文,并设为 |
.env 是基础设施,部署一次即可。email / question 每次对话不同,由 Agent 从对话变量(如 $邮箱、$问题)传入。
Related MCP server: MCP Sendmail Server
环境要求
Python 3.10+
能访问所用 SMTP(本机直连 Gmail 需 465/587 出网)
安装
cd send_issue_email_mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env按下面说明填好 .env,不要把 .env 提交到仓库。
配置 .env
必填:收件与 SMTP
TARGET_EMAIL=issues@example.com
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_USERNAME=your_account@gmail.com
SMTP_PASSWORD=xxxx xxxx xxxx xxxx
SMTP_USE_SSL=true
SENDER_EMAIL=your_account@gmail.com
SENDER_NAME=问题收集机器人变量 | 说明 |
| 问题收件箱,必填 |
| SMTP 服务器 |
| 登录凭据。Gmail 必须用应用专用密码,不是登录密码 |
|
|
| 发件人,默认等于 |
| 发件显示名 |
Gmail 两套等效组合:
方式 |
|
|
SSL(推荐) |
|
|
STARTTLS |
|
|
Workspace / 学校 Google 账号可能被管理员关掉 SMTP,那种情况接不了。
MCP 传输(远程客户端)
智齿会对你填的 URL 根路径发 POST /,因此远程默认如下:
MCP_TRANSPORT=streamable-http
MCP_HOST=0.0.0.0
MCP_PORT=8765
MCP_PATH=/变量 | 说明 |
|
|
| 监听地址,远程填 |
| 监听端口。本机 |
| HTTP 端点路径。智齿必须是 |
改完 .env 后,若终端里已经 export 过同名变量,load_dotenv() 不会覆盖。新开终端,或先 unset MCP_TRANSPORT TARGET_EMAIL 再启动。
先验证发信(不启动 MCP)
source .venv/bin/activate
python test_email.py成功会打印:成功:问题已发送至服务邮箱 ...
脚本里的第一个参数是模拟用户联系邮箱,不是发件人。建议改成你自己的真实邮箱再测,避免 example.com 被收件方拦进垃圾箱。
SMTP 成功只代表邮局收下了信。若目标是企业飞书等邮箱,再查发件箱「已发送」、有无退信、对方垃圾箱/隔离。
启动 MCP(智齿 / 远程)
source .venv/bin/activate
python server.py日志里应出现类似:
transport 'streamable-http' (stateless) on http://0.0.0.0:8765/不要同时开两份,否则会 address already in use。需要重启时先停掉旧进程再启动。
智齿里填的 URL
传输类型选 Streamable HTTP / HTTP(不要选 SSE)。
URL 不要带 /sse 或 /mcp,填能打到这台机器的根地址:
http://<这台机器的可达地址>:<MCP_PORT>/例如局域网:http://192.168.x.x:8765/
智齿若是云端 SaaS,访问不到内网 IP。需要公网 IP、域名或隧道,URL 同样是根路径,不要加后缀。
保存后重新连接。服务日志应为 POST / HTTP/1.1" 200,而不是 404。
本机自检
curl -sS -X POST http://127.0.0.1:8765/ \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"check","version":"0.0.1"}}}'正常返回带 "jsonrpc":"2.0" 和 "serverInfo":{"name":"issue-collector"...} 的 JSON。
启动 MCP(本机 stdio)
.env 设 MCP_TRANSPORT=stdio 后,由 Cursor 等本地客户端用命令拉起,例如:
{
"mcpServers": {
"issue-collector": {
"command": "/绝对路径/send_issue_email_mcp/.venv/bin/python",
"args": ["/绝对路径/send_issue_email_mcp/server.py"]
}
}
}stdio 模式下不要把普通日志打到 stdout。
工具约定
send_issue_email(email: str, question: str) -> str
email:用户联系邮箱question:问题/诉求返回以
成功:或错误:开头的字符串,供 Agent 分支
邮件主题:[问题收集] 来自用户 {email} ({时间})
正文含用户邮箱、提交时间、问题描述;Reply-To 为用户邮箱。
send_message 成功后立即返回 MCP 结果,SMTP QUIT/关连接在后台线程进行,避免关 SSL 拖过智齿超时。
日志
执行日志写在项目下的 log/,按天一个文件,当天多次启动是追加:
log/2026-08-19.log含 HTTP 请求起止、工具调用、SMTP 连接/登录/发送耗时、后台关闭结果。不含 SMTP 密码。
排障
现象 | 原因 | 处理 |
智齿「服务响应格式异常」;日志 | 客户端 POST 根路径,服务却在 |
|
| 端口已被上一份 MCP 占用 | 停掉旧进程后再启动,不要同时开两份 |
日志 | URL 多写了 | 改成根路径 |
脚本仍发到旧 | 终端里已有旧环境变量, |
|
SMTP 成功但收件箱没有 | 进了垃圾箱/隔离,或看错了收件账号 | 查发件箱已发送、退信、对方垃圾箱 |
Gmail | 用了登录密码或未开两步验证 | 改用应用专用密码 |
load_dotenv() 在 server.py 启动时执行一次。只改 .env 不重启进程,运行中的服务不会读到新值。
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure as a service: mailboxes, domains, dedicated IPs, sending, deliverability.
Send transactional emails for AI agents via SMTP. Templates included.
Send transactional email over a verified domain — templates, attachments, custom headers.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables sending emails via SMTP with template management, supporting multiple SMTP configurations, template creation with variable substitution, and bulk email sending with rate limiting.6227 npm24MIT
- FlicenseNot gradedqualityDmaintenanceEnables sending emails via SMTP with support for HTML content, attachments, bulk sending, and template-based emails. Features session management and full MCP Streamable HTTP transport compliance.-
- AlicenseNot gradedqualityDmaintenanceEnables sending emails through SMTP using nodemailer, allowing AI assistants to send plain text and HTML emails with configurable SMTP credentials.25 npm2ISC
- AlicenseNot gradedqualityDmaintenanceEnables sending and receiving emails through SMTP, IMAP, and POP3 protocols with support for attachments, HTML content, and email validation.MIT