Neo4j as Knowledge Graph for Claude via MCP
I wanted Claude to query a local knowledge graph. Neo4j plus an MCP server is the shortest path. Here is the minimal local setup:
The Docker Compose file
A single Neo4j 5 service with persistent volumes and the APOC plugin enabled:
services:
neo4j:
image: neo4j:5
ports:
- "7474:7474" # Browser UI
- "7687:7687" # Bolt protocol
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
environment:
- NEO4J_AUTH=${NEO4J_AUTH:-neo4j/changeme}
- NEO4J_server_memory_heap_initial__size=512m
- NEO4J_server_memory_heap_max__size=1G
- NEO4J_server_memory_pagecache_size=512m
- NEO4J_PLUGINS=["apoc"]
restart: unless-stopped
volumes:
neo4j_data:
neo4j_logs:
The environment file
Credentials live in a .env file. Format is username/password:
# Neo4j credentials (format: username/password)
NEO4J_AUTH=neo4j/changeme
The MCP configuration
First, install the Neo4j MCP server locally so the neo4j-mcp binary is on your PATH.
Then drop a .mcp.json in the project root. Claude Code picks it up and starts the server over stdio:
{
"mcpServers": {
"neo4j": {
"type": "stdio",
"command": "neo4j-mcp",
"env": {
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "changeme",
"NEO4J_DATABASE": "neo4j"
}
}
}
}
Final words
Run docker compose up -d, open the Browser UI at http://localhost:7474, and seed a few nodes.
Start Claude Code in the project directory and it can now run Cypher queries against the graph through MCP.
Delete the neo4j_data volume to start over.