Codegraph logo

Codegraph

Maps source files, symbols, references, and dependencies so coding agents can navigate repositories and assess change impact.

Install Codegraph

Run the project’s own setup commands, in order.

Setup steps from the project

codegraph installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    npm install -g @lzehrung/codegraph
    
  2. 2. Install
    codegraph install
    
  3. 3. Install
    irm https://github.com/lzehrung/codegraph/releases/latest/download/install.ps1 | iex
    
  4. 4. Install
    curl -fsSL https://github.com/lzehrung/codegraph/releases/latest/download/install.sh | sh
    

Overview

The codegraph MCP server turns a local source tree into a resolved map of files, symbols, references, and dependencies using tree-sitter. It gives coding agents structural context for locating implementations, tracing relationships, assessing change impact, and finding candidate tests instead of relying only on text search. Reach for it when an agent needs cross-file repository understanding or when you want read-only evidence for review and refactoring work. codegraph also provides a local CLI and TypeScript library for inspecting the same repository model.

Use cases

  • Explore an unfamiliar repository before choosing files to inspect
  • Trace references and reverse dependencies during a refactor
  • Review changes and identify candidate affected tests
  • Export a repository graph for analysis or visualization

Key features

  • Tree-sitter source analysis
  • File, symbol, reference, and dependency mapping
  • Change impact and affected-test analysis
  • Read-only refactoring and rename previews
  • Graph export to JSON, SQLite, Mermaid, and DOT
  • Repository health and API-surface inspections

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

11/11 checks healthy over the last 40d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars11Stargazers on the source repository.
Last commitTodayMost recent push to the default branch.
Directory activity4 viewsConfig copies, upvotes, and views on AllMCPs.

How Codegraph works

What codegraph does

codegraph builds a repository map from source code, covering files, symbols, references, and dependencies. Its MCP interface makes that structural information available to coding agents working against a local repository. The project also ships as a CLI and TypeScript library, so the same analysis can be used directly without an agent.

The repository map is intended to answer questions such as where an implementation lives, which files depend on a symbol, what a change might affect, and which tests are plausible validation targets. Results can include source evidence and next steps bounded to the relevant parts of the codebase.

codegraph complements rather than replaces other developer tools. Text search is still useful for exact strings, while compilers establish language behavior; codegraph supplies the relationships between files and symbols that those tools do not represent as a repository map.

How it works

Source files are parsed with tree-sitter and converted into a resolved model of repository relationships. The model can represent symbol definitions, references, dependencies, reverse dependencies, exports, and candidate tests. The CLI can search for terms, bundle search hits with related source and dependents, inspect individual targets, and calculate broader change impact.

Analysis can be performed against a working tree or compared across revisions. Review and impact commands summarize changed symbols and possible blast radius, while affected-test analysis derives test paths from changed files and reverse dependencies. Additional inspections identify dependency cycles, unresolved items, highly connected files, duplicate code, undocumented exported symbols, and broken local Markdown links.

The graph can also be exported as JSON, SQLite, Mermaid, or DOT. A packaged viewer presents a human-facing graph UI, while agents are directed toward graph JSON, SQLite, MCP, or structured JSON output instead.

Setup and configuration

The package requires Node.js 22.16 or newer. Install it globally from npm with:

Terminal
npm install -g @lzehrung/codegraph

After installation, codegraph doctor checks the local setup and codegraph install performs the project’s installation step. A typical repository exploration starts with:

bash
codegraph explore "build review report" --root .

Standalone shell and PowerShell installers are also available. They download a self-contained bundle containing Node.js, the CLI, and the matching native runtime. Repository operations accept a root directory, and many commands support JSON output for structured consumption.

Tools and capabilities

  • Explore a repository by combining lexical search with source, dependents, and candidate tests.
  • Explain files or targets, inspect semantic references, and list direct or reverse dependencies.
  • Review changes, calculate impact, and identify affected test paths between revisions.
  • Preview refactoring evidence and rename effects without applying code changes.
  • Inspect API surfaces, undocumented exports, cycles, unresolved relationships, hotspots, and duplicate groups.
  • Export repository graphs to JSON, SQLite, Mermaid, or DOT, or inspect them in the packaged viewer.

Limitations and notes

codegraph is not an AST, compiler, or linter. Its output should be used alongside exact text search and compiler checks rather than as a substitute for either. Search queries are lexical, so terms that appear in the code produce the most useful results.

The graph viewer is intended for people, whereas agents should use MCP, graph JSON, SQLite, or structured CLI output. Refactoring and rename-preview operations provide read-only evidence and do not modify source files. External URLs are skipped by the Markdown-link checker, which focuses on local links.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Codegraph

codegraph is an MCP server that connects coding agents to local source repositories and exposes tree-sitter-based analysis of files, symbols, references, and dependencies. Its main tools support repository exploration, relationship tracing, change-impact assessment, and candidate-test discovery with bounded source evidence.

Install codegraph globally with npm on Node.js 22.16 or newer. Run `npm install -g @lzehrung/codegraph`, then use `codegraph doctor` and `codegraph install`; standalone shell and PowerShell installers are also available.

codegraph analyzes a source tree’s files, symbols, references, dependencies, exports, and related tests. Its commands can also inspect cycles, unresolved relationships, duplicate groups, connected files, undocumented API symbols, and broken local Markdown links.

Yes, codegraph can identify candidate affected-test paths from changed files and reverse dependencies. The CLI supports comparisons such as `--base HEAD --head WORKTREE` and can produce quiet output for deterministic test-path results.

No, the refactoring and rename-preview capabilities are read-only and do not apply code changes. They return evidence, proposed edits, and conflict information for review.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewCodegraph AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/codegraph-3?style=directory)](https://allmcps.com/mcp/codegraph-3)
HTML Embed
<a href="https://allmcps.com/mcp/codegraph-3"><img src="https://allmcps.com/api/badge/codegraph-3?style=directory" alt="Codegraph on AllMCPs" /></a>