MCP 入門指南:別再手寫 20 個(gè)工具適配器了
MCP 入門指南:別再手寫 20 個(gè)工具適配器了
想讓 AI Agent 接微信、飛書、Notion、MySQL,甚至你公司內(nèi)部的 ERP API?先別急著寫第 17 個(gè) tool_call 封裝函數(shù)——Anthropic 推出的 MCP(Model Context Protocol),就是為解決這類重復(fù)勞動(dòng)而生。
它不是新模型,也不是新框架,而是一個(gè)標(biāo)準(zhǔn)化的工具接入層:把 LLM 當(dāng)作插線板,MCP 就是那個(gè)兼容 USB-C、Type-A 和雷電 3 的萬(wàn)能轉(zhuǎn)接頭。你不用再維護(hù) get_user_info_from_feishu()、insert_row_to_notion_v3()、query_erp_order_by_sn() 這類五花八門的函數(shù)——統(tǒng)一注冊(cè)、統(tǒng)一描述、統(tǒng)一調(diào)用。
三筆賬,算清為什么用 MCP
- 開(kāi)發(fā)成本:一個(gè)飛書機(jī)器人 + Notion 數(shù)據(jù)同步 + 郵件自動(dòng)歸檔的 Agent,傳統(tǒng)方式要寫 3 套認(rèn)證邏輯、4 種錯(cuò)誤重試策略、5 類參數(shù)校驗(yàn);用 MCP,你只寫 1 個(gè)
server.yaml+ 3 個(gè)tool.json,其余由 MCP Server 處理。 - 維護(hù)成本:飛書 API 升級(jí)到 v2.5?只需更新
feishu-server的 Docker 鏡像,所有接入它的 Agent 自動(dòng)生效。 - 復(fù)用成本:你在 m.yzybsl.com 上部署的
notion-mcp-server,別人 clone 后執(zhí)行docker run -p 3001:3000 notion-mcp-server,就能直接接入自己的 Claude Agent——零代碼復(fù)用。
MCP 核心就兩件事:發(fā)現(xiàn) + 描述
1. Server Discovery(服務(wù)發(fā)現(xiàn))
Agent 啟動(dòng)時(shí)向 http://localhost:3000/v1/servers 發(fā) GET 請(qǐng)求,收到:
[
{
"id": "notion-2024",
"name": "Notion CRM Sync",
"description": "Read/write pages & databases via Notion API v1",
"endpoint": "http://localhost:3001"
}
]2. Tool Schema(工具定義)
每個(gè) Server 必須暴露 /tools 接口,返回標(biāo)準(zhǔn) 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 的字段映射或簽名規(guī)則,只要按 schema 填參數(shù),MCP Server 負(fù)責(zé)簽名、重試、限流和日志。
MCP 和 A2A:不是競(jìng)品,是搭檔
常有人問(wèn):“MCP 和 A2A 啥關(guān)系?”
答:MCP 是‘手腳’,A2A 是‘神經(jīng)’。
- ? MCP 管「Agent 怎么用工具」:對(duì)接數(shù)據(jù)庫(kù)、發(fā)郵件、調(diào)支付網(wǎng)關(guān)——解決 how to act
- ? A2A 管「Agent 怎么協(xié)作」:銷售 Agent 把線索傳給客服 Agent,再觸發(fā)財(cái)務(wù) Agent 開(kāi)票——解決 who talks to whom
你搭一個(gè)銷售漏斗 Agent:
→ 用 MCP 接入 HubSpot(獲客)、Stripe(收款)、Slack(通知)
→ 用 A2A 讓「線索質(zhì)檢 Agent」自動(dòng)把高意向客戶推給「人工跟進(jìn) Agent」
二者分層解耦:改工具不碰流程,調(diào)流程不改工具。
?? Binance · OKX · Gate.io · HTX · Bitget
真實(shí)賺錢案例:Notion + 微信自動(dòng)成交系統(tǒng)(已上線)
深圳一家 SaaS 培訓(xùn)機(jī)構(gòu)用 MCP 實(shí)現(xiàn)「咨詢→試聽(tīng)→付費(fèi)→開(kāi)課」全自動(dòng)流轉(zhuǎn):
- MCP Server:
wechat-mcp-server(基于 WeCom API 封裝)、notion-mcp-server(讀寫課程表/學(xué)員庫(kù)) - Agent 流程:用戶在微信發(fā)“試聽(tīng)”,Agent 解析意圖 → 調(diào)
notion_search_student→ 若無(wú)記錄,調(diào)notion_create_student+wechat_send_template發(fā)預(yù)約鏈接 → 用戶點(diǎn)擊后,自動(dòng)調(diào)stripe_charge并觸發(fā)notion_update_status - 結(jié)果:人力咨詢崗從 3 人減至 0.5 人(僅處理異常),月均節(jié)省 4.2 萬(wàn)元;轉(zhuǎn)化率提升 27%(響應(yīng) <8 秒 vs 原平均 47 分鐘)
- 可復(fù)制路徑:
①git clone https://github.com/yitb/mcp-wechat-server
② 填企業(yè)微信 Secret,docker build -t wx-mcp . && docker run -p 3002:3000 wx-mcp
③ 在 Claude 工具配置中添加http://localhost:3002→ 即刻啟用
下一步,30 分鐘跑通你的第一個(gè) MCP 工具
現(xiàn)在就開(kāi)始:
打開(kāi)終端,運(yùn)行:
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- 訪問(wèn)
http://localhost:3001/tools,確認(rèn)看到notion_append_to_database等工具定義 - 在 m.yzybsl.com/agent-studio 新建 Agent,添加 MCP 工具源
http://localhost:3001,選一個(gè)工具測(cè)試調(diào)用
你剛完成的不是 Demo,是生產(chǎn)就緒的工具接入起點(diǎn)。MCP 不制造 AI,它讓 AI 真正開(kāi)始干活。
?? 提示:m.yzybsl.com 已上線 12 個(gè)開(kāi)箱即用 MCP Server(含飛書、釘釘、MySQL、Airtable),全部帶源碼和 Dockerfile。訪問(wèn) m.yzybsl.com/mcp 獲取一鍵部署腳本與商業(yè)級(jí)監(jiān)控模板。