This MCP server provides a local code indexing solution for Cursor IDE, allowing you to search your codebase semantically without sending your code to external services. It uses ChromaDB to create and query a local vector database of your code.
Clone and enter the repository:
git clone <repository-url>
cd cursor-local-indexing
Create a configuration file:
cp .env.example .env
Configure your environment by editing the .env
file:
PROJECTS_ROOT=~/your/projects/root # Path to your projects directory
FOLDERS_TO_INDEX=project1,project2 # Comma-separated list of folders to index
For example:
PROJECTS_ROOT=~/projects
FOLDERS_TO_INDEX=project1,project2
Launch the indexing server:
docker-compose up -d
To connect Cursor with your local indexing server:
Create or modify the MCP configuration file:
mkdir -p ~/.cursor
nano ~/.cursor/mcp.json
Add the following content to the file:
{
"mcpServers": {
"workspace-code-search": {
"url": "http://localhost:8978/sse"
}
}
}
Restart Cursor IDE to apply the changes.
After setup, you can use semantic code search within Cursor:
Open one of the projects you configured for indexing.
Create a .cursorrules
file in your project root with the following content:
<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>
Activate Cursor's Agent mode to start using local vector searches.
When properly set up, Cursor will use your local index when performing code searches instead of sending your code to external services. You can test this by asking the Cursor Agent questions about your codebase.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.