In-process graph engine for AI semantic layers — powered by Rust
Project description
MagGraph
In-process Git-backed graph engine for AI semantic layers — powered by Rust
Why "MagGraph"? The name is short for Magpie — a Corvid. Corvids (ravens, crows, jays, and magpies) are renowned in animal cognition research for their remarkable intelligence, long-term memory, and sophisticated tool use. MagGraph is built to be the memory and knowledge layer for AI agents with those same qualities: a graph that thinks, remembers, and uses tools.
MagGraph stores knowledge as versioned Markdown nodes in your Git repository,
with BFS/DFS traversal, Git-backed sync, external lakehouse content resolution,
and a built-in MCP server scaffold — all from a zero-dependency pip install.
Install
pip install maggraph
Pre-built wheels are available for:
| Platform | Architectures |
|---|---|
| Linux (manylinux_2_28) | x86_64 · aarch64 |
| macOS | Intel (x86_64) · Apple Silicon (arm64) |
| Windows | x86_64 |
No Rust toolchain required — the Rust core is compiled into the wheel.
Quick start
import maggraph
# Load config + open the graph index
config = maggraph.load_config("maggraph.toml")
index = config.open_index()
# List nodes
print(index.list_nodes()) # ['getting_started', 'welcome', ...]
# Read a node
node = index.read_node("welcome")
print(node.body) # full markdown body
# Search, backlinks, and recall
print(index.search("Welcome")[0]["id"])
print(index.backlinks("welcome"))
bundle = index.recall_bundle("welcome", reason="quick start")
print(bundle["markdown"])
# BFS traversal
result = index.traverse("welcome", depth=2, order="bfs")
print(result.to_markdown(index)) # formatted traversal report
# CRUD and memory helpers
index.create_memory_node("prefers_cli", "preference", "User prefers CLI-first UX.")
index.create_node("new_note", node_type="note", body="# Hi\n", links=["welcome"])
index.update_node("new_note", "# Updated\n")
index.suppress_node("new_note", reason="example")
index.unsuppress_node("new_note")
index.delete_node("new_note")
Async support
import asyncio, maggraph
async def main():
index = maggraph.open_index("examples/basic/knowledge_graph")
node = await index.read_node_async("welcome")
result = await index.traverse_async("welcome", depth=3, order="dfs")
print(result.to_markdown(index))
asyncio.run(main())
Blocking Rust work runs on a Tokio thread pool — Python's event loop stays responsive.
Lakehouse content resolution
Resolve external data sources (S3, file://, HTTP) referenced from node frontmatter:
import maggraph
config = maggraph.load_config("maggraph.toml") # mode = "lakehouse"
index = config.open_index()
reader = config.open_lakehouse_reader()
# Resolve a node's external source (e.g. s3://bucket/data.parquet)
result = reader.read_node(index, "customer_churn_q2")
print(result.content.kind) # "external_asset"
print(result.content.uri) # "s3://corp-data/lake/churn.parquet"
print(result.content.format) # "parquet"
print(result.content.to_markdown()) # agent-friendly summary
# Cache stats
print(reader.cache_len()) # 1
print(reader.cache_bytes()) # ~128
# Also callable directly on the index
result2 = index.read_node_with_content(reader, "customer_churn_q2")
maggraph.toml for lakehouse mode:
[storage]
mode = "lakehouse"
root_path = "./knowledge_graph"
[lakehouse]
remote_sources = [
{ uri = "s3://corp-data/lake", format = "parquet" }
]
MCP server scaffold
maggraph scaffold --mcp --output ./mcp_server
Generates a ready-to-run FastMCP server at ./mcp_server/server.py wired to
your graph index — expose list_nodes, read_node, traverse, create_node,
and delete_node as MCP tools with one command.
Git-backed sync
# Leader pushes a snapshot
maggraph sync push --message "Add Q2 analysis nodes"
# Follower (read-only) pulls
maggraph sync pull
API reference
| Class / Function | Description |
|---|---|
load_config(path) |
Load maggraph.toml → ResolvedConfig |
open_index(root_path) |
Open graph index directly → GraphIndex |
ResolvedConfig.open_index() |
Open index from config |
ResolvedConfig.open_lakehouse_reader() |
Create a LakehouseReader |
GraphIndex.list_nodes() |
All node ids (sorted) |
GraphIndex.read_node(id) |
Node with metadata + body |
GraphIndex.search(...) |
Structured search over ids, types, tags, frontmatter, links, body, and recency |
GraphIndex.backlinks(id) |
Node ids that link to id |
GraphIndex.changed_since(unix) |
Files modified after a Unix timestamp |
GraphIndex.update_file(path) |
Refresh one changed markdown file in the index |
GraphIndex.recall_bundle(id, ...) |
Compact agent retrieval dict with Markdown |
GraphIndex.read_node_async(id) |
Async version |
GraphIndex.traverse(id, depth, order) |
BFS/DFS → TraversalResult |
GraphIndex.traverse_async(...) |
Async version |
GraphIndex.create_node(...) |
Write new node to disk + index |
GraphIndex.create_memory_node(...) |
Create typed memory nodes (preference, project_fact, decision, task, session_summary, bookmark, tool_failure) |
GraphIndex.update_node(id, body) |
Update body on disk |
GraphIndex.delete_node(id) |
Delete node from disk + index |
GraphIndex.suppress_node(id) / unsuppress_node(id) |
Mark/unmark stale or duplicate nodes |
GraphIndex.merge_nodes(target, source) |
Merge duplicate source into canonical target |
GraphIndex.read_node_with_content(reader, id) |
Resolve external content |
LakehouseReader.read_node(index, id) |
→ NodeWithContent |
LakehouseReader.read_node_async(index, id) |
Async version |
LakehouseReader.cache_len() |
Entries in content cache |
LakehouseReader.cache_bytes() |
Bytes in content cache |
Node.id / .node_type / .body / .links / .source |
Node properties |
Node.to_markdown() |
Full node as Markdown string |
Node.to_dict() |
Node as plain Python dict |
ResolvedContent.kind |
"local" / "text" / "external_asset" |
ResolvedContent.body / .uri / .format |
Content details |
ResolvedContent.to_markdown() |
Agent-friendly summary |
NodeWithContent.node / .content |
Node + resolved content |
Links
License
MIT OR Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maggraph-0.2.5.tar.gz.
File metadata
- Download URL: maggraph-0.2.5.tar.gz
- Upload date:
- Size: 73.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8285d460af052ca7ded52cf2ceba25a27cd0bd3de1bb61bd7efd2fcc2488a2d1
|
|
| MD5 |
fffbb98eedd8ad63f112d391defc59da
|
|
| BLAKE2b-256 |
3a2608b83a32355bde47b4666451e40930ac3b3b68fe87bcbd8e9cb82b2cee23
|
File details
Details for the file maggraph-0.2.5-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: maggraph-0.2.5-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c02553f542e10b888309465fd35baee248976d19efe34ef11e4b9c5f46211bc
|
|
| MD5 |
24e64f4538bafaa8d277268c4ad5422c
|
|
| BLAKE2b-256 |
5844f1ad397491af11c05d02cc3baff18c72fa6c29f0b655c455724c5223252f
|
File details
Details for the file maggraph-0.2.5-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: maggraph-0.2.5-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af4cf289d6d63417c38205df8c8ff4f493460fae0cb9cbfaebe4beba155cdd9e
|
|
| MD5 |
e83870943591cc1bdcb55cf3803d3439
|
|
| BLAKE2b-256 |
d9ffdaec0cb71eb1f4cd25811dfe7280ef4d1234c44ab74fd96b1c715bce04d9
|
File details
Details for the file maggraph-0.2.5-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: maggraph-0.2.5-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05bf67bdcdca806ecb5ea48812c5a5dc9530d61382ba5c9ba2bdb9466e45c6ab
|
|
| MD5 |
4f15096ee4e3ee153482f637f08bcaf7
|
|
| BLAKE2b-256 |
8ce7b121003661dd6fd765c1a59148b37f83cb118ae681dc89ba31cd661ef93d
|
File details
Details for the file maggraph-0.2.5-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: maggraph-0.2.5-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 948.4 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
066b104ca9133cad74bc50526fe704c26ea50d170aadb809ae23861deeb748a7
|
|
| MD5 |
fca80f04bfe5952f60f1da9a3c013f99
|
|
| BLAKE2b-256 |
b72f4e0a2e3ee591ce280e399f85d0be24295ac46cbde62275f01660add0bd77
|
File details
Details for the file maggraph-0.2.5-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: maggraph-0.2.5-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 960.1 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10d933ca1b7d9d1423c1d46f470434bc5918f11cca083589a601af8a2dc8177a
|
|
| MD5 |
875bc58e513e0e8dd5916f515e2dfcdb
|
|
| BLAKE2b-256 |
bc94353f8b76a4356aab586d11ce3270f9ab1d32455a1bdc39a99fc52c5ee567
|