mcp-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMCP Setup
MCP 配置
Configure Model Context Protocol (MCP) servers to extend Claude Code's capabilities with external tools like web search, file system access, and GitHub integration.
配置模型上下文协议(MCP)服务器,为Claude Code扩展网页搜索、文件系统访问、GitHub集成等外部工具能力。
Overview
概述
MCP servers provide additional tools that Claude Code agents can use. This skill helps you configure popular MCP servers using the command-line interface.
claude mcp addMCP服务器可为Claude Code Agent提供额外工具。本指南将帮助你通过命令行界面配置主流MCP服务器。
claude mcp addStep 1: Show Available MCP Servers
步骤1:查看可用的MCP服务器
Present the user with available MCP server options using AskUserQuestion:
Question: "Which MCP server would you like to configure?"
Options:
- Context7 - Documentation and code context from popular libraries
- Exa Web Search - Enhanced web search (replaces built-in websearch)
- Filesystem - Extended file system access with additional capabilities
- GitHub - GitHub API integration for issues, PRs, and repository management
- All of the above - Configure all recommended MCP servers
- Custom - Add a custom MCP server
通过询问用户问题展示可选的MCP服务器:
问题: "你想要配置哪款MCP服务器?"
选项:
- Context7 - 主流库的文档与代码上下文查询
- Exa Web Search - 增强型网页搜索(替代内置网页搜索功能)
- Filesystem - 扩展文件系统访问能力
- GitHub - GitHub API集成,支持议题、PR与仓库管理
- 以上全部 - 配置所有推荐的MCP服务器
- 自定义 - 添加自定义MCP服务器
Step 2: Gather Required Information
步骤2:收集必要信息
For Context7:
针对Context7:
No API key required. Ready to use immediately.
无需API密钥,可直接使用。
For Exa Web Search:
针对Exa Web Search:
Ask for API key:
Do you have an Exa API key?
- Get one at: https://exa.ai
- Enter your API key, or type 'skip' to configure later询问API密钥:
你是否拥有Exa API密钥?
- 获取地址:https://exa.ai
- 输入你的API密钥,或输入'skip'稍后配置For Filesystem:
针对Filesystem:
Ask for allowed directories:
Which directories should the filesystem MCP have access to?
Default: Current working directory
Enter comma-separated paths, or press Enter for default询问允许访问的目录:
文件系统MCP需要访问哪些目录?
默认:当前工作目录
输入逗号分隔的路径,或按回车键使用默认设置For GitHub:
针对GitHub:
Ask for token:
Do you have a GitHub Personal Access Token?
- Create one at: https://github.com/settings/tokens
- Recommended scopes: repo, read:org
- Enter your token, or type 'skip' to configure later询问令牌:
你是否拥有GitHub个人访问令牌?
- 创建地址:https://github.com/settings/tokens
- 推荐权限范围:repo, read:org
- 输入你的令牌,或输入'skip'稍后配置Step 3: Add MCP Servers Using CLI
步骤3:通过CLI添加MCP服务器
Use the command to configure each MCP server. The CLI automatically handles settings.json updates and merging.
claude mcp add使用命令配置各MCP服务器,CLI会自动处理settings.json的更新与合并。
claude mcp addContext7 Configuration:
Context7配置:
bash
claude mcp add context7 -- npx -y @upstash/context7-mcpbash
claude mcp add context7 -- npx -y @upstash/context7-mcpExa Web Search Configuration:
Exa Web Search配置:
bash
claude mcp add -e EXA_API_KEY=<user-provided-key> exa -- npx -y exa-mcp-serverbash
claude mcp add -e EXA_API_KEY=<用户提供的密钥> exa -- npx -y exa-mcp-serverFilesystem Configuration:
Filesystem配置:
bash
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem <allowed-directories>bash
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem <允许访问的目录>GitHub Configuration:
GitHub配置:
Option 1: Docker (local)
bash
claude mcp add -e GITHUB_PERSONAL_ACCESS_TOKEN=<user-provided-token> github -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-serverOption 2: HTTP (remote)
bash
claude mcp add --transport http github https://api.githubcopilot.com/mcp/Note: Docker option requires Docker installed. HTTP option is simpler but may have different capabilities.
选项1:Docker(本地)
bash
claude mcp add -e GITHUB_PERSONAL_ACCESS_TOKEN=<用户提供的令牌> github -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server选项2:HTTP(远程)
bash
claude mcp add --transport http github https://api.githubcopilot.com/mcp/注意:Docker选项需要已安装Docker。HTTP选项操作更简单,但功能可能有所不同。
Step 4: Verify Installation
步骤4:验证安装
After configuration, verify the MCP servers are properly set up:
bash
undefined配置完成后,验证MCP服务器是否正常设置:
bash
undefinedList configured MCP servers
列出已配置的MCP服务器
claude mcp list
This will display all configured MCP servers and their status.claude mcp list
该命令将显示所有已配置的MCP服务器及其状态。Step 5: Show Completion Message
步骤5:显示完成消息
MCP Server Configuration Complete!
CONFIGURED SERVERS:
[List the servers that were configured]
NEXT STEPS:
1. Restart Claude Code for changes to take effect
2. The configured MCP tools will be available to all agents
3. Run `claude mcp list` to verify configuration
USAGE TIPS:
- Context7: Ask about library documentation (e.g., "How do I use React hooks?")
- Exa: Use for web searches (e.g., "Search the web for latest TypeScript features")
- Filesystem: Extended file operations beyond the working directory
- GitHub: Interact with GitHub repos, issues, and PRs
TROUBLESHOOTING:
- If MCP servers don't appear, run `claude mcp list` to check status
- Ensure you have Node.js 18+ installed for npx-based servers
- For GitHub Docker option, ensure Docker is installed and running
- Run /oh-my-claudecode:doctor to diagnose issues
MANAGING MCP SERVERS:
- Add more servers: /oh-my-claudecode:mcp-setup or `claude mcp add ...`
- List servers: `claude mcp list`
- Remove a server: `claude mcp remove <server-name>`MCP服务器配置完成!
已配置的服务器:
[列出已配置的服务器]
下一步:
1. 重启Claude Code使更改生效
2. 已配置的MCP工具将对所有Agent可用
3. 运行`claude mcp list`验证配置
使用提示:
- Context7:查询库文档(例如:"如何使用React hooks?")
- Exa:用于网页搜索(例如:"搜索最新TypeScript特性")
- Filesystem:实现工作目录之外的扩展文件操作
- GitHub:与GitHub仓库、议题和PR交互
故障排除:
- 如果MCP服务器未显示,运行`claude mcp list`检查状态
- 确保已安装Node.js 18+以支持基于npx的服务器
- 对于GitHub Docker选项,确保Docker已安装并运行
- 运行/oh-my-claudecode:doctor诊断问题
管理MCP服务器:
- 添加更多服务器:/oh-my-claudecode:mcp-setup 或 `claude mcp add ...`
- 列出服务器:`claude mcp list`
- 删除服务器:`claude mcp remove <服务器名称>`Custom MCP Server
自定义MCP服务器
If user selects "Custom":
Ask for:
- Server name (identifier)
- Transport type: (default) or
stdiohttp - For stdio: Command and arguments (e.g., )
npx my-mcp-server - For http: URL (e.g., )
https://example.com/mcp - Environment variables (optional, key=value pairs)
- HTTP headers (optional, for http transport only)
Then construct and run the appropriate command:
claude mcp addFor stdio servers:
bash
undefined如果用户选择“自定义”:
询问以下信息:
- 服务器名称(标识符)
- 传输类型:(默认)或
stdiohttp - 对于stdio:命令与参数(例如:)
npx my-mcp-server - 对于http:URL(例如:)
https://example.com/mcp - 环境变量(可选,键=值对)
- HTTP头(可选,仅适用于http传输)
然后构造并运行对应的命令:
claude mcp add针对stdio服务器:
bash
undefinedWithout environment variables
无环境变量
claude mcp add <server-name> -- <command> [args...]
claude mcp add <服务器名称> -- <命令> [参数...]
With environment variables
带环境变量
claude mcp add -e KEY1=value1 -e KEY2=value2 <server-name> -- <command> [args...]
**For HTTP servers:**
```bashclaude mcp add -e KEY1=value1 -e KEY2=value2 <服务器名称> -- <命令> [参数...]
**针对HTTP服务器:**
```bashBasic HTTP server
基础HTTP服务器
claude mcp add --transport http <server-name> <url>
claude mcp add --transport http <服务器名称> <URL>
HTTP server with headers
带HTTP头的服务器
claude mcp add --transport http --header "Authorization: Bearer <token>" <server-name> <url>
undefinedclaude mcp add --transport http --header "Authorization: Bearer <令牌>" <服务器名称> <URL>
undefinedCommon Issues
常见问题
MCP Server Not Loading
MCP服务器无法加载
- Ensure Node.js 18+ is installed
- Check that npx is available in PATH
- Run to verify server status
claude mcp list - Check server logs for errors
- 确保已安装Node.js 18+
- 检查npx是否在PATH中可用
- 运行验证服务器状态
claude mcp list - 查看服务器日志排查错误
API Key Issues
API密钥问题
- Exa: Verify key at https://dashboard.exa.ai
- GitHub: Ensure token has required scopes (repo, read:org)
- Re-run with correct credentials if needed
claude mcp add
- Exa:在https://dashboard.exa.ai验证密钥
- GitHub:确保令牌拥有所需权限范围(repo, read:org)
- 若需,重新运行并输入正确凭据
claude mcp add
Agents Still Using Built-in Tools
Agent仍使用内置工具
- Restart Claude Code after configuration
- The built-in websearch will be deprioritized when exa is configured
- Run to confirm servers are active
claude mcp list
- 配置完成后重启Claude Code
- 配置Exa后,内置网页搜索功能会被优先降级
- 运行确认服务器处于活跃状态
claude mcp list
Removing or Updating a Server
删除或更新服务器
- Remove:
claude mcp remove <server-name> - Update: Remove the old server, then add it again with new configuration
- 删除:
claude mcp remove <服务器名称> - 更新:先删除旧服务器,再重新添加新配置的服务器