cursor-code-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cursor-code-mcpIn D:\code\myapp, have Cursor fix the failing tests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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(微软操作系统)中可能同名的其他命令。
完整 prompt(提示词)通过 UTF-8(统一编码)标准输入传给 Cursor Agent(Cursor 代理),因此多行内容不会经由 WSL(适用于 Linux 的 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(版本控制)提交。
This server cannot be deployed
Maintenance
Related MCP Connectors
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Work on your own computers from Claude or ChatGPT: run commands, edit and search files.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Cross-agent artifact workspace with provenance across Claude Code, Codex, Cursor, LangGraph.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceFacilitates 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.7 npm39MIT
- AlicenseCqualityCmaintenanceWraps 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.75 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients like Claude Code to delegate coding tasks to the local Cursor Agent CLI, with persistent per-workspace sessions that resume across calls.12 npmMIT
- AlicenseAqualityCmaintenanceEnables MCP-compatible coding agents to execute the local Codex CLI as a coding agent, including code reviews, session resume/fork, and CLI diagnostics.93 npmMIT