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

Links


License

MIT OR Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maggraph-0.4.0.tar.gz (82.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

maggraph-0.4.0-cp39-abi3-win_amd64.whl (925.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

maggraph-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

maggraph-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

maggraph-0.4.0-cp39-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

maggraph-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file maggraph-0.4.0.tar.gz.

File metadata

  • Download URL: maggraph-0.4.0.tar.gz
  • Upload date:
  • Size: 82.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for maggraph-0.4.0.tar.gz
Algorithm Hash digest
SHA256 043e2b8042af1a3297faf6b5ec73821dd3312fd97bf9b2fdda2d4eede2824b4f
MD5 82eed88919931af36655ad8d3eadccab
BLAKE2b-256 280e8ee3ebb0ca57664a56f1e95e041df7e8185dd35b5ddb71cba4b98757bbac

See more details on using hashes here.

File details

Details for the file maggraph-0.4.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: maggraph-0.4.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 925.8 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for maggraph-0.4.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 50166b6aa0a36f2a50c77c72625c4f2aa650dfc3e7071fcd5c9a2ef0a9bee6b6
MD5 b2fe2a8396ca39b9b1c240c3f5d94657
BLAKE2b-256 e171f0717c9cb8233fba8ec186dcf1fcc42099b3eec0c3a304d0eed6508faace

See more details on using hashes here.

File details

Details for the file maggraph-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for maggraph-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd95f28cc1eea089122a578905b35b2803fa4e7319d4e38bd3bd46f68c7ffe7a
MD5 6bcbbd12c7fc2ec56557bad05525ef73
BLAKE2b-256 329ebc8dfdd0d5692f9d7bf82112611ad1cb8a8efac65e7868373f40739242ef

See more details on using hashes here.

File details

Details for the file maggraph-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for maggraph-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6edd69cb5af9fb6e6fe0d8ecf7c9bc6198efcfb121ad3e4b622bcba0226357b6
MD5 388cc63f8207df0ec0edf44181304c2f
BLAKE2b-256 581f711dee2e8aa079368196ff2f3cde67e85f428e4f3c629ea5d93a10491276

See more details on using hashes here.

File details

Details for the file maggraph-0.4.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for maggraph-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bbf3ab11514a040d2f14a335e44028acae9c4bbd86df1b57979711cc0261cbda
MD5 7815650555466f62db94872da106143a
BLAKE2b-256 1e3cf6e55cb3d2eb4902db3efe1d9012b93775b02f6ec1f2900b574a3d604fe4

See more details on using hashes here.

File details

Details for the file maggraph-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for maggraph-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4c95c4ebf37c29507c8d084f75417b77182022fd0fb6a55ffc652c9b01c9ea32
MD5 fc646ceb4d078873480146c5ab825ed8
BLAKE2b-256 92832a13de4b2e11c51cd38c85196c9c3d79f155044a65a378f24763ea67046c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

6 files

This release

0.4.0 This release

6 files

0.3.0

6 files

0.2.5

6 files

0.2.0

2 files

0.1.0

1 file

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