Skip to main content

MCP Neo4j Knowledge Graph Memory Server

Project description

🧠🕸️ Neo4j Knowledge Graph Memory MCP Server

🌟 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 entity
        • type (string): Type of the entity
        • observations (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 entity
        • target (string): Name of target entity
        • relationType (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 to
        • contents (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 from
        • observations (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.3.0",
      "--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.3.0" ],
    "env": {
      "NEO4J_URL": "neo4j+s://xxxx.databases.neo4j.io",
      "NEO4J_USERNAME": "<your-username>",
      "NEO4J_PASSWORD": "<your-password>"
    }
  }
}

🌐 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 /api/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=/api/mcp/
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.3.0"
    ]
  }
}

🚀 Development

📦 Prerequisites

  1. Install uv (Universal Virtualenv):
# Using pip
pip install uv

# Using Homebrew on macOS
brew install uv

# Using cargo (Rust package manager)
cargo install uv
  1. Clone the repository and set up development environment:
# Clone the repository
git clone https://github.com/yourusername/mcp-neo4j-memory.git
cd mcp-neo4j-memory

# Create and activate virtual environment using uv
uv venv
source .venv/bin/activate  # On Unix/macOS
.venv\Scripts\activate     # On Windows

# Install dependencies including dev dependencies
uv pip install -e ".[dev]"

🐳 Docker

Build and run the Docker container:

# Build the image
docker build -t mcp/neo4j-memory:latest .

# Run the container
docker run -e NEO4J_URL="neo4j+s://xxxx.databases.neo4j.io" \
          -e NEO4J_USERNAME="your-username" \
          -e NEO4J_PASSWORD="your-password" \
          mcp/neo4j-memory:latest

📄 License

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_neo4j_memory-0.3.0.tar.gz (898.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_neo4j_memory-0.3.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_neo4j_memory-0.3.0.tar.gz.

File metadata

  • Download URL: mcp_neo4j_memory-0.3.0.tar.gz
  • Upload date:
  • Size: 898.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for mcp_neo4j_memory-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9588a645d38bce60c8523ba3eab7d7fffbf5a2d0cfd389066ae41f099e708c1c
MD5 2849b651bad9255fb4bf2b2a1a0f9ee8
BLAKE2b-256 954e719acb8b9b8c872939cb352d32224c43a3782f4ed3c3269d4a0409fa2fc4

See more details on using hashes here.

File details

Details for the file mcp_neo4j_memory-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_neo4j_memory-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1230baa2e2117eba03517f1c7e0ac9ed288a36e7d08d15220b54d3699b662bc7
MD5 ec913254ba080b0301693829b7df1432
BLAKE2b-256 3bab8c4ac5816332b3581bb3beaabf1263be85881119152a190854fb14325090

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page