使用说明
电子邮件分类MCP
Rust MCP服务器,通过后台终端模型命令对入站电子邮件进行分类,并可以选择将结果路由到任何webhook风格的API。
适合
是的,如果你的目标是将电子邮件分类作为可重用工具公开给Codex、Claude Desktop或任何其他MCP客户端,那么这应该是一个MCP服务器。
只有当你需要一个与一个产品的身份验证和清单模型绑定的特定于主机的集成界面时,插件才是更好的选择。对于本地或自托管的电子邮件工作流,MCP是更干净的架构。
它的作用
- 暴露
triage_email - 暴露
route_email - 暴露
build_generic_connector - 暴露
list_connector_defaults - 暴露
build_connector_flow - 暴露
run_connector_flow - 暴露
configure_triage_flow - 暴露
enqueue_email_batch - 暴露
process_queue - 暴露
get_queue_status - 通过外包进行分类
CLASSIFIER_COMMAND - 向任何HTTP端点发送可选路由有效负载
- 公开通用
imap和webhook传输加命名预设,如gmail,joplin,以及highlevel
连接器型号
预期的用户体验是用户用简单的英语描述工作流程,MCP客户端将其转换为流配置。
示例:
- “接收未读的Gmail邮件,并将支持线索推送到我的CRM中”
- “从billing@读取IMAP邮件,并将分流有效负载发送到此webhook”
- “使用Gmail作为来源,为任何紧急情况创建Joplin笔记”
服务器围绕以下内容构建:
- 通用运输:
imap,webhook - 命名预设:
gmail,joplin,crm,highlevel - 覆盖:文件夹名称、端点、笔记本ID、环境变量名称、路由回退
这使得内置连接器表面保持较小,同时仍然为AI提供了足够的结构来可靠地组装流量。
分类器模型
点 CLASSIFIER_COMMAND 在任何从stdin读取并在stdout上返回严格JSON的CLI上。
示例:
export CLASSIFIER_COMMAND='claude -p'
export CLASSIFIER_COMMAND='codex exec --json'
如果您的首选CLI需要标志、会话设置或提示包装,请使用shell脚本和点 CLASSIFIER_COMMAND 相反,在那个剧本上。
预期来自分类器的JSON
{
"category": "support",
"confidence": 0.94,
"summary": "Customer is reporting a failed login after password reset.",
"reasoning": "The email is requesting account help.",
"suggestedRoute": "helpdesk.auth",
"priority": "high",
"suggestedNextStep": "Create a support task and respond with password reset troubleshooting.",
"actionItems": [
"Open a support ticket",
"Assign to the authentication queue"
],
"contactHints": ["Existing customer", "Needs response today"],
"tags": ["auth", "login"]
}
允许的类别包括 sales, support, billing, spam, personal, urgent,以及 other.
允许的优先级为 low, medium, high,以及 urgent.
跑
cargo build
CLASSIFIER_COMMAND='claude -p' cargo run
Gmail到乔普林测试
先设置这些:
export CLASSIFIER_COMMAND='claude -p'
export GMAIL_EMAIL='you@gmail.com'
export GMAIL_APP_PASSWORD='your-app-password'
export JOPLIN_TOKEN='your-joplin-token'
Joplin应该在启用WebClipperneneneba API的情况下在本地运行。默认端点为 http://127.0.0.1:41184.
然后使用默认值构建模块化流:
{
"source": {
"kind": "imap",
"preset": "gmail",
"host": "imap.gmail.com",
"port": 993,
"folder": "INBOX",
"unreadOnly": true,
"maxEmails": 1,
"passwordEnv": "GMAIL_APP_PASSWORD"
},
"destination": {
"kind": "joplin",
"endpoint": "http://127.0.0.1:41184",
"tokenEnv": "JOPLIN_TOKEN",
"tag": "email-triage"
}
}
使用该对象 run_connector_flow。如果你想安全地通过第一关,那就设置 dryRun 到 true.
这里的设计目标是,客户端可以说“源是gmail,目标是joplin”,服务器会填写合理的默认值,同时仍然允许覆盖文件夹、笔记本ID、端点和标签。
Gmail高级示例
{
"source": {
"kind": "imap",
"preset": "gmail",
"passwordEnv": "GMAIL_APP_PASSWORD"
},
"destination": {
"kind": "webhook",
"preset": "highlevel",
"endpoint": "https://services.leadconnectorhq.com/email-triage",
"tokenEnv": "HIGHLEVEL_API_KEY"
},
"routeUnclassifiedTo": "crm.untriaged"
}
这仍然是下面的一个webhook传输。如果用户说“将其与行动项一起发送到我的HighLevel CRM”,人工智能应将HighLevel视为预设的起点,然后通过覆盖填写端点详细信息和有效载荷期望。
队列模式
对于生产使用,更喜欢面向队列的流,而不是单个大型流 run_connector_flow 呼叫:
build_connector_flowconfigure_triage_flowenqueue_email_batchprocess_queueget_queue_status
这使得MCP作为控制平面,而服务器则作为worker按顺序处理电子邮件作业。
MCP客户端示例
{
"mcpServers": {
"email-triage": {
"command": "/absolute/path/to/email-triage-mcp/target/debug/email-triage-mcp",
"env": {
"CLASSIFIER_COMMAND": "claude -p"
}
}
}
}
下一步
如果你想接收真实邮件,请在它前面为Gmail、IMAP、SES或Postmark添加一个单独的worker。将接收层放在MCP服务器之外,这样MCP表面就保持简单:分类、路由和返回结构化输出。