Skip to main content

🧠🕸️ 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 create some entities with constraints
Create a "用户管理" (User Management) entity with operation type "CRUD", node type "功能模块", point 5, 
and constraints: 必须 have "用户认证" and "权限验证", 禁止 have "超级管理员权限" for regular users.

Results in Claude calling the create_entities and create_relations tools with the new constraint-based structure.

📦 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_memories

    • Search for nodes based on a query
    • Input:
      • query (string): Search query matching names, operation types, node types, descriptions
    • Returns: Matching subgraph
  • find_memories_by_name

    • 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
        • operation_type (string): Operation type of the entity
        • node_type (string): Node type of the entity
        • point (int): Level/point of the entity
        • description (string): Chinese description of the entity name
        • node_description (string): Chinese description of the node type
        • constraint (object): Constraint conditions with "必须" (required) and "禁止" (forbidden) arrays
        • label (array of strings): Labels for 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
        • description (string): Description of the 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

📝 Constraint Management Tools

  • add_constraints

    • Add new constraints to existing entities
    • Input:
      • constraints: Array of objects with:
        • entityName (string): Entity to add constraints to
        • constraint (object): Constraint conditions with "必须" (required) and "禁止" (forbidden) arrays
    • Returns: Added constraint details
  • delete_constraints

    • Delete specific constraints from entities
    • Input:
      • deletions: Array of objects with:
        • entityName (string): Entity to delete constraints from
        • constraint (object): Constraint conditions to remove
    • Returns: Success confirmation

🔧 Usage with Claude Desktop

💾 Installation

pip install neo4j-mcp-memory-scccy

⚙️ Configuration

Add the server to your claude_desktop_config.json with configuration of:

"mcpServers": {
  "neo4j": {
    "command": "uvx",
    "args": [
      "neo4j-mcp-memory-scccy@0.2.1",
      "--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": [ "neo4j-mcp-memory-scccy@0.2.1" ],
    "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/)
neo4j-mcp-memory-scccy --transport http

# Custom HTTP configuration
neo4j-mcp-memory-scccy --transport http --host 0.0.0.0 --port 8080 --path /api/mcp/

Environment variables for HTTP configuration:

export NEO4J_TRANSPORT=http
export NEO4J_MCP_SERVER_HOST=0.0.0.0
export NEO4J_MCP_SERVER_PORT=8080
export NEO4J_MCP_SERVER_PATH=/api/mcp/
neo4j-mcp-memory-scccy

🔄 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-mcp-memory-scccy:0.2.1"
    ]
  }
}

🚀 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/neo4j-mcp-memory-scccy.git
cd neo4j-mcp-memory-scccy

# 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-mcp-memory-scccy: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-mcp-memory-scccy: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.

Metadata

Release files for neo4j-mcp-memory-scccy 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neo4j-mcp-memory-scccy 0.2.2
File Size Uploaded
neo4j_mcp_memory_scccy-0.2.2.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neo4j-mcp-memory-scccy 0.2.2
File Interpreter ABI Platform
neo4j_mcp_memory_scccy-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.4 kB

Release files / neo4j_mcp_memory_scccy-0.2.2.tar.gz

Download URL neo4j_mcp_memory_scccy-0.2.2.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c97c047f67a1dc0ef10685c65be8f4b7db3626f21b8b964509b587a8cc22a414
BLAKE2b-256 checksum
How to use checksums
9f04996e220917611c15ec858fafde9ab88e5169df93f5e63831924667fac14b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / neo4j_mcp_memory_scccy-0.2.2-py3-none-any.whl

Download URL neo4j_mcp_memory_scccy-0.2.2-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2c5267b6139af41f769d7eadebc1a162876021aaca2820832c0f213887c77c4
BLAKE2b-256 checksum
How to use checksums
5d75526d22f945e8c1262a809d79c5c489ed4c7be3bb4c6d4aa73c7faa5cf31b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page