在 macOS 上安装
在 macOS 上安装和配置 ContextForge MCP 的完整指南。
前提条件
- Node.js 18 或更高版本
通过 Homebrew 安装:
brew install node
或从 nodejs.org 下载 - Claude Desktop 或 Claude Code
从 claude.ai/download 下载 Claude Desktop
- ContextForge 账户
第一步:安装 ContextForge MCP
打开终端并执行:
npm install -g contextforge-mcp
第二步:验证安装
# Check if contextforge-mcp is installed which contextforge-mcp # Should output something like: # /usr/local/bin/contextforge-mcp # or /opt/homebrew/bin/contextforge-mcp
选项 A:Claude Code(CLI)
快速配置向导
推荐运行交互式配置向导:
npx contextforge-setup
备选方案:手动命令
claude mcp add contextforge -s user -e CONTEXTFORGE_API_KEY=your-api-key-here -- npx -y contextforge-mcp
验证配置
# List configured MCPs claude mcp list # Or run verification npx contextforge-setup --verify
选项 B:Claude Desktop
1. 找到配置文件
打开终端并执行:
# Open the Claude config folder open ~/Library/Application\ Support/Claude/ # Or create/edit the config file directly nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
2. 配置文件路径
~/Library/Application Support/Claude/claude_desktop_config.json
3. 添加 ContextForge 配置
添加或编辑文件,写入以下内容:
{
"mcpServers": {
"contextforge": {
"command": "npx",
"args": ["-y", "contextforge-mcp"],
"env": {
"CONTEXTFORGE_API_KEY": "your-api-key-here"
}
}
}
}注意:将 your-api-key-here 替换为你从 仪表盘 获取的实际 API key
4. 重启 Claude Desktop
完全退出 Claude Desktop(Cmd + Q)后重新打开。
更新 ContextForge MCP
有新版本时,可以通过以下命令更新:
npm install -g contextforge-mcp
如果遇到问题或需要全新重装:
npm uninstall -g contextforge-mcp && npm install -g contextforge-mcp
更新后,请重启 Claude Desktop 或 Claude Code 会话以使更改生效。
macOS 故障排除
command not found: contextforge-mcp
检查 npm 全局 bin 目录是否在 PATH 中:
# Find npm prefix npm config get prefix # Add to your shell profile (~/.zshrc or ~/.bashrc) export PATH="$PATH:$(npm config get prefix)/bin" # Reload profile source ~/.zshrc
权限被拒绝
如果 npm 报权限错误,建议使用 Node 版本管理器 nvm 或修复 npm 权限。
Library 文件夹不可见
Library 文件夹默认隐藏。在 Finder 中按 Cmd + Shift + . 显示隐藏文件,或使用终端。
Claude Desktop 未显示 ContextForge
确保已完全退出 Claude Desktop(Cmd + Q)。也检查菜单栏是否有 Claude 图标并从那里退出。