Lucid Lineage GraphRAG MCP
Provides tools to query and manage a Neo4j knowledge graph, enabling tracing of asset lineage, identification of co-location 'blast radius', compliance boundary checks, audit finding logging and retrieval, and cross-boundary leak scans.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Lucid Lineage GraphRAG MCPtrace the lineage of the customer payment dataset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Status: Personal Exploratory PoC β feature-complete for the current phase
Lucid Lineage GraphRAG MCP
Lucid Lineage is a personal proof-of-concept (PoC) and exploratory project demonstrating the practical application of agentic AI and Knowledge GraphRAG (Retrieval-Augmented Generation) technology. It explores how an autonomous orchestration framework can map mock infrastructure dependencies and evaluate data boundary anomalies within a simulated sandbox environment.
π‘ Personal Project Notice
Lucid Lineage is an independent, open-source personal research project built entirely in my own time using public libraries. The code, architectural design, and synthetic datasets contained in this repository are created solely in an individual capacity for learning and brand-building purposes. They do not reflect the views, strategies, or technologies of any current or past employers, nor was any corporate time, hardware, or intellectual property used in the making of this project.
All organisations, assets, compliance boundaries, and "violations" in this project are fictional test fixtures operating on synthetic data. Released under the MIT License β see LICENSE. Β© 2026 Raul Villar Robledo.
Project Summary
This project evaluates how a Neo4j knowledge graph can be paired with LLM-driven reasoning to trace simulated data flows and analyze mock compliance constraints (such as illustrative GDPR, SOX, or CCPA frameworks). It leverages a LangChain-orchestrated reasoning agent to traverse an experimental graph database, test deterministic graph-querying tools, and log simulated audit findings back into the database for analysis.
Related MCP server: cyntrisec
Codebase Guide
The project serves as an exploratory GraphRAG architecture pattern: a LangChain agent (backed by Google Gemini) reasons over a mock Neo4j knowledge graph, interacts with deterministic graph tools, and logs simulated findings back to the graph environment. At runtime, a presentation entry point calls run_trace(), which lets the agent evaluate and select appropriate graph tools; those tools execute parameterized Cypher through a singleton driver against the Neo4j instance.
app.py / main.py β run_trace() β Gemini selects tools
(presentation) (src/agent.py) β
β src/graph_tools.py β src/db.py β Neo4j Aura
β β
returns per-submission scope src/graph_view.py (read-only)
(touched assets / locations) ββββββββββββββββΊ Knowledge Graph tab highlightA core principle is single-source-of-truth: all Cypher business logic lives in src/graph_tools.py (shared by the agent and the MCP server); all model configuration lives in src/llm.py (shared by the UI and the CLI).
Presentation layer
app.pyβ Streamlit web UI ("Forensic Workspace"). Two tabs: a π Forensic Workspace (access-control sidebar for IAM role / clearance boundary, chat rendering, the per-submission security "traffic light", and per-prompt calls torun_trace()), and a πΈοΈ Knowledge Graph tab that visualizes the graph and highlights the subgraph the last query touched. Manages session state and records each submission's touched scope for the graph tab to consume.main.pyβ CLI "Forensic Terminal": builds the live agent and loops over audit queries βrun_trace()β prints results (with a Windows UTF-8 console guard).
Orchestration layer
src/agent.pyβ The core. Defines the six LangChain@toolwrappers, the Neo4j-backed chat memory (get_graph_memory/save_graph_memory, including primitive-serialization normalization), andrun_trace()β the main pipeline (bounded history β role/clearance-aware prompt βcreate_tool_calling_agent+AgentExecutorwith iteration/time caps β normalized, persisted answer). The agent now captures which assets and compute nodes each submission investigated (_extract_query_scope, viareturn_intermediate_steps); withreturn_details=True,run_trace()returns{answer, touched_assets, touched_locations, full_scan}so the UI can scope the security light and graph highlight to the current turn. The prompt enforces read-only discipline (only logs a finding when explicitly asked), classification-scoped answers, distinct-asset counts, and findings grounded strictly in retrieved data. Falls back to a mock response when no LLM is supplied.src/llm.pyβ LLM factory & provider toggle: builds either Google Gemini (gemini-3.5-flash) or OpenAI (gpt-4o-mini), selected viaLLM_PROVIDERin.env(or theDEFAULT_PROVIDERconstant). Single source of truth for model config.
Data access layer
src/graph_tools.pyβ The unified Cypher query layer; all Neo4j business logic. Six tools: asset-lineage trace, co-location "blast radius", compliance-boundary check, write audit finding, retrieve past findings, and the cross-boundary leak scan. The leak scan excludes the false positive where a single node governed by multiple boundaries would otherwise look like a leak, and counts each incident once β but the two call sites use different, individually-correct predicates for this: the tool (query_restricted_asset_leaks) applies a canonical ordering (c1.name < c2.name) so every offending node pair is listed exactly once for drill-down, while the parallel security-light scans insrc/graph_admin.pyuse the equivalent identity guard (c1 <> c2) because they only need a distinct-asset count. Both yield the same set of affected assets; the headline reports distinct affected assets. All queries are parameterized (injection-safe).src/db.pyβ Thread-safe singleton Neo4j driver (bounded connection pool + acquisition timeout), plus connectivity verification and graceful shutdown.src/graph_admin.pyβ Graph administration & health: reseeds the graph from the canonical Cypher, detects drift from the seeded baseline (SHA-256 fingerprint), and computes the security "traffic light". Exposes a whole-graph scan (security_status), an asset-scoped scan (security_status_for_assets) and a locationβassets resolver (assets_on_locations) so the light can reflect the specific submission; a shared_classifyhelper keeps the RED/AMBER/GREEN logic identical across both scans. The leak component of each scan also uses thec1 <> c2guard.
Presentation β knowledge graph visualization
src/graph_view.pyβ Renders the enterprise knowledge graph on the dedicated Streamlit tab using st-link-analysis (a Cytoscape.js component). The base graph is queried from Neo4j once and cached (@st.cache_data); each chat submission only recomputes which nodes are highlighted β the touched assets/locations plus their one-hop neighbourhood stay vivid while the rest dims. Because the component is keyed, it reconciles in place on Streamlit's automatic rerun (no iframe reload, no re-query), so the view updates as the conversation progresses without a manual refresh.
Tool bridging & observability
src/mcp_server.pyβ FastMCP server exposing the same six tools via the Model Context Protocol, so external MCP clients use identical Cypher and schema.src/telemetry.pyβ OpenTelemetry instrumentation; thetrace_tooldecorator records spans, non-secret arguments, latency, and success/failure forrun_traceand each graph tool.src/__init__.pyβ Package docstring / module map.
Data & persistence
data/init_graph.cypherβ Enterprise graph seed script: compliance boundaries, compute nodes, data assets, service accounts, their lineage relationships, and intentional compliance violations used as test fixtures.seed_db.pyβ Loads and executesdata/init_graph.cypherto provision or reset the graph.
Diagnostics
check_env.pyβ Verifies Neo4j Aura connectivity and authentication from.env.check_models.pyβ Lists the Gemini models the configured API key can access.
Testing & validation
TESTCASES.mdβ The three canonical scenarios (each a primary + follow-up query).eval/run_testcases.pyβ Automated harness that runs the scenarios (primary + follow-up on a shared session to exercise memory) and captures responses, tools invoked, timing, and errors.TESTCASES_LOG.mdβ Audit log of test-run results (pass/fail status and any trace errors).
Infrastructure as Code (planned deployment β see ARCHITECTURE.md, Milestone C)
infra/main.tfβ Terraform: Vertex AI endpoint, a (mock) Neo4j host, and a Cloud Run service for the Streamlit UI (regioneurope-west2for sovereignty).infra/iam.tfβ Terraform: zero-trust IAM β custom agent role, service account, and role bindings.infra/variables.tfβ Terraform input variables (project_id,region,streamlit_service_name).
Configuration & documentation
.envβ Secrets/config: Neo4j credentials, provider toggle, and LLM API key(s) (gitignored). Note:PROJECT_IDis not read from.envβ it is a Terraform input variable (infra/variables.tf), supplied atterraform applytime.requirements.txtβ Python dependencies, aligned to the code's actual direct imports (includesst-link-analysisfor the graph tab).ARCHITECTURE.md: Core system architecture, target state, and graph schema.CLEANUP_LOG.md: Housekeeping audit trail (what was reviewed/removed and why).
Graph schema (quick reference)
Nodes:
Data_Asset,Compute_Node,Compliance_Boundary,Service_Account,Audit_Finding(plusSession/Messagefor chat memory).Edges:
STORED_ON,REPLICATED_TO,GOVERNED_BY,HAS_ACCESS,HAS_AUDIT_RECORD.
Known Limitations
Lucid Lineage has two layers with very different reliability characteristics, and the boundary between them matters when interpreting output:
Deterministic query layer (
src/graph_tools.py,src/graph_admin.py) β parameterized Cypher with fixed semantics. Once a query is correct it stays correct and is reproducible run-to-run: the cross-boundary leak scan returns the same distinct-asset set every time, andresolve_location()maps a location phrase to a node name by fixed rules.Agent reasoning layer (
src/agent.py+ the LLM) β probabilistic. It decides which tools to call and how to phrase answers, and it can err even when the underlying data is correct β most notably by (a) reporting a row count instead of the DISTINCT-asset count, and (b) resolving an informal location phrase to the wrong node under conversational context drift.
Concrete example from this project's own testing: asked in-session about "the APAC gateway
location" after two turns about a different APAC node, the agent resolved it to
APAC_Singapore_Analytics instead of APAC_Edge_Gateway (and logged a mis-targeted audit finding
off that); separately it reported "3 Highly_Restricted assets" for what were 2 distinct assets
across 3 boundary-crossing paths. The mitigations for these β a classification-aware leak count
returned by the tool itself, and a deterministic resolve_location step the agent is instructed
to call before any location lookup β reduce these error modes but do not eliminate them;
the reasoning layer remains probabilistic. Treat agent output as decision support, and rely on the
deterministic tools / the graph directly for anything authoritative.
Setup Instructions
Create a .env file in the root directory:
NEO4J_URI=neo4j+s://<your-db-id>.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_PASSWORD=<your-password>
# LLM provider toggle: "google" (default) or "openai"
LLM_PROVIDER=google
GOOGLE_API_KEY=<your-gemini-api-key>
# Required only when LLM_PROVIDER=openai
OPENAI_API_KEY=<your-openai-api-key>Then install dependencies, seed the graph, and launch:
pip install -r requirements.txt
python seed_db.py # provision / reset the Neo4j graph
streamlit run app.py # web UI (or: python main.py for the CLI)Verify connectivity at any time with python check_env.py and python check_models.py.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/raul-villar-ai/Lucid-Lineage-GraphRAG-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server