codegraph-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codegraph-mcpFind all references to calculateTotal and show their impact."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codegraph-mcp
A dependency-free MCP server that surfaces a codebase's
symbol graph — and a full symbol-aware edit loop — as first-class agent tools, sitting right
next to grep and read_file in the model's tool list.
The whole point: an agent reaches for a native tool by reflex, but ignores an npm script it has to construct through a generic shell and then text-parse. Same logic, better surface. Instead of "grep, then read six whole files to reconstruct the answer with certainty", the agent asks the graph one question and gets back exactly the lines that matter — a big context-token win on every turn (see Why it matters).
Transport: newline-delimited JSON-RPC 2.0 over stdio (the MCP stdio convention). No external dependencies — just Node +
sqlite3+ your source tree.
The tools
Each MCP tool shells out to a small, single-purpose .cjs CLI under codegraph-ext/,
so there is one source of truth for the logic whether you call it as an MCP tool or from the
shell. The target repo is resolved per call as projectRoot arg → cwd autodetect → $CODEGRAPH_ROOT.
Discovery (read)
Tool | What it answers |
| Turn a concept ("graph series color", a hex literal) into ranked candidate symbols — searches names, qualified names, docstrings, signatures and bodies (identifiers + literals). |
| The pre-scoped edit set for a symbol change: definition + references + covering tests + literal-assert sites, each with the current line inline. |
| Raw blast-radius set for a symbol (def + prod refs + covering tests + literal-assert sites). |
| The relevant slices of many files in ONE call — feed it the |
Edit + verify (write)
Tool | What it does |
| Edit by (file, line) — the server fetches that line's context itself, so no whole-file read to build an anchor. Batched, atomic, verifies once. The default edit path. |
| Apply many anchored |
| One-shot |
| ONE compact PASS/FAIL verdict over the affected tests for the whole working-tree diff. Memoized — unchanged green suites are skipped. |
| The raw-output escape hatch: run one test file (optional |
Related MCP server: symapse
Quick start
1. Prerequisites
Node ≥ 16 and sqlite3 on
PATH.A built codegraph SQLite DB for your repo at
<repo>/.codegraph/codegraph.db(produced by your basecodegraph indexstep), plus this kit's overlays applied — seedocs/ARCHITECTURE.md.
2. Drop the kit into your repo
Copy the codegraph-ext/ folder to the root of the repo you want to index,
so the layout is <repo>/codegraph-ext/*.cjs. Build the body index + overlays:
node codegraph-ext/build-body-index.cjs # full-text index over symbol bodies
node codegraph-ext/augment.cjs # covers/mocks + prop + annotation overlays3. Register the MCP server with your agent
Point your MCP-capable client at the server over stdio:
{
"mcpServers": {
"codegraph": {
"command": "node",
"args": ["/absolute/path/to/codegraph-ext/codegraph-mcp.cjs"],
"env": { "CODEGRAPH_ROOT": "/absolute/path/to/your/repo" }
}
}
}projectRootcan be passed per call to point at any checkout/clone.Set
CODEGRAPH_LOCK_ROOTto hard-confine every call to a single path (e.g. an isolated sandbox) — explicitprojectRootargs and cwd autodetection are then ignored.
4. (Optional) the nudge hook
node codegraph-ext/install-hook.cjs opt-in installs a UserPromptSubmit hook that nudges the
agent to prefer the graph. It only fires when the session cwd is inside the repo, so installing it
is safe everywhere else. Uninstall with --uninstall.
Why it matters
A controlled A/B experiment on a real production TypeScript/React codebase found that giving a
coding agent this graph — instead of letting it grep/read files — turned the cheaper model
(Sonnet) from the most expensive, worst-behaving option into the cost-optimal one: ~5×
cheaper than non-KG Sonnet and ~4× cheaper than KG Opus, at matching correctness. The full
write-up (method, results, significance tests, and the tuning log) is in
docs/experiment.md — also rendered as
docs/report.html / docs/report.pdf.
Reach for token-bench.cjs to quantify the win on your repo.
It's zero-config: it auto-discovers the highest-fan-in questions (the most-mocked module, the
most-covered source file, the widest prop surface, a documented symbol) and, for each, compares:
naive — a grep listing plus the full text of every file you'd have to open to reconstruct the answer with certainty, and
cg:ask — the exact stdout the overlay hands back for the same question.
node codegraph-ext/token-bench.cjsThe graph turns "open N files and hope" into "ask one question, get the exact lines" — fewer tokens per turn, fewer wrong-file detours, and edits that are scoped to a symbol's span so a change can't silently leak into a sibling.
See docs/ARCHITECTURE.md for how the overlays are built and kept fresh.
Layout
codegraph-ext/
codegraph-mcp.cjs # the MCP server (stdio JSON-RPC) — wraps the CLIs below
query.cjs # locate / plan / impact / docs / covers / mocks / props / notes
read-context.cjs # relevant multi-file slices in one call
apply-at-site.cjs # edit by (file, line) — the default edit path
apply-edits.cjs # anchored multi-file atomic edits
build-body-index.cjs # full-text index over symbol BODIES (identifiers + literals)
augment.cjs # covers/mocks + prop + annotation overlays
verify-affected.cjs # one memoized PASS/FAIL verdict over affected tests
test-one.cjs # raw jest output for one file (escape hatch)
affected.cjs # shared change→covering-test mapping (library)
cg-graph.cjs # interactive HTML change-impact graph
install-hook.cjs # opt-in nudge-hook installer
cg-nudge-hook.cjs # the nudge hook itself
token-bench.cjs # quantify context-token savings vs. naive grep+read
annotations.json # hand-authored institutional memory (conventions/decisions/dedupe)License
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
FlicenseNot gradedqualityDmaintenanceProvides AI coding agents with structured access to indexed codebases via semantic search, symbol analysis, and file reading tools.12- AlicenseNot gradedqualityDmaintenanceProvides code analysis tools for AI coding agents to understand project architecture, search for symbols, and plan changes with token reduction.131AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceProvides a semantic understanding of your codebase by parsing with tree-sitter and building a graph of symbols and dependencies. Enables AI assistants to navigate code, analyze changes, and discover architecture using 18 tools with minimal context overhead.221MIT
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to efficiently understand and navigate a codebase by providing semantic search over symbols and a reference graph, replacing expensive grep/glob calls with structured tools like definition lookup, caller/callee queries, and change-impact analysis.1MIT
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Codebase intelligence for agents: 152 structured artifacts across 21 programs, one call.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/shekharnair96/codegraph-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server