Mcp Neo4j Memory
io.github.neo4j-contrib/mcp-neo4j-memory · 958 stars · Python · MIT
MCP server MCP Neo4j Knowledge Graph Memory Server
Install
pip install mcp-neo4j-memoryThese repos do not share one command. When an entry shows a command, it was copied as published. Check the repo's README before you run it.
Published as
- PyPI
mcp-neo4j-memorystdio
From the server's entry in the official MCP Registry.
Configuration
| Name | Set as | What it is |
|---|---|---|
NEO4J_URIRequired | Env var | Neo4j connection URI |
NEO4J_USERNAMERequired | Env var | Neo4j username |
NEO4J_PASSWORDRequired · Secret | Env var | Neo4j password |
NEO4J_DATABASEOptional | Env var | Neo4j database name |
NEO4J_NAMESPACEOptional | Env var | Tool namespace prefix |
Files
🧠🕸️ Neo4j Knowledge Graph Memory MCP Server
mcp-name: io.github.neo4j-contrib/mcp-neo4j-memory
🌟 Overview
A Model Context Protocol (MCP) server implementation that provides persistent memory capabilities through Neo4j graph database integration.
By storing information in a graph structure, this server maintains complex relationships between entities as memory nodes and enables long-term retention of knowledge that can be queried and analyzed across multiple conversations or sessions.
With Neo4j Aura you can host your own database server for free or share it with your collaborators. Otherwise you can run your own Neo4j server locally.
The MCP server leverages Neo4j's graph database capabilities to create an interconnected knowledge base that serves as an external memory system. Through Cypher queries, it allows exploration and retrieval of stored information, relationship analysis between different data points, and generation of insights from the accumulated knowledge. This memory can be further enhanced with Claude's capabilities.
🕸️ Graph Schema
Memory- A node representing an entity with a name, type, and observations.Relationship- A relationship between two entities with a type.
🔍 Usage Example
Let's add some memories
I, Michael, living in Dresden, Germany work at Neo4j which is headquartered in Sweden with my colleagues Andreas (Cambridge, UK) and Oskar (Gothenburg, Sweden)
I work in Product Management, Oskar in Engineering and Andreas in Developer Relations.
Results in Claude calling the create_entities and create_relations tools.
📦 Components
🔧 Tools
The server offers these core tools:
#### 🔎 Query Tools
read_graph- Read the entire knowledge graph
- No input required
- Returns: Complete graph with entities and relations
search_nodes- Search for nodes based on a query
- Input:
query(string): Search query matching names, types, observations- Returns: Matching subgraph
find_nodes- Find specific nodes by name
- Input:
names(array of strings): Entity names to retrieve- Returns: Subgraph with specified nodes
#### ♟️ Entity Management Tools
create_entities- Create multiple new entities in the knowledge graph
- Input:
entities: Array of objects with:name(string): Name of the entitytype(string): Type of the entityobservations(array of strings): Initial observations about the entity- Returns: Created entities
delete_entities- Delete multiple entities and their associated relations
- Input:
entityNames(array of strings): Names of entities to delete- Returns: Success confirmation
#### 🔗 Relation Management Tools
create_relations- Create multiple new relations between entities
- Input:
relations: Array of objects with:source(string): Name of source entitytarget(string): Name of target entityrelationType(string): Type of relation- Returns: Created relations
delete_relations- Delete multiple relations from the graph
- Input:
relations: Array of objects with same schema as create_relations- Returns: Success confirmation
#### 📝 Observation Management Tools
add_observations- Add new observations to existing entities
- Input:
observations: Array of objects with:entityName(string): Entity to add tocontents(array of strings): Observations to add- Returns: Added observation details
delete_observations- Delete specific observations from entities
- Input:
deletions: Array of objects with:entityName(string): Entity to delete fromobservations(array of strings): Observations to remove- Returns: Success confirmation
🔧 Usage with Claude Desktop
💾 Installation
pip install mcp-neo4j-memory
⚙️ Configuration
Add the server to your claude_desktop_config.json with configuration of:
"mcpServers": {
"neo4j": {
"command": "uvx",
"args": [
"mcp-neo4j-memory@0.4.5",
"--db-url",
"neo4j+s://xxxx.databases.neo4j.io",
"--username",
"<your-username>",
"--password",
"<your-password>"
]
}
}
Alternatively, you can set environment variables:
"mcpServers": {
"neo4j": {
"command": "uvx",
"args": [ "mcp-neo4j-memory@0.4.5" ],
"env": {
"NEO4J_URL": "neo4j+s://xxxx.databases.neo4j.io",
"NEO4J_USERNAME": "<your-username>",
"NEO4J_PASSWORD": "<your-password>"
}
}
}
#### Namespacing For multi-tenant deployments, add --namespace to prefix tool names:
"args": [ "mcp-neo4j-memory@0.4.5", "--namespace", "myapp", "--db-url", "..." ]
Tools become: myapp-read_graph, myapp-create_entities, etc.
Can also use NEO4J_NAMESPACE environment variable.
🌐 HTTP Transport Mode
The server supports HTTP transport for web-based deployments and microservices:
# Basic HTTP mode (defaults: host=127.0.0.1, port=8000, path=/mcp/)
mcp-neo4j-memory --transport http
# Custom HTTP configuration
mcp-neo4j-memory --transport http --host 127.0.0.1 --port 8080 --path /mcp/
Environment variables for HTTP configuration:
export NEO4J_TRANSPORT=http
export NEO4J_MCP_SERVER_HOST=127.0.0.1
export NEO4J_MCP_SERVER_PORT=8080
export NEO4J_MCP_SERVER_PATH=/mcp/
export NEO4J_NAMESPACE=myapp
mcp-neo4j-memory
🔄 Transport Modes
The server supports three transport modes:
- STDIO (default): Standard input/output for local tools and Claude Desktop
- SSE: Server-Sent Events for web-based deployments
- HTTP: Streamable HTTP for modern web deployments and microservices
🐳 Using with Docker
"mcpServers": {
"neo4j": {
"command": "docker",
"args": [
"run",
"--rm",
"-e", "NEO4J_URL=neo4j+s://xxxx.databases.neo4j.io",
"-e", "NEO4J_USERNAME=<your-username>",
"-e", "NEO4J_PASSWORD=<your-password>",
"mcp/neo4j-memory:0.4.5"
]
}
}
🔒 Security Protection
The server includes comprehensive security protection with secure defaults that protect against common web-based attacks while preserving full MCP functionality when using HTTP transport.
🛡️ DNS Rebinding Protection
TrustedHost Middleware validates Host headers to prevent DNS rebinding attacks:
Secure by Default:
- Only
localhostand127.0.0.1hosts are allowed by default
Environment Variable:
export NEO4J_MCP_SERVER_ALLOWED_HOSTS="example.com,www.example.com"
🌐 CORS Protection
Cross-Origin Resource Sharing (CORS) protection blocks browser-based requests by default:
Environment Variable:
export NEO4J_MCP_SERVER_ALLOW_ORIGINS="https://example.com,https://app.example.com"
🔧 Complete Security Configuration
Development Setup:
mcp-neo4j-memory --transport http \
--allowed-hosts "localhost,127.0.0.1" \
--allow-origins "http://localhost:3000"
Production Setup:
mcp-neo4j-memory --transport http \
--allowed-hosts "example.com,www.example.com" \
--allow-origins "https://example.com,https://app.example.com"
🚨 Security Best Practices
For allow_origins:
- Be specific:
["https://example.com", "https://example.com"] - Never use
"*"in production with credentials - Use HTTPS origins in production
For allowed_hosts:
- Include your actual domain:
["example.com", "www.example.com"] - Include localhost only for development
- Never use
"*"unless you understand the risks
🐳 Docker Deployment
The Neo4j Memory MCP server can be deployed using Docker for remote deployments. Docker deployment should use HTTP transport for web accessibility. In order to integrate this deployment with applications like Claude Desktop, you will have to use a proxy in your MCP configuration such as mcp-remote.
📦 Using Your Built Image
After building locally with docker build -t mcp-neo4j-memory:latest .:
# Run with http transport (default for Docker)
docker run --rm -p 8000:8000 \
-e NEO4J_URI="bolt://host.docker.internal:7687" \
-e NEO4J_USERNAME="neo4j" \
-e NEO4J_PASSWORD="password" \
-e NEO4J_DATABASE="neo4j" \
-e NEO4J_TRANSPORT="http" \
-e NEO4J_MCP_SERVER_HOST="0.0.0.0" \
-e NEO4J_MCP_SERVER_PORT="8000" \
-e NEO4J_MCP_SERVER_PATH="/mcp/" \
mcp/neo4j-memory:latest
# Run with security middleware for production
docker run --rm -p 8000:8000 \
-e NEO4J_URI="bolt://host.docker.internal:7687" \
-e NEO4J_USERNAME="neo4j" \
-e NEO4J_PASSWORD="password" \
-e NEO4J_DATABASE="neo4j" \
-e NEO4J_TRANSPORT="http" \
-e NEO4J_MCP_SERVER_HOST="0.0.0.0" \
-e NEO4J_MCP_SERVER_PORT="8000" \
-e NEO4J_MCP_SERVER_PATH="/mcp/" \
-e NEO4J_MCP_SERVER_ALLOWED_HOSTS="example.com,www.example.com" \Facts
- Kind
- MCP server
- Repo
- io.github.neo4j-contrib/mcp-neo4j-memory
- Group
- Uncategorized
- Stars
- 958
- License
- MIT
- Language
- Python
- Last push
- 2026-09-09
- Forks
- 262
- MCP Registry
- io.github.neo4j-contrib/mcp-neo4j-memory
- Topics
- database, mcp, mcp-server, neo4j, stdio
- 1Everythingmodelcontextprotocol/serversThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.85.8k
- 2Fetchmodelcontextprotocol/serversA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.85.8k
- 3Gitmodelcontextprotocol/serversA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.85.8k
- 4Memorymodelcontextprotocol/serversA basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats.85.8k
- 5Sequential Thinkingmodelcontextprotocol/serversAn MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.85.8k
- 6Timemodelcontextprotocol/serversA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.85.8k