A Neo4j MCP server implementation that manages graph database operations through the Model Context Protocol. This server allows you to interact with Neo4j databases directly from AI assistants like Cursor and Claude Desktop.
You can run the server directly using npx without installation:
# Using a single connection string
NEO4J_CONNECTION=neo4j+s://your-instance.databases.neo4j.io,neo4j,your-password npx neo4j-mcpserver
# Or using separate environment variables
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io NEO4J_USER=neo4j NEO4J_PASSWORD=your-password npx neo4j-mcpserver
If you prefer a global installation:
npm install -g neo4j-mcpserver
Then run it:
NEO4J_CONNECTION=neo4j+s://your-instance.databases.neo4j.io,neo4j,your-password neo4j-mcpserver
You can connect to your Neo4j database using two methods:
NEO4J_CONNECTION=<uri>,<user>,<password>
NEO4J_URI=<your-uri>
NEO4J_USER=<your-user>
NEO4J_PASSWORD=<your-password>
You can also create a .env
file in your project root:
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_PASSWORD=your-password
To configure the Neo4j MCP server in Cursor:
Open Cursor Settings
Navigate to Features > MCP Servers
Click on the "+ Add New MCP Server" button
Fill out the following information:
env=NEO4J_URI=your-neo4j-uri,NEO4J_USER=your-neo4j-user,NEO4J_PASSWORD=your-neo4j-password npx -y @neobarrientos/neo4j_mcpserver
Important: Replace the credentials with your actual Neo4j database credentials.
The server provides the neo4j-query
tool for executing Cypher queries against your Neo4j database.
Example usage in Cursor:
MATCH (n) RETURN n LIMIT 5
If you encounter issues connecting to your database:
Verify Neo4j Credentials
Path Issues
Tool Detection Issues
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.