Cursor MCP Server

Cursor MCP Server

Turns Claude Desktop into a Cursor-like assistant for code browsing, editing, searching, linting, formatting, and version control.

Category
访问服务器

README

Cursor MCP Server – AI Coding Assistant for Claude Desktop

Turn Claude Desktop into a Cursor‑like assistant that can browse, search, edit, lint, format, and version‑control your entire codebase – all through a single MCP server.

Directory Tree cursor-mcp-server/ ├── README.md ├── .gitignore ├── requirements.txt ├── mcp_server.py # main server – entry point ├── config.py # global configuration ├── tools/ │ ├── init.py │ ├── file_tools.py # file read/write/diff/tree │ ├── search_tools.py # grep, semantic search, find files │ ├── command_tools.py # safe command execution │ ├── git_tools.py # git status/diff/log/branch │ ├── code_quality_tools.py # linting & formatting │ └── rag.py # ChromaDB indexing & semantic search └── claude_desktop_config.json # ready-to-paste configuration

🚀 Overview

This project provides a Model Context Protocol (MCP) server written in Python. Once connected to Claude Desktop, it gives Claude the ability to:

  • Explore the file tree and read/write files
  • Search code with regex (grep) and semantic search (ChromaDB + embeddings)
  • Apply unified diffs safely (with optional backups)
  • Run terminal commands inside the project (sandboxed)
  • Inspect Git status, diff, log, and branch
  • Lint and format code (detects Python / JavaScript projects)
  • Build and query a semantic code index (fully local)

Everything runs offline after installing dependencies – no API keys needed.

📋 Prerequisites

  • Python 3.10 or higher
  • pip (Python package manager)
  • Git (optional, for Git‑related tools)
  • Linters / formatters are optional – the tools will detect them if installed:
    • Python: flake8 and black
    • JavaScript/TypeScript: eslint and prettier

📦 Installation

  1. Clone or download this repository into a directory of your choice.

  2. Create and activate a virtual environment (recommended):

    python3 -m venv .venv
    source .venv/bin/activate
    
  3. Install the required Python packages:

    pip install -r requirements.txt
    

    Note: The first time you run the semantic search tools, sentence-transformers will download a small embedding model (~80 MB). This is only needed once and works completely offline afterwards.

⚙️ Setup

1. Build the semantic code index (recommended)

The semantic search tool needs an index. You can build it by running the server and calling the rebuild_index tool, or by running the indexing script manually:

python -m tools.rag

This will walk the entire project, chunk files, and store embeddings inside .chroma_db/.

2. Configure Claude Desktop

  1. Open Claude Desktop settings:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Replace or merge the mcpServers section with the content of claude_desktop_config.json from this project. Edit the paths to match your setup:

    {
      "mcpServers": {
        "cursor-assistant": {
          "command": "/path/to/your/project/.venv/bin/python3",
          "args": [
            "/path/to/your/project/mcp_server.py",
            "--project-root",
            "/path/to/your/project"
          ],
          "env": {
            "PROJECT_ROOT": "/path/to/your/project",
            "PYTHONPATH": "/path/to/your/project"
          }
        }
      }
    }
    
    • Replace /path/to/your/project with the absolute path to the project you want to work on.
    • The command should point to the Python binary inside your virtual environment.
  3. Restart Claude Desktop completely (quit and reopen).

Once restarted, you’ll see an integration named cursor-assistant. Enable it and start using the assistant.

🧠 Usage

  • In Claude Desktop, start a conversation. The tools are automatically available.
  • You can ask in natural language:
    • “Show me the file tree”
    • “Find where authentication logic is”
    • “Search for all places where we use the requests library”
    • “Apply this diff to login.py”
    • “What’s the git status?”
    • “Run tests and show me the output”

All destructive actions (writing files, running commands) are described clearly. Always review the proposed actions before Claude executes them. You have full control.

🔧 Tools Reference

Workspace

  • get_workspace_info – project root and top‑level entries

Files

  • read_file(path) – read a file
  • read_multiple_files(paths) – read several files at once
  • write_file(path, content) – overwrite/create a file ⚠️
  • list_directory(path=".") – list non‑hidden contents
  • get_file_tree(path=".", max_depth=4) – recursive tree as JSON
  • apply_diff(path, diff, create_backup=True) – apply a unified diff

Search

  • grep(pattern, path=".", include=None) – regex search (respects .gitignore)
  • semantic_search(query, n_results=5) – semantic (embedding‑based) search
  • find_files(pattern, path=".") – glob‑based file search

Commands

  • execute_command(command, cwd=".") – run a shell command (⚠️ use with approval)

Git

  • git_status() – short status
  • git_diff(staged=False) – working directory diff
  • git_log(max_count=10) – recent commits
  • git_branch() – current branch name

Code Quality

  • lint_file(path, linter="auto") – run flake8/eslint
  • format_file(path) – run black/prettier (returns formatted code, does not write)

Indexing

  • rebuild_index() – rebuild the semantic search index

🛡️ Safety

  • All file and command operations are restricted to the project root – path traversal is blocked.
  • write_file and apply_diff modify files. Always review the changes before approving.
  • execute_command runs in a sandboxed directory, but the command itself is not restricted. Claude will ask for your confirmation before calling this tool.
  • Backups are automatically created when applying diffs (can be disabled).

🔍 Offline Capabilities

  • Semantic search uses a local embedding model (all-MiniLM-L6-v2) via sentence-transformers. The model is downloaded automatically on first use.
  • ChromaDB storage is local (.chroma_db/ folder).
  • No internet connection is required after the initial model download and dependency installation.

🐛 Troubleshooting

  • “Module not found: mcp” – Ensure you are using the Python from your virtual environment and have run pip install -r requirements.txt inside it.
  • rebuild_index fails / semantic search returns nothing – Ensure the .chroma_db/ folder is writable and that sentence-transformers is installed.
  • Git tools error – Make sure Git is installed and the project is a Git repository.
  • Linter / formatter not found – Install the required tools (e.g., pip install flake8 black, npm install -g eslint prettier) or simply ignore those tools.
  • Path outside project root – You may be trying to access a file outside the configured project root. Adjust PROJECT_ROOT.
  • Server disconnects immediately – Check the Claude Desktop logs for error messages. A common fix is to run the server manually (python3 mcp_server.py --project-root .) and see the traceback.

📝 License

https://github.com/tariqnasheed – use it, modify it, share it.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选