M5 — AST Code Knowledge Graph for AI Coding Agents
When AI agents work on your codebase, they spend most of their time (and your tokens) doing clumsy discovery: grepping files one by one, wandering through directory listings, and trying to reconstruct call hierarchies in their head.
M5 fixes that. It parses your codebase with Tree-sitter into an embedded, zero-overhead SQLite knowledge graph (.m5/local_graph.db). When your agent asks a question, M5 returns the exact code, upstream callers, downstream dependencies, and blast radius in one single call.
- 100% Local: No Docker, no heavy background daemons, no cloud dependency.
- Sub-50ms Incremental Sync: Watches your files and updates only what changed when you save.
- Zero-Friction MCP Integration: Works with Claude Code, Cursor, VS Code / Copilot, Gemini CLI, Antigravity, and Codex.
- Interactive Browser UI: Visualize your architecture and dependency chains at
http://127.0.0.1:5555.
🚀 Quickstart
1. Install M5
Install globally using pip or pipx:
pip install m5-engine
# or with pipx:
pipx install m5-engine
2. Connect Your AI Agent
Run the interactive setup wizard to get clean, copy-pasteable MCP config snippets for your editor:
m5 setup
(Or specify your tool directly: m5 setup claude, m5 setup cursor, m5 setup vscode)
Paste the provided JSON block into your editor's MCP configuration. We don't silently rewrite your system files behind your back — you stay in full control.
3. Build Your Project Index
Navigate to any project repository and build the graph:
cd your-project
m5 build
This scans your workspace and indexes all AST symbols and call edges into .m5/local_graph.db in under a second.
4. Keep It Fresh While You Code
Start the background watcher:
m5 live
Whenever you or your AI agent edits a file, M5 catches the change and updates the graph in $<50\text{ms}$.
🔍 CLI Commands
| Command | What it does | Example |
|---|---|---|
m5 setup |
Interactive manual setup wizard with exact MCP configs for your IDE | m5 setup or m5 setup cursor |
m5 build |
Scans workspace and builds AST knowledge graph into .m5/ |
m5 build |
m5 live |
Starts real-time file watcher (<50ms incremental sync on save) | m5 live |
m5 stats |
Shows index summary (files, AST symbols, call edges, DB size) | m5 stats |
m5 trace |
1-shot surgical context: verbatim code + call flow + blast radius | m5 trace "auth middleware token validation" |
m5 peek |
View symbol definition & callers, or view line-numbered file | m5 peek UserService or m5 peek src/auth.py |
m5 find |
Search AST symbols by name, type, or pattern (FTS5 + B-tree) | m5 find parse_jwt |
m5 callers |
Find all functions and files calling a symbol | m5 callers handle_request |
m5 callees |
Find all functions called by a symbol | m5 callees handle_request |
m5 blast |
Multi-hop blast radius & affected files analysis before refactoring | m5 blast DatabasePool --depth 2 |
m5 diff-tests |
Find test suites affected by modified files | git diff --name-only | m5 diff-tests --stdin |
m5 view |
Open local browser visualizer at http://127.0.0.1:5555 |
m5 view |
m5 serve |
Start the MCP server over stdio (invoked by IDEs) | m5 serve |
m5 purge |
Cleanly remove .m5/ index from project |
m5 purge |
m5 scan |
Force full re-index of the repository | m5 scan |
m5 dump |
Export index bundle for CI / team sharing | m5 dump |
m5 pull |
Pull pre-computed team index from CI cache | m5 pull https://ci.company.com/index.tar.gz |
🖥️ Visual Graph Browser (m5 view)
Want to see what your AI agent sees? Run:
m5 view
Opens a fast, dark-mode browser interface at http://127.0.0.1:5555:
- Search & Filter: Find any function, method, or class across your repo with instant fuzzy search.
- Live Code Inspection: Read exact symbol bodies with line numbers and AST metadata.
- Dependency Panels: See direct callers, outgoing calls, and affected files on the side.
- Zero External Server: Powered by Python's built-in HTTP server, so it starts instantly without npm or heavy node packages.
🤖 Agent Instructions (CLAUDE.md / AGENTS.md / GEMINI.md)
To help subagents and command-line agents make the most of M5, paste this snippet into your project's CLAUDE.md, AGENTS.md, or GEMINI.md:
<!-- M5 CONTEXT ENGINE START -->
## M5 Code Context & AST Knowledge Graph
This project uses M5 for instant AST code intelligence and dependency navigation.
Instead of repeatedly reading entire files or running multiple grep commands:
- Run `m5 trace "<query>"` to retrieve relevant symbol definitions, call hierarchies, and blast radius in 1 step.
- Run `m5 peek <symbol>` to view the exact implementation and callers of any function or class.
- Run `m5 callers <symbol>` or `m5 callees <symbol>` to navigate the call graph.
- Run `m5 diff-tests` to see tests affected by modified files.
<!-- M5 CONTEXT ENGINE END -->
🌐 Supported Languages
M5 extracts full AST symbol trees and resolves cross-file call edges across:
- Web & Backend: Python, TypeScript, JavaScript, Go, Rust, Java, C++, C, C#, Ruby, PHP
- Mobile & Modern: Swift, Kotlin, Dart, Scala
📄 License
MIT License. Free and open source for developers and teams.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 m5_engine-1.0.3.tar.gz.
File metadata
- Download URL: m5_engine-1.0.3.tar.gz
- Upload date:
- Size: 79.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ce78ec377a391dd3f082deca9db0646fc64b08bd4dc05b2a5b8a6a282bdb0ce
|
|
| MD5 |
a73be0121583424d0dc2adb824246edf
|
|
| BLAKE2b-256 |
1e22abe7d80d4504d39395c631e3bc5493aa6cdfbd4c0a5ecddd0e7831c24cc5
|
File details
Details for the file m5_engine-1.0.3-py3-none-any.whl.
File metadata
- Download URL: m5_engine-1.0.3-py3-none-any.whl
- Upload date:
- Size: 80.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a8dfc358aaa71c12188f4a953f7e738a47cfdac15305f609af5a39fcab3928e
|
|
| MD5 |
e946bff669dca433676f19a927ff4070
|
|
| BLAKE2b-256 |
88391de02bd26453cdd63c0b57d1c847549473e96f3a5d2aae46b6d73cbfd176
|