关于 mcp-setup
此 Skill 使用 `claude mcp add` CLI 引导用户为 Claude Code 配置 MCP 服务,涵盖推荐组合、单个服务,以及自定义 stdio 或 HTTP 配置。
主要功能
- 01引导选择服务配置方案
- 02配置 Context7、Exa、Filesystem 和 GitHub
- 03支持自定义 stdio 与 HTTP 服务
- 04使用 `claude mcp add` 添加服务
- 05通过 `claude mcp list` 验证配置
适用场景
- 01配置入门 MCP 服务组合
- 02添加文档或搜索服务
- 03连接文件系统或 GitHub 工具
- 04注册自定义 MCP 端点
MCP 相关
此 Skill 为 Claude Code 配置 MCP 服务,使其工具可供 Claude Code Agent 使用。它支持 stdio 和 HTTP 服务配置,包括自定义服务。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ yeachan-heo/ oh-my-claudecode --skill mcp-setup安装后在 Claude Code 中输入/mcp-setup确认已加载。
详细介绍
MCP 设置
配置 Model Context Protocol(MCP)服务,借助网页搜索、文件系统访问和 GitHub 集成等外部工具扩展 Claude Code 的功能。
概述
MCP 服务提供 Claude Code Agent 可使用的其他工具。本技能会帮助你使用 claude mcp add 命令行界面配置常用的 MCP 服务。
步骤 1:选择设置路径
使用 AskUserQuestion,每次只提一个问题,且每个问题最多提供 3 个选项。较新的 Claude Code 版本会将包含更多选项的负载判定为无效工具参数,因此请分阶段进行 MCP 选择流程。
步骤 1.1:第一个菜单
问题:“你想要哪种 MCP 设置?”
选项:
- 推荐入门设置 - 快速添加最常用的 OMC MCP 服务
- 单个常用服务 - 从后续的简短菜单中选择一个内置服务
- 自定义服务 - 添加你自己的 stdio 或 HTTP MCP 服务
步骤 1.2:如果用户选择“推荐入门设置”
使用 AskUserQuestion 提出后续问题:
问题:“你想配置哪个推荐 MCP 套件?”
选项:
- 仅 Context7(推荐) - 无需配置的文档/上下文服务
- Context7 + Exa - 文档/上下文服务和增强型网页搜索
- 完整推荐套件 - Context7、Exa、Filesystem 和 GitHub
根据该选择确定要配置的服务列表。
步骤 1.3:如果用户选择“单个常用服务”
使用 AskUserQuestion 提出后续问题:
问题:“你想先配置哪个服务?”
选项:
- Context7(推荐) - 提供常用库的文档和代码上下文
- Exa 网页搜索 - 增强型网页搜索(取代内置的 websearch)
- 更多服务选项 - Filesystem、GitHub 或完整推荐套件
如果用户选择**“更多服务选项”**,再使用 AskUserQuestion 提出一个问题:
问题:“你还想配置哪个 MCP 选项?”
选项:
- Filesystem(推荐) - 扩展文件系统访问能力
- GitHub - 集成 GitHub API,用于处理 issue、PR 和仓库管理
- 完整推荐套件 - 一起配置 Context7、Exa、Filesystem 和 GitHub
步骤 1.4:如果用户选择“自定义服务”
直接跳转到下方的自定义 MCP 服务部分。
步骤 2:收集所需信息
对于 Context7:
无需 API 密钥。可立即使用。
对于 Exa 网页搜索:
询问 API 密钥:
Do you have an Exa API key?
- Get one at: https://exa.ai
- Enter your API key, or type 'skip' to configure later
对于 Filesystem:
询问允许访问的目录:
Which directories should the filesystem MCP have access to?
Default: Current working directory
Enter comma-separated paths, or press Enter for default
对于 GitHub:
询问令牌:
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
步骤 3:使用 CLI 添加 MCP 服务
使用 claude mcp add 命令配置每个 MCP 服务。CLI 会自动处理 settings.json 的更新和合并。
Context7 配置:
claude mcp add context7 -- npx -y @upstash/context7-mcp
Exa 网页搜索配置:
claude mcp add -e EXA_API_KEY=<user-provided-key> exa -- npx -y exa-mcp-server
Filesystem 配置:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem <allowed-directories>
GitHub 配置:
选项 1:Docker(本地)
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-server
选项 2:HTTP(远程)
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
注意:Docker 选项需要安装 Docker。HTTP 选项更简单,但功能可能有所不同。
步骤 4:验证安装
配置完成后,验证 MCP 服务是否已正确设置:
# List configured MCP servers
claude mcp list
这将显示所有已配置 MCP 服务及其状态。
步骤 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:omc-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 服务
如果用户选择“自定义”:
询问:
- 服务名称(标识符)
- 传输类型:
stdio(默认)或http - 对于 stdio:命令和参数(例如
npx my-mcp-server) - 对于 http:URL(例如
https://example.com/mcp) - 环境变量(可选,键值对)
- HTTP 标头(可选,仅适用于 http 传输)
然后构造并运行相应的 claude mcp add 命令:
对于 stdio 服务:
# Without environment variables
claude mcp add <server-name> -- <command> [args...]
# With environment variables
claude mcp add -e KEY1=value1 -e KEY2=value2 <server-name> -- <command> [args...]
对于 HTTP 服务:
# Basic HTTP server
claude mcp add --transport http <server-name> <url>
# HTTP server with headers
claude mcp add --transport http --header "Authorization: Bearer <token>" <server-name> <url>
公司上下文约定
如果自定义服务旨在为 OMC 工作流提供组织专属参考资料,建议使用名为 get_company_context 的单个工具,通过 { context: string } 返回 Markdown。
本地注册示例:
claude mcp add company-context -- node examples/vendor-mcp-server/server.mjs
然后在 .claude/omc.jsonc 或 ~/.config/claude-omc/config.jsonc 中,将 OMC 指向完整的工具名称:
{
"companyContext": {
"tool": "mcp__company-context__get_company_context",
"onError": "warn"
}
}
这仍是提示词上下文建议,并非运行时强制执行。
常见问题
MCP 服务无法加载
- 确保已安装 Node.js 18+
- 检查 PATH 中是否有 npx
- 运行
claude mcp list验证服务状态 - 检查服务日志是否有错误
API 密钥问题
- Exa:在 https://dashboard.exa.ai 验证密钥
- GitHub:确保令牌具有所需的范围(repo、read:org)
- 如有需要,使用正确的凭据重新运行
claude mcp add
Agent 仍在使用内置工具
- 配置后重启 Claude Code
- 配置 exa 后,内置 websearch 的优先级会降低
- 运行
claude mcp list确认服务处于活动状态
移除或更新服务
- 移除:
claude mcp remove <server-name> - 更新:移除旧服务,然后使用新配置重新添加