cursor-code-mcp

cursor-code-mcp

Connects Windows-based Codex to the Cursor Agent CLI in WSL, providing a run_cursor tool to execute tasks in specified working directories and resume sessions per directory.

Category
Visit Server

README

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(微软操作系统)中可能同名的其他命令。

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(版本控制)提交。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured