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 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.

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

neo4j_mcp_memory_scccy-0.2.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

neo4j_mcp_memory_scccy-0.2.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file neo4j_mcp_memory_scccy-0.2.1.tar.gz.

File metadata

  • Download URL: neo4j_mcp_memory_scccy-0.2.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for neo4j_mcp_memory_scccy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b249453ea61e4d471ac4391466f40f92a8b66dac1082d0834c6e7d283e88770f
MD5 2bff974c59dd168abfc008bb07eef16f
BLAKE2b-256 fadd05402d281ebae23c0f9be09af054b13e5ee21cc9b8def3ec6a1bf039595b

See more details on using hashes here.

File details

Details for the file neo4j_mcp_memory_scccy-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for neo4j_mcp_memory_scccy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8010190a6f43ce377c406ef80bd42123e8dac6720a57c19d996b908429f75e42
MD5 4ca76104a01b9f6b465dce0510ec5693
BLAKE2b-256 5d42b979a59abe019feba58af0b79c7c3dc1a88e963cf5f4cfac0b50640b64e5

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