Skip to main content

MagGraph

In-process Git-backed graph engine for AI semantic layers — powered by Rust

CI PyPI Python License

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 ./agent

Generates a ready-to-run FastMCP server at ./agent/mcp_server/server.py wired to your graph index — expose list_nodes, get_node, traverse_graph, create_node, update_node, and delete_node as MCP tools with one command. Add --read-only to leave out the write tools, and --skill to write ./agent/maggraph-skill/SKILL.md.


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.hybrid_search(...) Explainable lexical + graph + recency + optional semantic retrieval with temporal/project filters
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.apply_memory_batch(...) Preview or apply reviewed update/suppress/unsuppress/merge operations as one rollback-capable batch
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


License

MIT OR Apache-2.0

Metadata

Release files for maggraph 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maggraph 0.4.2
File Size Uploaded Provenance Actions
maggraph-0.4.2.tar.gz 85.8 kB Without provenance Details for maggraph-0.4.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for maggraph 0.4.2
File Actions
maggraph-0.4.2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for maggraph-0.4.2-cp39-abi3-win_amd64.whl
maggraph-0.4.2-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for maggraph-0.4.2-cp39-abi3-manylinux_2_28_x86_64.whl
maggraph-0.4.2-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for maggraph-0.4.2-cp39-abi3-manylinux_2_28_aarch64.whl
maggraph-0.4.2-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for maggraph-0.4.2-cp39-abi3-macosx_11_0_arm64.whl
maggraph-0.4.2-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for maggraph-0.4.2-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 5.6 MB

Release files / maggraph-0.4.2.tar.gz

Download URL maggraph-0.4.2.tar.gz
Size 85.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7c78191dd8e690700a6ba2d5f8f5e48252bc4380876f5e158ce9f7e63f21acf2
BLAKE2b-256 checksum
How to use checksums
060e26a919418e7dce738152c1b84f72dc8d9562bc357661aa55e55043677af5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / maggraph-0.4.2-cp39-abi3-win_amd64.whl

Download URL maggraph-0.4.2-cp39-abi3-win_amd64.whl
Size 962.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
7246a43f89d51ca67b88ef02d0b0ab85eed20e235da305cc7846dc290bc29d74
BLAKE2b-256 checksum
How to use checksums
740174fccb48d6c476c9497e20ff989c20b58d1e28925960cc3b7e65ce1825f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / maggraph-0.4.2-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL maggraph-0.4.2-cp39-abi3-manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
13057fbd45e7e1e998ce979ba75f9b193c969dea2759558f1ae9633ef06863dc
BLAKE2b-256 checksum
How to use checksums
68a783f7bde6da84c7ff47b83664561b90575967a558e099bae76cce668ca0bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / maggraph-0.4.2-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL maggraph-0.4.2-cp39-abi3-manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b274762c9dca9e6cbe3b1bc1f08136be5c7166004d9bd81fd1e43fc1ca6ce0c0
BLAKE2b-256 checksum
How to use checksums
a524d9135b5572290b88758b326f6650c7bb02d95370e6c6d9af9bbfdb0fba58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / maggraph-0.4.2-cp39-abi3-macosx_11_0_arm64.whl

Download URL maggraph-0.4.2-cp39-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6b81125f19d11c43d4d5b29b573bf471d8aeb51de77bef547e6385bd59f07aa8
BLAKE2b-256 checksum
How to use checksums
c7d5a3ad87820879222a7fe6b198a10b4f82b62570512ebe9af185c077d41d3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / maggraph-0.4.2-cp39-abi3-macosx_10_12_x86_64.whl

Download URL maggraph-0.4.2-cp39-abi3-macosx_10_12_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
df62c079b78269ec804f6835189297dde739d23abd7e569112071da90fe79ea4
BLAKE2b-256 checksum
How to use checksums
1111e9127b52c15a91318b909851766e17a94c562e918496ee8ee1a62f6ad651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for maggraph 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page