Skip to main content
Glama
neo4j-kg-mcp

neo4j-kg-mcp

by happy-momo

neo4j-kg-mcp

Neo4j Knowledge Graph MCP Server for AI Agents — zero-LLM-config tool server that turns PDFs, Word, Excel and plain text into a Neo4j knowledge graph.


Why this exists

Most MCP knowledge-graph servers embed private LLM calls and ask you to configure yet another API key. neo4j-kg-mcp flips that: the host platform's LLM — Claude, GPT, Gemini, DeepSeek inside your agent — performs entity-relationship extraction in a conversational chunk loop, while the server handles the graph-write layer: document parsing, ontology validation, parameterized Cypher generation, and auditable Neo4j writes.

It is the missing graph construction block for the MCP ecosystem:

  • Zero LLM configuration — the server ships with no LLM dependency. Configure one Neo4j connection and you're done.

  • Schema-driven & interactive — define your ontology in YAML, validate it conversationally with the agent, iterate until it passes.

  • Long-task friendly — work proceeds chunk-by-chunk in the conversation, survives server restarts, and never duplicates nodes.


Related MCP server: Neo4j MCP Knowledge Graph Server

Features

Feature

Description

🔌 MCP native

8 clean tools; works over stdio (Claude Code, Cursor) or Streamable HTTP (WorkBuddy, Dify, n8n, custom agents)

🤖 Agent = engine

No embedded LLM, no API keys — extraction quality follows your platform's model

📚 Multi-format documents

PDF, DOCX/DOC, XLSX/XLS, TXT — single file, folder batch, or inline text

📝 Ontology (Schema) management

Preset templates + YAML; validate_schema returns structured errors the agent can fix iteratively

🧱 Enforced constraints

Entity types, relation types and endpoints are validated against your ontology before writing

🛡️ Secure by design

Parameterized Cypher (injection-safe), sanitized identifiers, read-only query whitelist

⏸️ Resumable

Progress persists to disk per job; resume after a crash or server restart

♻️ Idempotent writes

MERGE semantics — resuming or re-submitting a chunk never creates duplicate nodes


Quick demo

User:  Ingest docs/product-report.pdf using this schema
 1. Agent drafts a Schema → validate_schema → fixes per error list → passes
 2. start_extraction(document={path|text}, schema=final)
      ← {job_id, total_chunks, chunk_text, instructions}
 3. Agent reads the chunk, produces triples → submit_triples
      ← {accepted, rejected:[{triple, reason}], next_chunk}
 4. …loop until done…
 5. get_job_status → summary; query_graph → verify in Neo4j

You can interrupt at any block and redirect the agent ("normalize company names"), effective from the next chunk.


Install & configure

Prerequisites

  • Python 3.10+

  • A running Neo4j 5.x instance

1. Install

pip install -e neo4j-kg-mcp
# or
pip install -r requirements.txt

2. Claude Code / Cursor (stdio)

Add this to your .mcp.json:

{
  "mcpServers": {
    "neo4j-kg-mcp": {
      "command": "python",
      "args": ["-m", "kg_mcp.server"],
      "env": {
        "NEO4J_URI": "bolt://localhost:7687",
        "NEO4J_USER": "neo4j",
        "NEO4J_PASSWORD": "your_password"
      }
    }
  }
}

No NEO4J_* env vars? Still fine — call configure_neo4j in the conversation and pass credentials there.

3. WorkBuddy / Dify / n8n (Streamable HTTP)

python -m kg_mcp.server --http --host 0.0.0.0 --port 8765

Point your platform at: http://<host>:8765/mcp

Environment variables

Variable

Default

Description

NEO4J_URI

bolt://localhost:7687

Neo4j Bolt address

NEO4J_USER

neo4j

Username

NEO4J_PASSWORD

—

Password (optional if calling configure_neo4j)

Job progress lives in .data/jobs/<job_id>/; delete the folder to reset.


Tools (8)

Tool

Purpose

configure_neo4j

Set & test the Neo4j connection

list_schema_templates

List built-in ontology templates (full YAML)

validate_schema

Validate ontology YAML; return structured errors for agent iteration

start_extraction

Parse the document, chunk it, return chunk 0 + instructions

submit_triples

Validate & write a chunk's triples; return the next chunk

get_job_status

Query job progress

resume_extraction

Resume a job from its first unfinished chunk

query_graph

Read-only Cypher query (whitelist: MATCH/RETURN/WITH/ORDER BY/LIMIT)

Sample schema (ontology) YAML

entities:
  - name: Person
    properties: [name, role]
  - name: Company
    properties: [name, industry]

relationships:
  - {head: Person, relation: worksAt, tail: Company}
  - {head: Person, relation: develops, tail: Product}

Architecture

┌─────────────────────────────┐
│  Claude Code / WorkBuddy    │
│  (platform LLM = engine)    │
│  read chunk → triples       │◄── MCP tool calls
└──────────┬──────────────────┘
           ▼
┌─────────────────────────────┐
│  neo4j-kg-mcp (no LLM)      │
│  doc_loader · schema_mgr    │
│  triple validation · cypher │
│  graph_store · job_store    │
└──────────┬──────────────────┘
           ▼
         ┌──────┐
         │Neo4j │
         └──────┘

Design decisions

Decision

Rationale

No embedded LLM

Install-and-run (configure Neo4j only); quality follows your platform's model; cost stays on your existing subscription

Chunked conversational loop

No context overflow on big docs; ~2000-char chunks keep extraction precise; per-chunk persistence enables resume

Reject + explain, not silent filter

Rejected triples return their reason to the agent so it can fix and resubmit — no invisible data loss

MERGE writes

Idempotent: resume / re-submit never duplicates nodes or edges


Development

pytest tests/ -v        # unit + simulated end-to-end

Unit tests cover schema validation, triple validation (rejection reasons), injection-safe Cypher, job persistence and resume. An end-to-end script exercises the full MCP flow against a real Neo4j.


License

MIT


Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables document ingestion and typed knowledge graph queries through Claude MCP tools, allowing agents to extract, store, and retrieve typed entities and relations from documents.
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A containerized FastAPI + MCP server that lets LLM agents inject structured entities and relationships into a Neo4j graph database with safe Cypher execution.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables persona-grounded retrieval-augmented generation over your own documents by building a Neo4j knowledge graph and exposing tools for search, context, persona briefs, and graph queries via MCP.
      MIT