MCP Server 選擇指南:為你的 Claude Code 工作流程找到合適的工具
Claude Code MCP 伺服器選擇與配置實用指南。從必備伺服器到專業工具,建立最佳的開發環境。
Model Context Protocol (MCP) 生態系統快速成長,目前有 80+ 個伺服器可供各種用途使用。選擇正確的組合可以大幅提升你的 Claude Code 生產力——但選擇太多會使你的上下文膨脹並拖慢速度。
本指南幫助你為特定需求選擇最佳的 MCP 伺服器組合。
理解 MCP 上下文成本
在選擇伺服器之前,先理解這個權衡:
更多 MCP 伺服器 = 更多能力 + 更高的上下文成本
每個啟用的 MCP 伺服器:
- 將工具定義加入 Claude 的上下文(每個伺服器約 500-2000 tokens)
- 增加啟動時間
- 可能與其他伺服器衝突
經驗法則:從 3-5 個必備伺服器開始,只在需要時才增加更多。
必備入門套件
這些伺服器以最小的上下文開銷提供最大價值:
1. Filesystem 伺服器(必備)
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
}
}
}
原因:核心檔案操作。Claude Code 需要這個來讀寫程式碼檔案。
上下文成本:約 800 tokens
2. Memory 伺服器(強烈推薦)
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-memory"]
}
}
}
原因:跨會話的持久知識。儲存專案上下文、決策和學到的模式。
上下文成本:約 600 tokens
使用時機:
- 在多個會話中處理複雜專案
- 需要記住架構決策
- 想要跨會話的一致行為
3. Git 伺服器(團隊推薦)
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-git"]
}
}
}
原因:超越基本 CLI 的增強 git 操作。
上下文成本:約 700 tokens
使用時機:
- 使用團隊倉庫
- 需要智慧 commit 建議
- 想要分支管理協助
伺服器類別與選擇
類別 1:資料庫伺服器
| 伺服器 | 最適合 | 上下文成本 |
|---|---|---|
mcp-postgres | PostgreSQL 資料庫 | 約 900 tokens |
mcp-supabase | Supabase 專案 | 約 1100 tokens |
mcp-sqlite | 本地 SQLite DB | 約 600 tokens |
mcp-mongodb | MongoDB 資料庫 | 約 800 tokens |
選擇指南:
根據你的技術棧選擇一個資料庫伺服器:
- Supabase 專案? → mcp-supabase
- PostgreSQL 後端? → mcp-postgres
- 本地原型開發? → mcp-sqlite
- 文件資料庫? → mcp-mongodb
配置範例(Supabase):
{
"mcpServers": {
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server"],
"env": {
"SUPABASE_URL": "${SUPABASE_URL}",
"SUPABASE_SERVICE_ROLE_KEY": "${SUPABASE_SERVICE_ROLE_KEY}"
}
}
}
}
類別 2:API 與整合伺服器
| 伺服器 | 最適合 | 上下文成本 |
|---|---|---|
mcp-fetch | HTTP 請求 | 約 500 tokens |
mcp-brave-search | 網路搜尋 | 約 600 tokens |
mcp-github | GitHub API | 約 1200 tokens |
mcp-slack | Slack 整合 | 約 700 tokens |
選擇指南:
根據工作流程需求添加 API 伺服器:
- 需要網路研究? → mcp-brave-search
- GitHub 重度使用? → mcp-github
- 發出 API 請求? → mcp-fetch
- 團隊溝通? → mcp-slack
配置範例(GitHub):
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}
類別 3:開發工具
| 伺服器 | 最適合 | 上下文成本 |
|---|---|---|
mcp-puppeteer | 瀏覽器自動化 | 約 1000 tokens |
mcp-chromium-devtools | Chrome 除錯 | 約 900 tokens |
mcp-docker | 容器管理 | 約 800 tokens |
mcp-kubernetes | K8s 叢集 | 約 1100 tokens |
選擇指南:
根據專案類型添加開發工具:
- 需要 E2E 測試? → mcp-puppeteer
- 前端除錯? → mcp-chromium-devtools
- 容器化應用? → mcp-docker
- K8s 部署? → mcp-kubernetes
類別 4:文件與知識
| 伺服器 | 最適合 | 上下文成本 |
|---|---|---|
mcp-context7 | 函式庫文件 | 約 500 tokens |
mcp-notion | Notion 工作區 | 約 700 tokens |
mcp-confluence | Atlassian 文件 | 約 800 tokens |
選擇指南:
在以下情況添加知識伺服器:
- 使用不熟悉的函式庫 → mcp-context7
- 團隊使用 Notion → mcp-notion
- 企業文件 → mcp-confluence
配置範例(Context7):
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp-server"]
}
}
}
推薦組合
🎯 獨立開發者(Web App)
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
},
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-memory"]
},
"supabase": {
"command": "npx",
"args": ["-y", "@supabase/mcp-server"],
"env": {
"SUPABASE_URL": "${SUPABASE_URL}",
"SUPABASE_SERVICE_ROLE_KEY": "${SUPABASE_SERVICE_ROLE_KEY}"
}
}
}
}
總上下文成本:約 2500 tokens
為何選這個組合:
- Filesystem 用於程式碼操作
- Memory 用於專案知識持久化
- Supabase 一站式處理資料庫 + 認證 + 儲存
🎯 全端團隊
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
},
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-memory"]
},
"git": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-git"]
},
"github": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}
總上下文成本:約 4200 tokens
為何選這個組合:
- 核心檔案 + memory 操作
- Git 用於版本控制
- GitHub 用於 PR/Issue 管理
- PostgreSQL 用於生產資料庫
🎯 資料分析
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
},
"sqlite": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-sqlite", "./data.db"]
},
"fetch": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-fetch"]
},
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-brave-search"],
"env": {
"BRAVE_API_KEY": "${BRAVE_API_KEY}"
}
}
}
}
總上下文成本:約 2500 tokens
為何選這個組合:
- Filesystem 用於資料檔案
- SQLite 用於本地資料分析
- Fetch 用於 API 資料收集
- Brave Search 用於研究
🎯 DevOps/基礎設施
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
},
"git": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-git"]
},
"docker": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-docker"]
},
"kubernetes": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-kubernetes"],
"env": {
"KUBECONFIG": "${KUBECONFIG}"
}
}
}
}
總上下文成本:約 3400 tokens
為何選這個組合:
- 核心檔案 + git 操作
- Docker 用於容器管理
- Kubernetes 用於叢集操作
🎯 前端開發者
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "."]
},
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-memory"]
},
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp-server"]
},
"puppeteer": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-puppeteer"]
}
}
}
總上下文成本:約 2900 tokens
為何選這個組合:
- 核心檔案 + memory
- Context7 用於 React/Vue/框架文件
- Puppeteer 用於 E2E 測試
上下文優化策略
策略 1:延遲載入
不要一次啟用所有伺服器。使用專案特定配置:
project-a/.claude/settings.json → 資料庫伺服器
project-b/.claude/settings.json → 基礎設施伺服器
策略 2:Agent 專用 MCP
進階使用者可以將特定 MCP 伺服器分配給特定 agent:
# CLAUDE.md
## Agent MCP 分配
### security-auditor
- filesystem (唯讀)
- 無資料庫存取
### developer
- filesystem (完整)
- database
- git
### doc-writer
- filesystem (唯讀)
- context7
注意:這是概念模式。參見 Issue #17668 了解 MCP Context Isolation 的 RFC。
策略 3:基於環境的配置
# 開發環境
export MCP_PROFILE=dev
claude --mcp-config ./mcp-dev.json
# 生產環境
export MCP_PROFILE=prod
claude --mcp-config ./mcp-prod.json
常見問題排除
問題:上下文使用過高
症狀:「Context limit exceeded」或回應緩慢
解決方案:
- 檢查哪些伺服器已啟用:
claude --list-mcp - 移除未使用的伺服器
- 使用專案特定配置而非全域配置
問題:伺服器啟動失敗
症狀:「MCP server failed to start」
解決方案:
# 檢查 npx 是否能找到套件
npx -y @anthropic/mcp-filesystem --version
# 清除 npx 快取
rm -rf ~/.npm/_npx
# 檢查環境變數
env | grep -E "(SUPABASE|GITHUB|DATABASE)"
問題:權限被拒絕
症狀:MCP 伺服器回傳「Access denied」
解決方案:
- 檢查目標目錄的檔案權限
- 驗證 API tokens 有正確的 scopes
- 查看 MCP 伺服器文件了解所需權限
問題:伺服器衝突
症狀:意外行為、工具名稱重複
解決方案:
- 不要對同一個資料庫使用多個資料庫伺服器
- 在伺服器文件中檢查工具名稱衝突
- 盡可能每個類別只使用一個伺服器
進階:建立自訂 MCP 伺服器
當現有伺服器不符合你的需求時:
基本自訂伺服器結構
// my-mcp-server.js
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server({
name: "my-custom-server",
version: "1.0.0"
}, {
capabilities: {
tools: {}
}
});
// 定義工具
server.setRequestHandler("tools/list", async () => ({
tools: [{
name: "my_tool",
description: "做一些有用的事",
inputSchema: {
type: "object",
properties: {
input: { type: "string" }
}
}
}]
}));
// 處理工具呼叫
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "my_tool") {
return { content: [{ type: "text", text: "結果" }] };
}
});
// 啟動伺服器
const transport = new StdioServerTransport();
await server.connect(transport);
何時建立自訂
在以下情況建立自訂 MCP 伺服器:
- ✅ 需要內部 API 整合
- ✅ 專有資料庫存取
- ✅ 公司專用工具
- ✅ 特定領域邏輯
不要建立自訂當:
- ❌ 現有伺服器已覆蓋 80%+ 的需求
- ❌ 只需要小修改(改用 fork)
- ❌ 一次性使用案例(改用 fetch MCP)
快速參考:熱門伺服器
| 伺服器 | 套件 | 主要功能 |
|---|---|---|
| Filesystem | @anthropic/mcp-filesystem | 檔案操作 |
| Memory | @anthropic/mcp-memory | 持久知識 |
| Git | @anthropic/mcp-git | 版本控制 |
| GitHub | @anthropic/mcp-github | GitHub API |
| PostgreSQL | @anthropic/mcp-postgres | SQL 資料庫 |
| Supabase | @supabase/mcp-server | 完整 Supabase 堆疊 |
| Fetch | @anthropic/mcp-fetch | HTTP 請求 |
| Puppeteer | @anthropic/mcp-puppeteer | 瀏覽器自動化 |
| Context7 | @context7/mcp-server | 函式庫文件 |
| Brave Search | @anthropic/mcp-brave-search | 網路搜尋 |
入門清單
今天(10 分鐘)
- ✅ 稽核目前的 MCP 伺服器:
cat .claude/settings.json - ✅ 移除未使用的伺服器
- ✅ 驗證必備伺服器已配置
本週
- ✅ 設定專案特定的 MCP 配置
- ✅ 測試適合你使用案例的推薦組合
- ✅ 在 CLAUDE.md 中記錄你的配置
本月
- ✅ 監控上下文使用模式
- ✅ 根據實際使用情況優化
- ✅ 考慮為重複需求建立自訂 MCP
重點摘要
- 從小開始 - 從 3-5 個必備伺服器開始
- 配合工作流程 - 選擇符合你實際工作的伺服器
- 監控上下文 - 追蹤 token 使用並優化
- 專案特定 - 為不同專案使用不同配置
- 保持更新 - MCP 生態系統快速演進
正確的 MCP 組合可以將你的 Claude Code 體驗從良好變成卓越。花時間好好配置它。