/ Verzeichnis / Playground / Neo4j
● Offiziell neo4j-contrib 🔑 Eigener Schlüssel nötig

Neo4j

von neo4j-contrib · neo4j-contrib/mcp-neo4j

Query and evolve a Neo4j graph in Cypher via Claude — schema introspection plus read/write Cypher with guardrails.

Neo4j Labs' MCP collection covers Cypher execution (mcp-neo4j-cypher), schema management, and Aura admin. The default cypher server exposes read and write Cypher against any Bolt endpoint. Pair with a read-only Neo4j user for safe production exploration.

Warum nutzen

Hauptfunktionen

Live-Demo

In der Praxis

neo4j.replay ▶ bereit
0/0

Installieren

Wählen Sie Ihren Client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "neo4j": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  }
}

Öffne Claude Desktop → Settings → Developer → Edit Config. Nach dem Speichern neu starten.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "neo4j": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  }
}

Cursor nutzt das gleiche mcpServers-Schema wie Claude Desktop. Projektkonfiguration schlägt die globale.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "neo4j": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  }
}

Klicken Sie auf das MCP-Servers-Symbol in der Cline-Seitenleiste, dann "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "neo4j": {
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  }
}

Gleiche Struktur wie Claude Desktop. Windsurf neu starten zum Übernehmen.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "neo4j",
      "command": "uvx",
      "args": [
        "mcp-neo4j-cypher"
      ]
    }
  ]
}

Continue nutzt ein Array von Serverobjekten statt einer Map.

~/.config/zed/settings.json
{
  "context_servers": {
    "neo4j": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-neo4j-cypher"
        ]
      }
    }
  }
}

In context_servers hinzufügen. Zed lädt beim Speichern neu.

claude mcp add neo4j -- uvx mcp-neo4j-cypher

Einzeiler. Prüfen mit claude mcp list. Entfernen mit claude mcp remove.

Anwendungsfälle

Praxisnahe Nutzung: Neo4j

Explore an unfamiliar graph schema in 5 minutes

👤 Engineers / analysts inheriting a Neo4j DB ⏱ ~15 min beginner

Wann einsetzen: You got handed a graph DB with no docs. You need a mental model before you can write useful queries.

Voraussetzungen
  • Neo4j Bolt URL + user/passwordNEO4J_URI=bolt://host:7687, NEO4J_USERNAME, NEO4J_PASSWORD
  • Read-only user recommended for explorationCREATE USER claude SET PASSWORD '...' SET ROLES reader
Ablauf
  1. Get schema overview
    Call get_neo4j_schema. Summarize node labels, relationship types, and the most common (label)-[rel]->(label) patterns.✓ Kopiert
    → Schema summary with sample triples
  2. Sample representative nodes
    For the 3 most common labels, MATCH (n:Label) RETURN n LIMIT 3 each. Describe what each label seems to represent.✓ Kopiert
    → Semantic descriptions of labels
  3. Draw the likely ER model
    Based on schema + samples, describe in prose the 'entity' story of this graph. What's the main object, what connects to it, what's peripheral?✓ Kopiert
    → Clear domain model description

Ergebnis: A one-page domain model you can validate with the original authors.

Fallstricke
  • Sampling tiny graphs gives misleading patterns — Also MATCH (n)-[r]->() RETURN type(r), count(*) to see which rels dominate
Kombinieren mit: filesystem

Write graph queries to detect fraud rings

👤 Risk / fraud analysts ⏱ ~40 min advanced

Wann einsetzen: You suspect shared-device or shared-address fraud rings across accounts.

Voraussetzungen
  • Graph with User, Device, Address, Payment nodes and :USED, :LIVES_AT, :PAID relationships — Typical fraud-graph shape
Ablauf
  1. Find shared devices
    Find devices used by 3+ different users in the last 30 days. Return device_id + list of user_ids + last-used ts per pair.✓ Kopiert
    → Ring candidates
  2. Score by connected-component size
    Using GDS or pure Cypher, compute connected components over User-(:USED)-Device-(:USED)-User. Return top 10 components by size.✓ Kopiert
    → Suspicious clusters
  3. Produce an actionable list
    For each top cluster, list distinct users, total transaction volume, and earliest/latest activity. Flag clusters > $10k as high-priority review.✓ Kopiert
    → Analyst queue entries

Ergebnis: A prioritized fraud-review queue with the exact Cypher preserved.

Fallstricke
  • Naïve traversals blow up on hubs (shared public wifi device with 10k users) — Cap depth and filter out hub nodes by degree before traversing
Kombinieren mit: postgres

Prototype a content recommendation query

👤 Product engineers building 'users who also liked' ⏱ ~30 min intermediate

Wann einsetzen: You have User-LIKED->Item and want to recommend items from similar users.

Ablauf
  1. Pick a user and find neighbors
    For user <id>, find 20 users who share the most LIKED items. Return user_id and overlap count.✓ Kopiert
    → Similar users ranked
  2. Recommend items those users liked
    For those top 20 similar users, list items they liked that <id> has NOT liked. Rank by number of similar users who liked it.✓ Kopiert
    → Top-N recommendations
  3. Turn it into a reusable query
    Parameterize as a callable Cypher with $user_id; add indexes needed for speed.✓ Kopiert
    → Production-ready query + CREATE INDEX statements

Ergebnis: A working collaborative-filtering query, fast enough to serve online.

Fallstricke
  • Forgetting an index on :User(id) makes startup queries linear — CREATE INDEX FOR (u:User) ON (u.id) and EXPLAIN to confirm it's used

Load relational data into Neo4j from a staging table

👤 Data engineers moving from SQL to graph ⏱ ~40 min advanced

Wann einsetzen: You have users + follows in Postgres and want a graph representation.

Voraussetzungen
  • Writable Neo4j user — Role with CREATE on the target database
Ablauf
  1. Plan the node/edge mapping
    Given tables users(id, name) and follows(from_id, to_id), propose the Neo4j model. Label(s)? Relationship direction?✓ Kopiert
    → (:User {id,name})-[:FOLLOWS]->(:User)
  2. Create constraints first
    Generate CREATE CONSTRAINT FOR (u:User) REQUIRE u.id IS UNIQUE. Run it.✓ Kopiert
    → Constraint created
  3. Bulk load with MERGE
    From the provided user rows, run UNWIND $rows AS r MERGE (:User {id:r.id}) ... then follows with MERGE (a)-[:FOLLOWS]->(b). Batch 10k at a time.✓ Kopiert
    → All rows loaded idempotently

Ergebnis: A re-runnable ETL that loads your relational data into a graph shape.

Fallstricke
  • CREATE instead of MERGE creates duplicate nodes on re-run — Always MERGE for upserts, and require a uniqueness constraint before bulk MERGE for speed
Kombinieren mit: postgres

Answer natural-language questions over a knowledge graph

👤 Internal teams with a domain KG ⏱ ~25 min intermediate

Wann einsetzen: You built a small ontology (products, features, customers) and want Claude to answer 'which customers use feature X' without learning Cypher.

Ablauf
  1. Ground Claude in the schema
    Here's the schema [paste get_neo4j_schema output]. From now on, translate my questions to Cypher before running them.✓ Kopiert
    → Claude echoes the schema understanding
  2. Ask a question, get Cypher + answer
    Which customers use feature 'export-csv' in the last quarter?✓ Kopiert
    → Cypher shown + result table
  3. Refine when Cypher is wrong
    That Cypher missed the :USED relationship to Session. Fix it to go through sessions.✓ Kopiert
    → Corrected Cypher re-run

Ergebnis: A lightweight NL-to-Cypher interface for non-technical teammates.

Fallstricke
  • Claude invents labels that don't exist — Pin it: 'only use labels/rels from the provided schema; otherwise say unknown'

Kombinationen

Mit anderen MCPs für 10-fache Wirkung

neo4j + postgres

Sync relational data to a graph representation

Pull users + follows from Postgres, then MERGE into Neo4j as (:User)-[:FOLLOWS]->(:User).✓ Kopiert
neo4j + qdrant

Graph-enhanced RAG: use Qdrant for semantic recall, Neo4j for precise relationships

Qdrant finds docs similar to the question; then traverse Neo4j from matched entities to pull structured facts for the answer.✓ Kopiert
neo4j + filesystem

Export a Cypher-generated report as CSV/Markdown

Run the fraud-ring Cypher, export top 50 clusters as /reports/fraud-<date>.csv.✓ Kopiert

Werkzeuge

Was dieses MCP bereitstellt

WerkzeugEingabenWann aufrufenKosten
get_neo4j_schema Always first in a new session free
read_neo4j_cypher query: str, params?: object Any MATCH / RETURN — read-only free
write_neo4j_cypher query: str, params?: object CREATE/MERGE/SET/DELETE — mutations free

Kosten & Limits

Was der Betrieb kostet

API-Kontingent
Bounded by your Neo4j instance. Aura Free: 200k nodes/400k rels.
Tokens pro Aufruf
Schema: ~500 tokens. Query results: depends on rows+properties.
Kosten in €
Free for Community / self-hosted. Aura Free tier exists. Aura paid from ~$65/mo.
Tipp
Always EXPLAIN first on large graphs; a missing index on a startup label turns a 5ms query into a 5min scan.

Sicherheit

Rechte, Secrets, Reichweite

Minimale Scopes: reader role for read-only exploration
Credential-Speicherung: NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD in env
Datenabfluss: Direct Bolt connection to your Neo4j (self-hosted or Aura)
Niemals gewähren: admin role PUBLIC write access

Fehlerbehebung

Häufige Fehler und Lösungen

ServiceUnavailable: Connection refused

Neo4j not running or wrong Bolt port (default 7687). Check with cypher-shell -a bolt://host:7687.

Prüfen: nc -zv host 7687
Neo.ClientError.Security.Unauthorized

Wrong username/password. Reset via CALL dbms.security.changePassword('new') from an admin session.

Neo.ClientError.Statement.SyntaxError

Claude's Cypher has a typo — paste the exact error, ask for a corrected query.

Writes fail: Write operation not allowed in read-only mode

You're connected with a reader role; switch to a user with WRITE or use a separate writer connection.

Alternativen

Neo4j vs. andere

AlternativeWann stattdessenKompromiss
Memgraph MCPYou need streaming graph analytics; Memgraph is Cypher-compatibleSmaller ecosystem, fewer hosted options
ArangoDB MCPYou want multi-model (graph + document + KV)AQL instead of Cypher; learning curve
Postgres + Apache AGEYou're mostly relational with some graph needsGraph performance worse than native Neo4j on large traversals

Mehr

Ressourcen

📖 Offizielle README auf GitHub lesen

🐙 Offene Issues ansehen

🔍 Alle 400+ MCP-Server und Skills durchsuchen