为 Cursor IDE 安装

在 Cursor IDE 中安装和配置 ContextForge MCP 的完整指南。

前提条件

第一步:安装 ContextForge MCP

打开终端并执行:

npm install -g contextforge-mcp

第二步:验证安装

# Check if contextforge-mcp is installed
which contextforge-mcp

# Should output the path to the executable

第三步:配置 Cursor

1. 找到 MCP 配置文件

Cursor 使用 JSON 配置文件管理 MCP 服务器:

# macOS / Linux
~/.cursor/mcp.json

# Windows
%USERPROFILE%\.cursor\mcp.json

2. 创建或编辑配置文件

添加以下配置:

{
  "mcpServers": {
    "contextforge": {
      "command": "npx",
      "args": ["-y", "contextforge-mcp"],
      "env": {
        "CONTEXTFORGE_API_KEY": "your-api-key-here"
      }
    }
  }
}

注意: your-api-key-here 替换为你从 仪表盘 获取的实际 API key

3. 重启 Cursor

关闭并重新打开 Cursor IDE 以使更改生效。

在 Cursor 中使用 ContextForge

配置完成后,你可以在 Cursor 的 AI 对话中使用 ContextForge 工具:

# Save knowledge to memory
"Remember this API endpoint documentation..."

# Query your memory
"What do we know about the authentication flow?"

# Create tasks
"Create a task: Fix the login bug"

# List your tasks
"Show my pending tasks"

更新 ContextForge MCP

有新版本时,可以通过以下命令更新:

npm install -g contextforge-mcp

如果遇到问题或需要全新重装:

npm uninstall -g contextforge-mcp && npm install -g contextforge-mcp

更新后,请重启 Cursor IDE 以使更改生效。

故障排除

MCP 未在 Cursor 中显示

确保配置文件位于正确位置且 JSON 有效:

# Validate JSON syntax
cat ~/.cursor/mcp.json | jq .

# Check if contextforge-mcp is accessible
which contextforge-mcp

command not found: contextforge-mcp

将 npm 全局 bin 添加到 PATH,或在配置中使用完整路径:

# Find the full path
npm config get prefix

# Use full path in mcp.json
{
  "mcpServers": {
    "contextforge": {
      "command": "/usr/local/bin/contextforge-mcp",
      "env": {
        "CONTEXTFORGE_API_KEY": "your-api-key"
      }
    }
  }
}

身份验证错误

确认 API key 正确且未过期。你可以在 仪表盘 中生成新密钥。

Windows:路径问题

在 Windows 上,可能需要使用带 .cmd 扩展名的完整路径:

{
  "mcpServers": {
    "contextforge": {
      "command": "C:\\Users\\YourName\\AppData\\Roaming\\npm\\contextforge-mcp.cmd",
      "env": {
        "CONTEXTFORGE_API_KEY": "your-api-key"
      }
    }
  }
}

下一步