
Repo Cartographer
io.github.builditwithgk由 GitHub 帳號 builditwithgk 發布v1.0.1更新於 Oct 24, 2026
Maps any repo into an architecture diagram (Mermaid/Graphviz) and enforces architecture rules in CI
概覽
把本機程式碼倉庫轉成架構圖並檢查架構規則,並透過 MCP 工具提供結果。
- 可以做什麼
- 把倉庫目錄解析成確定性事實:語言、框架、進入點、模組,以及 JavaScript/TypeScript 與 Python 的倉庫內匯入關係。根據這些事實產生 Mermaid 或 Graphviz DOT 草稿圖,以及自帶樣式的 HTML 渲染頁面。check 指令依規則檔標示禁止的跨邊界匯入與相依循環,並可把現有違規記錄為基準,讓只有新增違規才會失敗。
- 適用情境
- 適合讓助理說明不熟悉的程式碼庫、為拉取請求或新人文件起草架構圖,或在合併時用架構規則把關。同一個執行檔也能當成一般命令列工具供人和 CI 使用,不需要 AI 用戶端。
- 執行需求
- 需要 Node.js 18 或更新版本;這個套件透過 stdio 在本機執行,例如使用 npx。未宣告任何帳號、API 金鑰或環境變數。渲染出的 HTML 頁面在瀏覽器開啟時會從 CDN 載入 Mermaid 或 Viz。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Repo Cartographer,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
repo-cartographer
Understand any codebase in 60 seconds. An MCP server that turns any repository into an architecture diagram.
[TypeScript] [License] [Version] [MCP] [Architecture]
Point your LLM at a folder and get back an architecture map: languages, frameworks, entry points, modules, and an import graph — rendered as a Mermaid diagram you can drop into a PR, a doc, or an onboarding guide.
It is model-agnostic. It speaks the Model Context Protocol over stdio, so it works with Claude Code, Claude Desktop, Cursor, Cline, Copilot, or the OpenAI Agents SDK — no Claude-specific dependency.
Why it's different
The server extracts hard facts. The model does the reasoning.
repo-cartographer never tries to "understand" your code semantically. It parses deterministic facts — file tree, import edges, manifests, framework detection, entry points — and hands your LLM structured JSON plus a draft diagram. Your model turns those facts into the final narrative and a refined diagram.
That split keeps the server small, fast, testable, and portable — and it means the diagram is grounded in what's actually in the repo, not hallucinated.
Example output
Running generate_diagram against this repo produces (a draft the model then refines):
A self-contained, shareable HTML render is committed under examples/ (both a high-level and a file-level detail view).
Install & run
Requires Node.js 18+.
The server communicates over stdio; AI clients launch it that way. You can also use it directly from a terminal — see below.
Command line (no AI needed)
The same binary is dual-mode: with no arguments it's the MCP server; with a subcommand it's a plain CLI for humans and CI.
Zip-friendly: if you point it at an extracted "Download ZIP" folder (repo-main/ wrapper and all), it detects the wrapper and maps the real repo root — noted in the output, never silent.
Two output notations, one strategy: Mermaid because that's where people read it (GitHub renders it natively in PR comments and READMEs), DOT because that's what their tools eat (pipe it into Graphviz, Backstage, or anything else: dot -Tsvg architecture.dot). Both come with the same shareable HTML page and role-colored modules. When the repo has a .cartographer.yml, its diagram: section supplies the defaults for --level, --format and -o; explicit flags always win.
check reads a rules file and flags forbidden cross-boundary imports and dependency cycles — deterministically, no LLM involved, so it's safe to gate a merge:
Adopting on an existing codebase? Record today's violations as an accepted baseline, so only new ones fail the build:
Commit that file; later runs auto-detect it and pass unless a PR introduces a new violation.
Architecture governance in CI (GitHub Action)
A composite action (action.yml) runs check on every PR — failing the
build on an error-level violation and posting a sticky comment with the diagram and
any violations:
This repo dogfoods it in .github/workflows/architecture.yml.
Full design + phases: docs/github-action.md.
Use it with Claude Code
Then ask: "Use repo-cartographer to map ./my-project and draw me an architecture diagram."
Claude Desktop
Add to claude_desktop_config.json:
Use it with the OpenAI Agents SDK
Same server, a different model — the whole point of MCP:
Tools & resources
Most of the time you just want map_repo — "path in, diagram out." Reach for the four granular tools only when you want to compose the steps yourself (e.g. let the model refine the diagram source between generate_diagram and render_diagram).
How it stays fast on big repos
- Languages: JavaScript/TypeScript and Python (v1).
- Skips
node_modules,.git,dist,build,venv,__pycache__,vendor, and other build/dependency/cache directories (plus all hidden dirs). - Caps the number of files scanned and bytes read per file; collapses the import graph to directory level past a threshold. Anything capped is reported in the output — never dropped silently.
- No network calls at scan time. (The rendered HTML pulls Mermaid from a CDN only when you open it in a browser.)
- Deterministic: output is sorted and stable, so diagrams don't churn between runs.
Development
Tests cover the deterministic core — import resolution (JS/TS + Python), module
collapsing, cycle detection, rule globs, baseline diffing, Mermaid rendering and
the check end-to-end path. They run against src/ via tsx, so there is no
build step and no test framework dependency.
Author
Built by Gopi K Aitham (builditwithgk) — see about://author, or scaleup-solutions.in. Available for freelance and contract work on AI, agent, and MCP tooling.
License
MIT
來源:README.md,提交 2da0787
工具
0版本歷史
1- v1.0.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分