Skip to main content
Glama

Cursor Code(代码编辑器)MCP(模型上下文协议)

该服务将运行在 Windows(微软操作系统)上的 Codex(代码智能体)连接到 WSL(适用于 Linux 的 Windows 子系统)中的官方 Cursor Agent(Cursor 代理)CLI(命令行工具)。它只提供 run_cursor 工具,并按规范化后的 Windows(微软操作系统)cwd 自动保存与恢复 Cursor(代码编辑器)会话。

安装

先在 Windows(微软操作系统)PowerShell(微软命令行环境)中安装 Cursor Agent(Cursor 代理)CLI(命令行工具):

wsl -d Ubuntu -- bash -lc 'curl -fsS https://cursor.com/install | bash'
wsl -d Ubuntu -- bash -lc 'export PATH="$HOME/.local/bin:$PATH"; agent --version'

再完成一次 Cursor(代码编辑器)账号登录:

wsl -d Ubuntu -- bash -lc 'export PATH="$HOME/.local/bin:$PATH"; agent login'

安装 Python(编程语言)依赖:

python -m pip install -r requirements.txt

服务会将 Windows(微软操作系统)工作目录转换为 WSL(适用于 Linux 的 Windows 子系统)挂载路径,例如 D:\\project\\demo 转为 /mnt/d/project/demo。Cursor Agent(Cursor 代理)在无交互模式下使用 -p --force --output-format json,因此可以直接修改指定工作目录。

服务会在每次 WSL(适用于 Linux 的 Windows 子系统)调用前将 ~/.local/bin(用户本地命令目录) 放到 PATH(环境变量搜索路径) 首位,确保运行官方 Cursor Agent(Cursor 代理)agent 命令,而不误用 Windows(微软操作系统)中可能同名的其他命令。

Related MCP server: Cursor Agent MCP Server

Codex(代码智能体)配置

~/.codex/config.toml 中添加:

[mcp_servers.cursor_code]
command = "python"
args = ["/absolute/path/to/cursor_code_mcp.py"]
startup_timeout_sec = 30
tool_timeout_sec = 21600
enabled_tools = ["run_cursor"]
default_tools_approval_mode = "auto"

[mcp_servers.cursor_code.env]
CURSOR_WSL_DISTRIBUTION = "Ubuntu"
CURSOR_COMMAND = "agent"
# 可选:指定 Cursor(代码编辑器)模型;此示例为 Grok 4.6(Grok 4.6 模型)的最高推理强度快速档。
CURSOR_MODEL = "cursor-grok-4.6-xhigh-fast"

Windows(微软操作系统)示例可写为:

[mcp_servers.cursor_code]
command = "D:\\anaconda\\python.exe"
args = ["D:\\project\\cursor-code-mcp\\cursor_code_mcp.py"]
startup_timeout_sec = 30
tool_timeout_sec = 21600
enabled_tools = ["run_cursor"]
default_tools_approval_mode = "auto"

[mcp_servers.cursor_code.env]
CURSOR_WSL_DISTRIBUTION = "Ubuntu"
CURSOR_COMMAND = "agent"
CURSOR_MODEL = "cursor-grok-4.6-xhigh-fast"

可选环境变量 CURSOR_MODEL 会传递为 --model(模型参数)。cursor-grok-4.6-xhigh-fast 是当前 CLI(命令行工具)列出的 Grok 4.6(Grok 4.6 模型)最高推理强度快速档;可通过 agent --list-models(列出模型)查看本账号可用的最新标识。若使用 API(接口)密钥而不是浏览器登录,请在 WSL(适用于 Linux 的 Windows 子系统)环境中设置 CURSOR_API_KEY,不要将密钥提交到仓库。

工具

run_cursor 只接收两个必填参数:

  • prompt:交给 Cursor Agent(Cursor 代理)的完整任务。

  • cwd:目标项目的 Windows(微软操作系统)绝对工作目录。

首次调用创建 Cursor(代码编辑器)会话;同一目录后续调用自动使用 --resume(恢复会话)。仅在任务成功完成后,服务才写入 state/sessions.json(会话映射)。每次调用会阻塞至 Cursor Agent(Cursor 代理)结束,并返回状态、退出码、最终 JSON(数据格式)结果与日志路径。日志保存在 logs,会话映射保存在 state/sessions.json,两者均不会被 Git(版本控制)提交。

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    Facilitates integration with the Cursor code editor by enabling real-time code indexing, analysis, and bi-directional communication with Claude, supporting concurrent sessions and automatic reconnection.
    14
    39
    MIT
  • A
    license
    C
    quality
    C
    maintenance
    Wraps the cursor-agent CLI to provide cost-effective tools for repository analysis, code search, planning, and editing. Offloads heavy thinking tasks from the host AI to reduce token usage while maintaining precise, scoped workspace operations.
    7
    5
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides workspace-scoped file operations and command execution tools for building Cursor-style agents, along with system prompts and tool definitions for LLM integration.
    5
    MIT

View all related MCP servers

Related MCP Connectors

  • Cross-agent artifact workspace with provenance across Claude Code, Codex, Cursor, LangGraph.

  • Securely search and manage workspace context files for AI agents and teams.

  • Coding agents from Claude Code, Cursor and Codex claim jobs and lock files on one shared board.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/guheng-re/cursor-code-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server