代码本地索引服务

一个基于Python的实验性服务器,使用ChromaDB本地索引代码库,并通过MCP服务器为Cursor等工具提供语义搜索功能。

  • by LuotoCompany
  • Python
  • 混合部署
  • 33 星标
  • 更新于
在 GitHub 查看 LuotoCompany/cursor-local-indexing

使用说明

游标的本地代码索引

一个基于Python的实验性服务器 本地 使用ChromaDB对代码库进行索引,并通过MCP(模型上下文协议)服务器为Cursor等工具提供语义搜索工具。

设置

  1. 克隆并进入存储库:

    git clone <repository-url>
    cd cursor-local-indexing
    
  2. 创建一个 .env 通过复制文件 .env.example:

    cp .env.example .env
    
  3. 配置您的 .env 文件:

    PROJECTS_ROOT=~/your/projects/root    # Path to your projects directory
    FOLDERS_TO_INDEX=project1,project2    # Comma-separated list of folders to index
    

    例子:

    PROJECTS_ROOT=~/projects
    FOLDERS_TO_INDEX=project1,project2
    
  4. 启动索引服务器:

    docker-compose up -d
    
  5. 配置Cursor以使用本地搜索服务器: 创建或编辑 ~/.cursor/mcp.json:

    {
      "mcpServers": {
        "workspace-code-search": {
          "url": "http://localhost:8978/sse"
        }
      }
    }
    
  6. 重新启动Cursor IDE以应用更改。

服务器将开始为您指定的项目建立索引,当这些项目处于活动状态时,您将能够在Cursor中使用语义代码搜索。

  1. 打开一个已配置为索引的项目。

创建一个 .cursorrules 文件并添加以下内容:

<instructions>
For any request, use the @search_code tool to check what the code does.
Prefer that first before resorting to command line grepping etc.
</instructions>
  1. 开始使用光标代理模式,并看到它进行局部矢量搜索!