scan_repository_graph
Scan a local codebase into an architecture graph. Test files and external imports are excluded.
path必填maxDepthcollapseUtils
io.github.Karry1123由 GitHub 账号 Karry1123 发布v0.1.1更新于 Nov 2, 2026
Local architecture maps and caller impact analysis with directory clustering and utility folding.
本地 MCP 服务器:把代码库扫描成架构图,生成可交互 HTML 地图,并追踪改动文件的调用方。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
参照 仓库 中的启动说明。
Turn any codebase into an interactive architecture map in 2 seconds. Zero server, full privacy, built for Claude & Claude Code.
[RepoGraph demo: click a file for its blast radius, double-click a directory to collapse it]
[npm version] [MIT license] [Node >=18] [Languages]
👉 Try the interactive live demo (zustand's architecture, generated with one command)
Find the files that matter before changing the code. RepoGraph scans local imports, groups source files by directory and likely architectural layer, and writes an interactive HTML map. Directory clustering and utility folding help keep shared helpers from turning the view into a spiderweb. Three MCP tools let Claude inspect architecture and trace the impact of a proposed change.
“2 seconds” describes the quickstart experience, not a measured performance guarantee. Scan time and HTML size depend on the repository; a small map can be ~40 KB. No account, server, or configuration file is required.
Open the printed file:///.../repograph.html link. Click a file to see its incoming callers in cyan and outgoing dependencies in red. Double-click directory boxes to collapse or expand them. Press f to fit the graph to the viewport. Search matches subsequences in full file paths; the minimap lets you jump around large graphs.
Node.js 18 or newer is required. Scanning stays on your machine. The HTML embeds your file paths and graph data, so treat it as repository information when sharing. Opening the interactive map downloads pinned Cytoscape/layout scripts from public CDNs; no source or graph data is sent by RepoGraph. The CDN scripts must be reachable on first opening. SVG, JSON, and Mermaid exports need no browser CDN scripts.
The path defaults to .. HTML defaults to ./repograph.html in your current working directory and prints its absolute file URL after writing. Other formats print to stdout unless --output is supplied. Output directories are created automatically. --max-depth 0 scans only root files.
The static SVG arranges files in entry → business → unknown → data → util columns. Mermaid exports preserve nested directory subgraphs. Both include utility candidates; HTML initially hides folded utilities and their edges.
RepoGraph is listed on the official MCP Registry as io.github.Karry1123/repograph. Registry-aware clients can install it by that name; the manual Claude setup below also works.
Add this entry to claude_desktop_config.json, merging it with existing servers:
Restart Claude Desktop, then ask: “Scan my repository at /absolute/path/to/project and show the impact of changing src/core/graph.ts.” Use an absolute repository path; the MCP server may start with a different working directory. Windows paths work too, for example F:\\RepoGraph in JSON.
Ask Claude to generate an architecture map before a refactor, or find all transitive callers of a module before editing it. MCP mode uses stdio for the protocol and writes errors only to stderr.
Each tool performs its own fresh static scan of path on every call, so no prior scan is needed. Tools are annotated readOnlyHint: true except generate_architecture_html, which writes one file.
For HTML generation, a relative outputPath is resolved against the repository path. An absolute output path is used directly. The tools use a utility fan-in threshold of 15. Missing changed files return an error with the closest matching IDs. transitiveDependents includes direct callers at depth 1; blastRadius counts unique affected files and excludes the changed file itself.
Each source file becomes a node with a forward-slash relative ID. Local imports become directed edges from importer to dependency. JavaScript and TypeScript use Babel, with a regex fallback for unsupported syntax. Repeated references of the same type are combined with an edge weight. External packages are dropped. Class inheritance through an imported binding gets an inheritance edge; import() gets a dynamic edge.
RepoGraph tries source extensions, directory index files, NodeNext .js → .ts equivalents, and a heuristic @/ → src/ alias. It does not execute code or load project-specific compiler plugins. Computed imports and custom aliases can be missed.
Classification checks entry, business, data, then utility clues. It is an explainable filename heuristic, not a semantic judgement about your design. Clusters reflect the first two directory levels and retain nested parents.
Files with more than 12 incoming callers and at most two outgoing dependencies, or utility-like names, are folding candidates. CLI/API default to 12; MCP defaults to 15. Folded nodes and their edges stay in the graph data and impact analysis but disappear from the initial HTML view. “Show utilities” reveals them. Degree counts use unique neighboring files, not repeated imports.
Impact analysis performs a breadth-first search over reverse edges. It handles cycles, visits each file once, and records the shortest caller depth. The inspector lists direct callers and dependencies; the highlight traces both full transitive chains. If a cycle belongs to both chains, the dependency highlight takes precedence.
Dead-code warnings count files with no incoming local edges that do not look like entry points. Treat these as review hints: frameworks, reflection, external consumers, and dynamic loading can all create valid files with no static callers. Coupling factor is average unique out-degree; density is edges divided by n * (n - 1) (zero for fewer than two files). LOC counts nonblank source lines, including comments.
Root and nested .gitignore rules are respected. RepoGraph skips dependency, build, cache, and editor directories, including node_modules, .git, dist, build, out, coverage, __pycache__, .venv, venv, .next, .nuxt, target, vendor, .idea, .vscode, and .cache. Symlinks are skipped to prevent cycles. Files larger than 1.5 MB and *.min.js are excluded. Test/spec files are excluded from the main graph, with their count retained as metrics.excludedTestFiles.
Python, Go, and Rust resolution is intentionally static and heuristic: workspace manifests, build tags, Python import hooks, Rust macros, and non-root Go modules are not evaluated. Only files included in the scan can become nodes or targets.
This table describes the tools' focus rather than a feature-completeness or performance benchmark. Check each project's current documentation for its full capabilities.
createServer() and startMcpServer() are exported from dist/src/index.js; importing the module does not start a transport. The graph data model lives in src/types.ts and ships with generated TypeScript declarations.
During development, use npm run dev -- .. On Windows PowerShell installations that block npm.ps1, use npm.cmd. Keep path IDs portable, avoid executing scanned code, and test resolution changes against a small repository containing the relevant imports. Include reproduction steps and the expected edges in bug reports or contributions.
MIT © 2026 Karry. See LICENSE.
Star to vote, open a Language Support Request issue, and share the imports and project layout you need supported. These thresholds guide priorities rather than promise delivery dates.
来源:README.md,提交 dd0b91b
Scan a local codebase into an architecture graph. Test files and external imports are excluded.
path必填maxDepthcollapseUtilsWrite a self-contained interactive architecture map of a local codebase.
path必填themeoutputPathFind direct and transitive callers of a changed file, with BFS depths and affected clusters.
path必填changedFile必填已满足适用检查项的 90%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
npx repograph-cli .repograph [path] [options]repograph mcp
Options: -o, --output <file> Write to a file --theme <theme> dark | light | matrix (default: dark) --max-depth <n> Maximum directory nesting (default: 6) --no-collapse-utils Show utility candidates immediately --format <format> html | json | mermaid | svg (default: html) -V, --version Show version -h, --help Show helpnpx repograph-cli ./my-app --output ./architecture.html --theme matrixnpx repograph-cli . --format json > graph.jsonnpx repograph-cli . --format mermaid --output architecture.mmdnpx repograph-cli . --format svg --output architecture.svgnpx repograph-cli . --max-depth 10 --no-collapse-utils{ "mcpServers": { "repograph": { "command": "npx", "args": ["-y", "repograph-cli", "mcp"] } }}claude mcp add repograph -- npx -y repograph-cli mcpimport { analyzeRepository } from 'repograph-cli/dist/src/api.js';import { impactPath } from 'repograph-cli/dist/src/core/graph.js';import { renderToHtml } from 'repograph-cli/dist/src/renderer/htmlTemplate.js';
const graph = await analyzeRepository('.', { maxDepth: 6, collapseUtils: true, utilThreshold: 12,});const impact = impactPath(graph, 'src/api.ts');const html = renderToHtml(graph, { theme: 'dark' });npm installnpm run buildnode dist/bin/cli.js . --output demo/self.htmlnode dist/bin/cli.js . --format jsonnode dist/bin/cli.js . --format mermaid