MCP 串接
透過 Model Context Protocol (MCP) 讓 Claude Desktop 直接存取群組資料。
什麼是 MCP?
Section titled “什麼是 MCP?”MCP 是 Anthropic 推出的開放協定,讓 AI 助手能安全地存取外部資料來源。透過 MCP 串接,你可以在 Claude Desktop 中直接:
- 查詢群組訊息
- 分析對話內容
- 搜尋歷史紀錄
- 產生摘要報告
1. 產生 API 金鑰
Section titled “1. 產生 API 金鑰”- 登入 Dashboard
- 前往「設定 > API 金鑰」
- 點擊「新增金鑰」
- 選擇權限:
read:messages、read:members - 複製產生的金鑰
2. 設定 Claude Desktop
Section titled “2. 設定 Claude Desktop”找到 Claude Desktop 設定檔:
| 作業系統 | 路徑 |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
加入以下設定:
{ "mcpServers": { "gm": { "url": "https://api.gm.kamigo.tw/mcp", "headers": { "Authorization": "Bearer YOUR_API_KEY" } } }}3. 重啟 Claude Desktop
Section titled “3. 重啟 Claude Desktop”儲存設定後,完全關閉並重新開啟 Claude Desktop。
4. 驗證連線
Section titled “4. 驗證連線”在 Claude 中輸入:
列出我的群組如果設定正確,Claude 會顯示你的群組列表。
MCP Tools
Section titled “MCP Tools”list_channels
Section titled “list_channels”列出所有可存取的群組。
回傳
{ "channels": [ { "id": "C1234567890", "name": "購物群", "memberCount": 150 } ]}get_messages
Section titled “get_messages”取得指定群組的訊息。
參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| channelId | string | 是 | 群組 ID |
| date | string | 否 | 日期 YYYY-MM-DD |
| limit | number | 否 | 筆數限制,預設 50 |
回傳
{ "messages": [ { "timestamp": "2025-01-15T08:30:00Z", "sender": "王小明", "content": "大家早安!" } ]}search_messages
Section titled “search_messages”搜尋訊息內容。
參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| channelId | string | 是 | 群組 ID |
| query | string | 是 | 搜尋關鍵字 |
| limit | number | 否 | 筆數限制 |
get_members
Section titled “get_members”取得群組成員列表。
參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| channelId | string | 是 | 群組 ID |
幫我查一下「購物群」最近一週的訊息搜尋「訂單」相關的對話幫我整理「讀書會」這個月討論的重點統計「團購群」的活躍度,用表格呈現| API 權限 | MCP Tool |
|---|---|
| read:messages | get_messages, search_messages |
| read:members | get_members, list_channels |
| read:media | 媒體檔案存取 |
Claude 沒有顯示 MCP 連線
Section titled “Claude 沒有顯示 MCP 連線”- 確認設定檔路徑正確
- 確認 JSON 語法正確
- 確認 API Key 有效
- 完全關閉 Claude Desktop 後重新開啟
權限不足錯誤
Section titled “權限不足錯誤”Error: Insufficient permissions確認 API Key 有勾選需要的權限。
確認:
- 群組已啟用備份功能
- 你是該群組的成員
- API Key 未過期
| 項目 | 值 |
|---|---|
| 協定版本 | MCP 1.0 |
| 傳輸方式 | HTTP/SSE |
| 認證方式 | Bearer Token |