Free Intensive Nov 21–22Free 2-day hands-on Vibecoding Intensive on Nov 21–22 at 16:00 MSK (Sat–Sun) · Live Cohort 3 starts Nov 23Join Free →Cohort 3 (Nov 23)
ReleaseInsight · On RadarHabr AI→ original

graphlens-mcp builds a code graph with one command and cuts token use 10–23x

graphlens-mcp is an MCP server that builds a structural graph of Python, TypeScript, Go, Rust and PHP code with a single command and plugs straight into an AI agent. In 936 tests on apache/superset (400k lines), impact analysis beat grep on token cost by 10–23x. The graph also sees cross-language chains (Python → TypeScript), which grep cannot. The product is in alpha, MIT-licensed and free.

AI-processed from Habr AI; edited by Hamidun News
graphlens-mcp builds a code graph with one command and cuts token use 10–23x
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Impact analysisthe graph is cheaper than grep in token cost by 10–23x
Key metric #2Targeted queries ("find the definition", "show the calls of a method"): the difference is minimal
Key metric #3Cross-language chains (Python → TypeScript): grep does not find them at all, while the graph builds the full path

graphlens-mcp is a new MCP server built on top of the graphlens engine. It builds a structural graph of your code with one command and makes it available to an AI agent immediately, with no manual glue code.

What the engine does

The graphlens engine takes source code in Python, TypeScript, Go, Rust and PHP and normalizes it into a single typed graph. Nodes are symbols: functions, classes, variables, methods. Edges describe relationships: CALLS (a call), HAS_TYPE (a type), INHERITS_FROM (inheritance). Each node gets a deterministic SHA-256 ID, so results are reproducible between runs and suitable for cacheable agent pipelines.

The key difference from grep is that the graph understands semantics. Grep searches text line by line: it does not know whether a matched line is a function name, an argument or a comment. The graph works with symbols and the relationships between them. If a Python backend calls a TypeScript client, the CALLS edge crosses the language boundary and is preserved in the graph. For monorepos and fullstack projects this is critical: dependencies between layers become explicit objects rather than strings of text that you have to trace by hand.

What the benchmark on real code showed

The author ran 936 tests on apache/superset, an open-source project with roughly 400 thousand lines of Python and TypeScript code. The test boundary was the /api/v1/... entry points. Each test had to answer questions such as "what changes if I touch this function?". 936 runs are enough for statistically significant conclusions.

Results:

  • Impact analysis: the graph is cheaper than grep in token cost by 10–23x
  • Targeted queries ("find the definition", "show the calls of a method"): the difference is minimal
  • Cross-language chains (Python → TypeScript): grep does not find them at all, while the graph builds the full path
  • Stability: SHA-256 IDs give reproducible results across repeated agent runs

When you need to understand what will break after changing a function or class, the graph wins many times over. When finding a string by pattern is enough, the difference is negligible. Token savings are most noticeable on large codebases with high coupling between modules.

From engine to finished product

Earlier articles described the graphlens engine itself, the internal mechanics of building the graph. But an engine is not a product. To connect it to an AI agent, you had to install dependencies yourself, configure the API and write a layer for a specific interaction protocol. For most developers that is a serious barrier.

"An engine is not a product.

To actually connect graphlens to an agent, pip install and an API are not enough. You need to write a pile of glue code," the author admits.

graphlens-mcp closes that gap. Under the hood it is the same engine, but on top of it sits a ready-made MCP server that accepts requests from the agent in a standardized format right after installation.

MCP (Model Context Protocol) has become the de facto standard for integrating external tools with language models, and it is supported by Claude, GPT and most modern AI frameworks. graphlens-mcp works with any agent that supports this protocol, with no extra configuration.

Installation takes one command. According to the author, it takes five minutes from that command to the first real result on your own project. The product is in alpha, MIT-licensed and distributed for free.

What this means

A structural code graph as a tool for AI agents is not theory but a measurable practice with concrete numbers on real code. graphlens-mcp lowers the barrier to entry for teams building agents for code review, refactoring or dependency analysis: instead of assembling an integration themselves, they get a ready-made tool with documented effectiveness. The open source code and free license let you try it without any commercial commitment.

Story

Key Questions Answered

What the engine does?

The graphlens engine takes source code in Python, TypeScript, Go, Rust and PHP and normalizes it into a single typed graph. Nodes are symbols: functions, classes, variables, methods. Edges describe relationships: CALLS (a call), HAS_TYPE (a type), INHERITS_FROM (inheritance). Each node gets a deterministic SHA-256 ID, so results are reproducible between runs and suitable for cacheable agent pipelines. The key difference from grep is that the graph understands semantics.

What the benchmark on real code showed?

The author ran 936 tests on apache/superset, an open-source project with roughly 400 thousand lines of Python and TypeScript code. The test boundary was the /api/v1/... entry points. Each test had to answer questions such as "what changes if I touch this function?". 936 runs are enough for statistically significant conclusions.

What are the key details on From engine to finished product?

Earlier articles described the graphlens engine itself, the internal mechanics of building the graph. But an engine is not a product. To connect it to an AI agent, you had to install dependencies yourself, configure the API and write a layer for a specific interaction protocol. For most developers that is a serious barrier. "An engine is not a product. To actually connect graphlens to an agent, pip install and an API are not enough. You need to write a pile of glue code," the author admits.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…