The Problem
Modern LLM agents need fast, queryable knowledge graphs that can be embedded in an application without deploying a separate database service. Existing solutions either require a running Neo4j instance or expose only a REST API, adding latency and operational overhead. A self‑contained, Cypher‑queryable graph that ships with both Rust and Python bindings eliminates those bottlenecks.
What This Does
KGLite implements an embedded graph engine that can be used directly from Rust or Python. The engine stores vertices, relationships, and properties in memory or on disk, supports Cypher queries, and exposes a lightweight MCP server for agent interactions. The same binary can be bundled in a Python wheel or a Rust crate, letting developers embed the graph in any distribution.
Key components:
crates/kglite-c/src/lib.rs– Rust library exposing the core graph API.crates/kglite-bolt-server/src/main.rs– Bolt‑compatible server that serves Cypher over TCP.crates/kglite-cli/src/main.rs– CLI tool for graph manipulation and querying.kglite/– Python package providing a thin wrapper around the Rust library (kglite.KnowledgeGraph).kglite-mcp-server– bundled MCP server that can be started from the wheel (kglite-mcp-server --graph path.kgl).
How It Is Wired
Execution begins in the CLI or MCP binary.
- CLI:
crates/kglite-cli/src/main.rsparses arguments, loads a graph file viakglite::Graph::load, then callskglite::Graph::cypherwhich delegates tokglite::Engine::execute. - MCP:
crates/kglite-mcp-server/src/main.rsstarts an async runtime, registers HTTP routes, and on a request to/cyphercallskglite::Graph::cypherin the same way. - Rust Library:
crates/kglite-c/src/lib.rscontainspub fn execute(&self, query: &str) -> ResultView, which parses Cypher, walks the graph structure, and returns a lazyResultView. - Bolt Server:
crates/kglite-bolt-server/src/main.rslistens on a TCP port, accepts Bolt frames, and forwards Cypher strings tokglite::Engine::execute. - Persistence:
kglite::Graph::savewrites a binary format viakglite::engine::Serializer. Reading uses the same serializer.
The widest blast radius is the execute function in kglite-c/src/lib.rs; it is the single point where query parsing, graph traversal, and result materialization occur. Changing it affects all consumers. The kglite-mcp-server/src/main.rs is a thin wrapper that only routes HTTP/Bolt requests to that function.
How To Use It
Setup
# Clone
git clone https://github.com/moses-y/kglite
cd kglite
# Build Rust crates (requires Rust 1.75+)
cargo build --release
# Install Python wheel
pip install --no-build-isolation kglite # uses prebuilt wheel
Configuration No external config files are required. The MCP server reads the graph path from the command line (--graph). The Rust library has no env vars.
Running
# Start MCP server with a pre‑built graph
kglite-mcp-server --graph examples/demo.kgl
# Or use the CLI to query a graph
kglite-cli --graph examples/demo.kgl cypher "MATCH (p:Person) RETURN p.name"
Python usage follows the README example: instantiate kglite.KnowledgeGraph(), load data, and run graph.cypher(...).
Real-World Use
A data‑science platform can ship a lightweight knowledge base with analytics notebooks. The notebook author writes Python code that loads a pre‑built demo.kgl and performs Cypher queries, all in‑process. An LLM agent can be given the same file and use the bundled MCP server to answer user questions without setting up Neo4j on the host.
Code Health & Issues
- Severity (Low) – No structural red flags detected – tests/CI/license/lockfile present.
- Severity (Low) – MIT license applies – all crates and Python wheel are MIT‑licensed.
- Severity (Low) – No hard dependencies on external services – the core engine has no network calls except the optional MCP server.
No critical bugs or missing documentation were detected by the static analysis. Automated tests cover 1974 test files across Rust and Python.
The Bottom Line
KGLite offers a pragmatic, zero‑dependency graph engine for Rust and Python. Its bundled MCP server and CLI make it easy to embed or run as a lightweight service. The codebase is well‑structured, heavily tested, and MIT‑licensed, making it suitable for production workloads that require fast, in‑process graph queries.