Skip to content

Commit f67d6cf

Browse files
committed
Python implementation Neo4j Memory server
1 parent 962ccb2 commit f67d6cf

File tree

17 files changed

+1379
-666
lines changed

17 files changed

+1379
-666
lines changed

servers/mcp-neo4j-memory/README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Neo4j Knowledge Graph Memory MCP Server
2+
3+
## Overview
4+
5+
A Model Context Protocol (MCP) server implementation that provides persistent memory capabilities through Neo4j graph database integration.
6+
7+
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.
8+
9+
With [Neo4j Aura](https://console.neo4j.io) you can host your own database server for free or share it with your collaborators. Otherwise you can run your own Neo4j server locally.
10+
11+
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.
12+
13+
### Graph Schema
14+
15+
* `Memory` - A node representing an entity with a name, type, and observations.
16+
* `Relationship` - A relationship between two entities with a type.
17+
18+
## Components
19+
20+
### Resources
21+
22+
### Prompts
23+
24+
### Tools
25+
26+
The server offers these core tools:
27+
28+
#### Query Tools
29+
- `read_graph`
30+
- Read the entire knowledge graph
31+
- No input required
32+
- Returns: Complete graph with entities and relations
33+
34+
- `search_nodes`
35+
- Search for nodes based on a query
36+
- Input:
37+
- `query` (string): Search query matching names, types, observations
38+
- Returns: Matching subgraph
39+
40+
- `find_nodes`
41+
- Find specific nodes by name
42+
- Input:
43+
- `names` (array of strings): Entity names to retrieve
44+
- Returns: Subgraph with specified nodes
45+
46+
#### Entity Management Tools
47+
- `create_entities`
48+
- Create multiple new entities in the knowledge graph
49+
- Input:
50+
- `entities`: Array of objects with:
51+
- `name` (string): Name of the entity
52+
- `type` (string): Type of the entity
53+
- `observations` (array of strings): Initial observations about the entity
54+
- Returns: Created entities
55+
56+
- `delete_entities`
57+
- Delete multiple entities and their associated relations
58+
- Input:
59+
- `entityNames` (array of strings): Names of entities to delete
60+
- Returns: Success confirmation
61+
62+
#### Relation Management Tools
63+
- `create_relations`
64+
- Create multiple new relations between entities
65+
- Input:
66+
- `relations`: Array of objects with:
67+
- `source` (string): Name of source entity
68+
- `target` (string): Name of target entity
69+
- `relationType` (string): Type of relation
70+
- Returns: Created relations
71+
72+
- `delete_relations`
73+
- Delete multiple relations from the graph
74+
- Input:
75+
- `relations`: Array of objects with same schema as create_relations
76+
- Returns: Success confirmation
77+
78+
#### Observation Management Tools
79+
- `add_observations`
80+
- Add new observations to existing entities
81+
- Input:
82+
- `observations`: Array of objects with:
83+
- `entityName` (string): Entity to add to
84+
- `contents` (array of strings): Observations to add
85+
- Returns: Added observation details
86+
87+
- `delete_observations`
88+
- Delete specific observations from entities
89+
- Input:
90+
- `deletions`: Array of objects with:
91+
- `entityName` (string): Entity to delete from
92+
- `observations` (array of strings): Observations to remove
93+
- Returns: Success confirmation
94+
95+
## Usage with Claude Desktop
96+
97+
### Released Package
98+
99+
Can be found on PyPi https://pypi.org/project/mcp-neo4j-memory/
100+
101+
Add the server to your `claude_desktop_config.json` with configuration of
102+
103+
* db-url (for [Neo4j Aura](https://console.neo4j.io) `neo4j+s://xxxx.databases.neo4j.io` for local `bolt://localhost`)
104+
* username
105+
* password
106+
107+
```json
108+
"mcpServers": {
109+
"neo4j": {
110+
"command": "uvx",
111+
"args": [
112+
"mcp-neo4j-memory",
113+
"--db-url",
114+
"neo4j+s://xxxx.databases.neo4j.io",
115+
"--username",
116+
"<your-username>",
117+
"--password",
118+
"<your-password>"
119+
]
120+
}
121+
}
122+
```
123+
124+
### Development
125+
126+
```json
127+
# Add the server to your claude_desktop_config.json
128+
"mcpServers": {
129+
"neo4j": {
130+
"command": "uv",
131+
"args": [
132+
"--directory",
133+
"parent_of_servers_repo/mcp-neo4j/servers/mcp-neo4j-memory/src/mcp_neo4j_memory",
134+
"run",
135+
"mcp-neo4j-memory",
136+
"--db-url",
137+
"bolt://localhost",
138+
"--username",
139+
"neo4j",
140+
"--password",
141+
"<your-password>"
142+
]
143+
}
144+
}
145+
```
146+
147+
## License
148+
149+
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

servers/mcp-neo4j-memory/eslint.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

servers/mcp-neo4j-memory/jest.config.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

servers/mcp-neo4j-memory/project.json

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = "mcp-neo4j-memory"
3+
version = "0.1.1"
4+
description = "MCP Neo4j Knowledge Graph Memory Server"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"mcp>=0.10.0",
9+
"neo4j>=5.26.0",
10+
]
11+
12+
[build-system]
13+
requires = ["hatchling"]
14+
build-backend = "hatchling.build"
15+
16+
[tool.uv]
17+
dev-dependencies = [
18+
"pyright>=1.1.389",
19+
"pytest>=8.3.5",
20+
"pytest-asyncio>=0.25.3",
21+
]
22+
23+
[project.scripts]
24+
mcp-neo4j-memory = "mcp_neo4j_memory:main"
25+
26+
[tool.pytest.ini_options]
27+
pythonpath = [
28+
"src"
29+
]

servers/mcp-neo4j-memory/src/assets/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)