The MCP Neo4j Server provides integration between Neo4j graph database and Claude Desktop, enabling you to perform graph database operations through natural language interactions. It allows Claude to execute queries, create nodes and relationships, and more, all through conversational prompts.
Run the MCP server directly using npx:
npx @alanse/mcp-neo4j
Edit your Claude Desktop configuration file to include the Neo4j server:
{
"mcpServers": {
"neo4j": {
"command": "npx",
"args": ["@alanse/mcp-neo4j-server"],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your-password",
"NEO4J_DATABASE": "neo4j"
}
}
}
}
Install the MCP Neo4j Server for Claude Desktop using Smithery:
npx -y @smithery/cli install @alanse/mcp-neo4j-server --client claude
The server requires the following environment variables:
NEO4J_URI
: Neo4j database URI (default: bolt://localhost:7687)NEO4J_USERNAME
: Neo4j username (default: neo4j)NEO4J_PASSWORD
: Neo4j password (required)NEO4J_DATABASE
: Neo4j database name (default: neo4j)For Neo4j Enterprise users with multiple databases, you can specify which database to connect to:
{
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your-password",
"NEO4J_DATABASE": "myCustomDatabase"
}
}
This will connect to "myCustomDatabase" instead of the default "neo4j" database.
execute_query: Execute Cypher queries on the Neo4j database
create_node: Create a new node in the graph database
create_relationship: Create a relationship between two existing nodes
You can ask Claude questions like:
Example interaction:
User: "Show me all employees in the Sales department"
Claude: Let me query the database for Sales department employees.
[Executes query internally: MATCH (e:Employee)-[:WORKS_IN]->(d:Department {name: 'Sales'}) RETURN e.name, e.position]
Result:
- John Smith (Sales Manager)
- Sarah Johnson (Sales Representative)
- Mike Brown (Account Executive)
You can give instructions like:
Example interaction:
User: "Add a new person named John Doe who is 30 years old"
Claude: I'll create a new Person node with the provided information.
[Creates node internally with label 'Person' and properties {name: 'John Doe', age: 30}]
Result: Created new person node with ID: 123
You can request relationships like:
Example interaction:
User: "Make John Doe friends with Jane Smith"
Claude: I'll create a friendship relationship between these two people.
[Creates relationship internally: MATCH (a:Person {name: 'John Doe'}), (b:Person {name: 'Jane Smith'})
CREATE (a)-[:FRIENDS_WITH {since: '2024-01-05'}]->(b)]
Result: Created friendship relationship between John Doe and Jane Smith
You can perform more complex operations with natural language:
Example interaction:
User: "Find all products purchased by customers who live in New York"
Claude: I'll query the database for this information.
[Executes query internally:
MATCH (c:Customer {city: 'New York'})-[:PURCHASED]->(p:Product)
RETURN c.name, collect(p.name) as products]
Result:
- Alice Wilson: [Premium Coffee, Tea Set, Cookies]
- Bob Miller: [Premium Coffee, Water Bottle]
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "neo4j" '{"command":"npx","args":["@alanse/mcp-neo4j-server"],"env":{"NEO4J_URI":"bolt://localhost:7687","NEO4J_USERNAME":"neo4j","NEO4J_PASSWORD":"your-password"}}'
See the official Claude Code MCP documentation for more details.
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 > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"neo4j": {
"command": "npx",
"args": [
"@alanse/mcp-neo4j-server"
],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your-password"
}
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"neo4j": {
"command": "npx",
"args": [
"@alanse/mcp-neo4j-server"
],
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your-password"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect