Neo4j Graph Database MCP Server
Connect Claude Code to Neo4j for graph database operations. Explore schemas, run Cypher queries, visualize relationships, and get query optimization advice through the Model Context Protocol.
MCP Server Configuration
Add to .claude/settings.json:
{ "mcpServers": { "neo4j": { "command": "npx", "args": ["-y", "@neo4j/mcp-neo4j"], "env": { "NEO4J_URI": "bolt://localhost:7687", "NEO4J_USERNAME": "neo4j", "NEO4J_PASSWORD": "${NEO4J_PASSWORD}", "NEO4J_DATABASE": "neo4j" } } } }
Available Tools
| Tool | Description |
|---|---|
get-schema | Retrieve the full graph schema (node labels, relationship types, properties) |
run-cypher | Execute a Cypher query and return results |
explain-query | Get the execution plan for a Cypher query |
get-node-count | Count nodes by label |
get-relationship-count | Count relationships by type |
Common Cypher Patterns
Schema Exploration
// List all node labels with counts CALL db.labels() YIELD label RETURN label, size((:` + label + `)) AS count ORDER BY count DESC; // List all relationship types CALL db.relationshipTypes() YIELD relationshipType RETURN relationshipType; // Show property keys for a label MATCH (n:User) WITH n LIMIT 1 RETURN keys(n) AS properties;
Common Queries
// Find shortest path between two nodes MATCH path = shortestPath( (a:User {name: 'Alice'})-[*..6]-(b:User {name: 'Bob'}) ) RETURN path; // Recommendation engine: users who liked similar items MATCH (user:User {id: $userId})-[:LIKED]->(item:Item)<-[:LIKED]-(other:User) WITH other, count(item) AS commonLikes ORDER BY commonLikes DESC LIMIT 10 MATCH (other)-[:LIKED]->(rec:Item) WHERE NOT (user)-[:LIKED]->(rec) RETURN rec.name, count(other) AS score ORDER BY score DESC LIMIT 5; // Find circular dependencies MATCH path = (n:Module)-[:DEPENDS_ON*2..5]->(n) RETURN path;
Performance Tips
// Create indexes for frequently queried properties CREATE INDEX user_email FOR (u:User) ON (u.email); CREATE INDEX item_name FOR (i:Item) ON (i.name); // Use PROFILE to analyze query performance PROFILE MATCH (u:User)-[:PURCHASED]->(p:Product) WHERE u.country = 'US' RETURN p.category, count(*) AS purchases ORDER BY purchases DESC;
Setup
- Install Neo4j:
brew install neo4j(macOS) or use Docker:docker run -d --name neo4j \ -p 7474:7474 -p 7687:7687 \ -e NEO4J_AUTH=neo4j/your-password \ neo4j:latest - Set the
NEO4J_PASSWORDenvironment variable - Add the MCP configuration to
.claude/settings.json - Access Neo4j Browser at
http://localhost:7474for visual exploration
Security Notes
- Store database credentials in environment variables, never in settings.json directly
- Use a read-only user for exploration if you want to prevent accidental mutations
- The MCP server connects over Bolt protocol (encrypted by default in production)
- Consider using a dedicated database user with limited permissions for MCP access
- Avoid running
DELETEorDETACH DELETEqueries through MCP without careful review
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Database MCP Integration
MCP server configuration for connecting Claude Code to PostgreSQL, MySQL, and MongoDB databases. Enables schema inspection, query building, and migration generation.
Elevenlabs Server
Streamline your workflow with this official, elevenlabs, text, speech. Includes structured workflows, validation checks, and reusable patterns for audio.
Browser Use Portal
Powerful mcp for server, enables, agents, control. Includes structured workflows, validation checks, and reusable patterns for browser_automation.