Grafema
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Grafema turns your codebase, infrastructure, knowledge, and workflows around it — into one queryable graph.
For humans and AI.
---
We treat code as text. But text is just a form.
What actually matters when you write code is the system you have in your head — its **structure**. Entities, invariants, limitations. Goals and purpose.
And how all these things relate to each other.
Software is naturally an executable graph — and so is everything around it: your services, your decisions, your team's knowledge. Grafema uses compiler-grade AST parsers — containing years of community-shared knowledge for each language — to excavate the deepest possible model of your system, and turn it into a transparent, queryable, enrichable map that grounds your understanding of it.
We refuse to accept *"that's impossible to analyze statically."* You can read code and understand it — you have a mental model in your head. So it's a matter of good enough heuristics. Human brains are literally built on this.
It's not magic and won't cover 100% of your system on day one. There will be gaps and *"Here be dragons"* signs. You will slay these dragons one by one — extend analysis with your own rules, fill up the knowledge base. And if you contribute, you slay one for everyone.
Thinking in graphs is not easy.
But once it clicks - you stop reading code and just navigate the system.
And your AI minions too.
Welcome to the party!
---
> Licensed under FSL-1.1-Apache-2.0 — free to use, source available, converts to Apache 2.0 after 2 years. Details
> **v0.4.1** — Early access. Changelog | Known limitations
Quick Start
That's it. --quickstart auto-detects your project languages, generates config, and builds the graph in one command.
For more control, use the two-step flow: grafema init (review config) → grafema analyze.
Explore your code
Use with AI (MCP)
Add to .mcp.json in your project root:
There is also a Docker image for running the MCP server (stdio) in a container — see the root Dockerfile: docker run -i --rm -v "$PWD":/workspace grafema-mcp.
30+ MCP tools available: find_nodes, find_calls, trace_dataflow, get_file_overview, describe, query_graph, and more. The AI agent queries the graph instead of reading files — faster, cheaper, more complete.
find_nodes returns rich context in a single call: callers, members, parent, import/call counts. Fuzzy name matching via local embeddings means approximate queries like find_nodes(name="PtyHostHeartbeatService") find HeartbeatService even without exact match.
Capabilities
**Analyze**
- ✅ Call graph — who calls what, across all files
- ✅ Data flow — trace values source to sink, forward and backward
- ✅ Control flow — CFG, reachability, branching paths
- ✅ Data shapes — object structure through assignment chains
- ✅ Effect propagation — transitive side-effect analysis through call graph
- ✅ Symbolic execution
- ✅ Cross-language & inter-process — service boundaries, message passing, remote calls
- ⏳ Side effect chain analysis
- ⏳ Inter-service contracts — message queue schemas, API schemas (OpenAPI, JSON Schema, gRPC)
- ⏳ Infrastructure as Code — Terraform, Kubernetes, Docker
**Query**
- ✅ CLI: tldr, who, wtf, why, check, overview
- ✅ 40+ MCP tools for AI agents (graph queries, navigation, dataflow, knowledge, git history)
- ✅ Datalog for custom structural queries
- ✅ Cypher query language
- ✅ Programmatic API (@grafema/util)
- ✅ HexAtlas — visual code map (2D/3D)
- ✅ VS Code extension
**Document**
- ✅ grafema export --as docs-md — generate human-readable docs from the live graph
- ✅ grafema export --as openapi-3.1 — auto-generate OpenAPI for HTTP routes
- ✅ grafema export --as mcp-schema — JSON-RPC tool registry, directly servable by any MCP runtime
- ✅ grafema export --as json-schema — Draft 2020-12 schemas per FEATURE