graphlens-mcp builds a code graph with one command and cuts token usage by 10–23x
graphlens-mcp is an MCP server that builds a structural code graph from Python, TypeScript, Go, Rust, and PHP with one command and connects directly to an AI…
AI-processed from Habr AI; edited by Hamidun News
graphlens-mcp is a new MCP server built on top of the graphlens engine that builds a structural code graph with one command and immediately makes it available to an AI agent without manual integration work.
What the graphlens engine can do graphlens takes source code in
Python, TypeScript, Go, Rust, and PHP and normalizes it into a unified typed graph. Nodes represent symbols: functions, classes, variables, methods. Edges describe relationships: `CALLS` (function call), `HAS_TYPE` (type), `INHERITS_FROM` (inheritance).
Each node receives a deterministic SHA-256 ID, which makes the result reproducible between runs and suitable for cacheable agent pipelines. The key difference from grep is understanding semantics. Grep searches for text line by line: it doesn't know if the found string is a function name, argument, or comment.
The graph operates on symbols and their relationships. If a Python backend calls a TypeScript client, the `CALLS` edge will traverse the language boundary and persist in the graph. For monorepos and fullstack projects, this is critical: dependencies between layers become explicit objects, not text strings that must be traced manually.
What measurements on real code showed
The author ran 936 tests on apache/superset—an open-source project with approximately 400,000 lines of code in Python and TypeScript. The test boundary was API entry points `/api/v1/...`.
Each test's goal was to answer questions like "what will change if I modify this function?" 936 runs provide statistically significant conclusions. Results: Impact analysis: graph is cheaper than grep in token cost by 10–23x Point queries ("find definition", "show method calls"): difference is minimal Cross-language chains (Python → TypeScript): grep finds nothing—graph builds the full path Stability: SHA-256 IDs provide reproducible results on agent re-runs Where you need to understand what breaks when you change a function or class—the graph wins many times over.
Where it's enough to find a string by pattern—the difference is negligible. Token savings are particularly noticeable on large code bases with high connectivity between modules.
From engine to finished product
Previous articles described the graphlens engine itself—the internal mechanics of graph construction. But an engine is not a product. To connect it to an AI agent, you had to independently install dependencies, configure the API, and write integration code for a specific protocol. For most developers, this was a serious barrier.
"An engine is not a product.
To really connect graphlens to an agent, pip install and an API are not enough. You need to write a lot of integration code," the author admits. graphlens-mcp closes this gap.
Under the hood is the same engine, but on top of it is a ready-made MCP server that accepts requests from an agent in standardized format immediately after installation. MCP (Model Context Protocol) has become the de facto standard for integrating external tools with language models—it is supported by Claude, GPT, and most modern AI frameworks. graphlens-mcp is compatible with any agent supporting this protocol, without additional configuration.
Installation is one command. According to the author, from installation to the first real result on your own project takes five minutes. The product is in alpha stage, MIT license, distributed for free.
What this means
Structural code graph as a tool for AI agents is not theory but measurable practice with concrete numbers on real code. graphlens-mcp lowers the entry barrier for teams building agents for code review, refactoring, or dependency analysis: instead of assembling integration themselves, they get a ready-made tool with documented efficiency. Open source and a free license enable trying it without any commercial obligations.
Want to stop reading about AI and start using it?
AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.