|
| 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. |
0 commit comments