$npx -y skills add harryleemedia/second-brain --skill mcp-clientUniversal MCP client for connecting to any MCP server with progressive disclosure. Wraps MCP servers as skills to avoid context window bloat from tool definitions. Use when interacting with external MCP servers (Zapier, Sequential Thinking, GitHub, filesystem, etc.), listing avai
| 1 | # 通用 MCP 客戶端 |
| 2 | |
| 3 | 連接任何 MCP 伺服器,採用漸進式載入——按需載入工具結構定義,而非一次性將數千個 token 塞入上下文。 |
| 4 | |
| 5 | ## 技能位置 |
| 6 | |
| 7 | 此技能位於:`.claude/skills/mcp-client/` |
| 8 | |
| 9 | **腳本路徑:** `.claude/skills/mcp-client/scripts/mcp_client.py` |
| 10 | |
| 11 | ## 設定 |
| 12 | |
| 13 | 腳本依以下順序尋找設定檔: |
| 14 | 1. `MCP_CONFIG_PATH` 環境變數(自訂路徑) |
| 15 | 2. **`references/mcp-config.json`**(此技能的設定檔——建議使用) |
| 16 | 3. 專案根目錄的 `.mcp.json` |
| 17 | 4. `~/.claude.json` |
| 18 | |
| 19 | **你的設定檔:** `.claude/skills/mcp-client/references/mcp-config.json` |
| 20 | |
| 21 | 編輯此檔案以加入你的 API 金鑰。範例檔案(`example-mcp-config.json`)作為參考範本保留。 |
| 22 | |
| 23 | **如果使用者尚未提供 Zapier API 金鑰,請向他們索取。** |
| 24 | |
| 25 | ## 執行指令 |
| 26 | |
| 27 | 所有指令使用位於 `.claude/skills/mcp-client/scripts/mcp_client.py` 的腳本: |
| 28 | |
| 29 | ```bash |
| 30 | # 列出已設定的伺服器 |
| 31 | python .claude/skills/mcp-client/scripts/mcp_client.py servers |
| 32 | |
| 33 | # 列出伺服器的工具 |
| 34 | python .claude/skills/mcp-client/scripts/mcp_client.py tools <server_name> |
| 35 | |
| 36 | # 呼叫工具 |
| 37 | python .claude/skills/mcp-client/scripts/mcp_client.py call <server> <tool> '{"arg": "value"}' |
| 38 | ``` |
| 39 | |
| 40 | ## 工作流程 |
| 41 | |
| 42 | 1. **檢查設定檔是否存在** - 執行 `servers` 指令。如果出錯,建立 `.mcp.json` |
| 43 | 2. **列出伺服器** - 查看已設定的 MCP 伺服器 |
| 44 | 3. **列出工具** - 從特定伺服器取得工具結構定義 |
| 45 | 4. **呼叫工具** - 帶參數執行工具 |
| 46 | |
| 47 | ## 指令參考 |
| 48 | |
| 49 | | 指令 | 說明 | |
| 50 | |---------|-------------| |
| 51 | | `servers` | 列出所有已設定的 MCP 伺服器 | |
| 52 | | `tools <server>` | 列出工具及完整參數結構定義 | |
| 53 | | `call <server> <tool> '<json>'` | 帶參數執行工具 | |
| 54 | |
| 55 | ## 範例:Zapier |
| 56 | |
| 57 | ```bash |
| 58 | # 1. 列出伺服器以確認 Zapier 已設定 |
| 59 | python .claude/skills/mcp-client/scripts/mcp_client.py servers |
| 60 | |
| 61 | # 2. 列出 Zapier 工具 |
| 62 | python .claude/skills/mcp-client/scripts/mcp_client.py tools zapier |
| 63 | |
| 64 | # 3. 呼叫 Zapier 工具 |
| 65 | python .claude/skills/mcp-client/scripts/mcp_client.py call zapier <tool_name> '{"param": "value"}' |
| 66 | ``` |
| 67 | |
| 68 | ## 範例:Sequential Thinking |
| 69 | |
| 70 | ```bash |
| 71 | # 1. 列出工具 |
| 72 | python .claude/skills/mcp-client/scripts/mcp_client.py tools sequential-thinking |
| 73 | |
| 74 | # 2. 使用 sequential thinking |
| 75 | python .claude/skills/mcp-client/scripts/mcp_client.py call sequential-thinking sequentialthinking '{"thought": "Breaking down the problem...", "thoughtNumber": 1, "totalThoughts": 5, "nextThoughtNeeded": true}' |
| 76 | ``` |
| 77 | |
| 78 | ## 設定檔格式 |
| 79 | |
| 80 | 設定檔格式(`references/mcp-config.json`): |
| 81 | |
| 82 | ```json |
| 83 | { |
| 84 | "mcpServers": { |
| 85 | "zapier": { |
| 86 | "url": "https://mcp.zapier.com/api/v1/connect", |
| 87 | "api_key": "your-api-key" |
| 88 | }, |
| 89 | "sequential-thinking": { |
| 90 | "command": "npx", |
| 91 | "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"] |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | ``` |
| 96 | |
| 97 | **傳輸偵測:** |
| 98 | - `url` + `api_key` → 帶 Bearer 驗證的 FastMCP(Zapier) |
| 99 | - `command` + `args` → stdio(本地伺服器如 sequential-thinking) |
| 100 | - `url` 以 `/sse` 結尾 → SSE 傳輸 |
| 101 | - `url` 以 `/mcp` 結尾 → 可串流 HTTP |
| 102 | |
| 103 | ## 錯誤處理 |
| 104 | |
| 105 | 錯誤以 JSON 格式回傳: |
| 106 | ```json |
| 107 | {"error": "message", "type": "configuration|validation|connection"} |
| 108 | ``` |
| 109 | |
| 110 | - `configuration` - 找不到設定檔。請建立 `.mcp.json` |
| 111 | - `validation` - 無效的伺服器或工具名稱 |
| 112 | - `connection` - 無法連接到伺服器 |
| 113 | |
| 114 | ## 依賴套件 |
| 115 | |
| 116 | ```bash |
| 117 | pip install mcp fastmcp |
| 118 | ``` |
| 119 | |
| 120 | ## 參考資料 |
| 121 | |
| 122 | - `references/example-mcp-config.json` - 設定檔範本 |
| 123 | - `references/mcp-servers.md` - 常見伺服器設定 |
| 124 | - `references/python-mcp-sdk.md` - Python SDK 文件 |