🧩 MCP生态

MCP 入门指南:别再手写 20 个工具适配器了

发布时间:2026-08-23 分类: MCP生态
摘要:MCP 入门指南:别再手写 20 个工具适配器了想让 AI Agent 接微信、飞书、Notion、MySQL,甚至你公司内部的 ERP API?先别急着写第 17 个 tool_call 封装函数——Anthropic 推出的 MCP(Model Context Protocol),就是为解决这类重复劳动而生。它不是新模型,也不是新框架,而是一个标准化的工具接入层:把 LLM 当作插线板,...

MCP 入门指南:别再手写 20 个工具适配器了

想让 AI Agent 接微信、飞书、Notion、MySQL,甚至你公司内部的 ERP API?先别急着写第 17 个 tool_call 封装函数——Anthropic 推出的 MCP(Model Context Protocol),就是为解决这类重复劳动而生。

它不是新模型,也不是新框架,而是一个标准化的工具接入层:把 LLM 当作插线板,MCP 就是那个兼容 USB-C、Type-A 和雷电 3 的万能转接头。你不用再维护 get_user_info_from_feishu()insert_row_to_notion_v3()query_erp_order_by_sn() 这类五花八门的函数——统一注册、统一描述、统一调用。

三笔账,算清为什么用 MCP

  • 开发成本:一个飞书机器人 + Notion 数据同步 + 邮件自动归档的 Agent,传统方式要写 3 套认证逻辑、4 种错误重试策略、5 类参数校验;用 MCP,你只写 1 个 server.yaml + 3 个 tool.json,其余由 MCP Server 处理。
  • 维护成本:飞书 API 升级到 v2.5?只需更新 feishu-server 的 Docker 镜像,所有接入它的 Agent 自动生效。
  • 复用成本:你在 yitb.com 上部署的 notion-mcp-server,别人 clone 后执行 docker run -p 3001:3000 notion-mcp-server,就能直接接入自己的 Claude Agent——零代码复用。

MCP 核心就两件事:发现 + 描述

1. Server Discovery(服务发现)

Agent 启动时向 http://localhost:3000/v1/servers 发 GET 请求,收到:

[
  {
    "id": "notion-2024",
    "name": "Notion CRM Sync",
    "description": "Read/write pages & databases via Notion API v1",
    "endpoint": "http://localhost:3001"
  }
]

2. Tool Schema(工具定义)

每个 Server 必须暴露 /tools 接口,返回标准 OpenAPI-like 描述:

{
  "tools": [
    {
      "name": "notion_append_to_database",
      "description": "Append a new row to specified Notion database",
      "input_schema": {
        "type": "object",
        "properties": {
          "database_id": {"type": "string", "description": "Notion database ID"},
          "properties": {"type": "object", "description": "Row properties as key-value"}
        },
        "required": ["database_id", "properties"]
      }
    }
  ]
}

LLM 不需要理解 Notion 的字段映射或签名规则,只要按 schema 填参数,MCP Server 负责签名、重试、限流和日志。

MCP 和 A2A:不是竞品,是搭档

常有人问:“MCP 和 A2A 啥关系?”
答:MCP 是‘手脚’,A2A 是‘神经’

  • ✅ MCP 管「Agent 怎么用工具」:对接数据库、发邮件、调支付网关——解决 how to act
  • ✅ A2A 管「Agent 怎么协作」:销售 Agent 把线索传给客服 Agent,再触发财务 Agent 开票——解决 who talks to whom

你搭一个销售漏斗 Agent:
→ 用 MCP 接入 HubSpot(获客)、Stripe(收款)、Slack(通知)
→ 用 A2A 让「线索质检 Agent」自动把高意向客户推给「人工跟进 Agent」
二者分层解耦:改工具不碰流程,调流程不改工具。

👉 Binance · OKX · Gate.io · HTX · Bitget

真实赚钱案例:Notion + 微信自动成交系统(已上线)

深圳一家 SaaS 培训机构用 MCP 实现「咨询→试听→付费→开课」全自动流转:

  • MCP Server:wechat-mcp-server(基于 WeCom API 封装)、notion-mcp-server(读写课程表/学员库)
  • Agent 流程:用户在微信发“试听”,Agent 解析意图 → 调 notion_search_student → 若无记录,调 notion_create_student + wechat_send_template 发预约链接 → 用户点击后,自动调 stripe_charge 并触发 notion_update_status
  • 结果:人力咨询岗从 3 人减至 0.5 人(仅处理异常),月均节省 4.2 万元;转化率提升 27%(响应 <8 秒 vs 原平均 47 分钟)
  • 可复制路径
    git clone https://github.com/yitb/mcp-wechat-server
    ② 填企业微信 Secret,docker build -t wx-mcp . && docker run -p 3002:3000 wx-mcp
    ③ 在 Claude 工具配置中添加 http://localhost:3002 → 即刻启用

下一步,30 分钟跑通你的第一个 MCP 工具

现在就开始:

  1. 打开终端,运行:

    curl -sL https://raw.githubusercontent.com/yitb/mcp-cli/main/install.sh | bash
    mcp init --template notion
    cd notion-mcp-server && npm install && npm start
  2. 访问 http://localhost:3001/tools,确认看到 notion_append_to_database 等工具定义
  3. yitb.com/agent-studio 新建 Agent,添加 MCP 工具源 http://localhost:3001,选一个工具测试调用

你刚完成的不是 Demo,是生产就绪的工具接入起点。MCP 不制造 AI,它让 AI 真正开始干活。

💡 提示:yitb.com 已上线 12 个开箱即用 MCP Server(含飞书、钉钉、MySQL、Airtable),全部带源码和 Dockerfile。访问 yitb.com/mcp 获取一键部署脚本与商业级监控模板。
返回首页