repo-cartographer
Produces Graphviz DOT output that can be piped into Backstage for architecture visualization and integration with Backstage's software catalog.
Provides a GitHub Action that enforces architecture rules on pull requests, posts diagrams and violations as comments, and fails the build on error-level violations.
Generates Mermaid flowchart diagrams from repository analysis, enabling visual architecture documentation that can be embedded in markdown and rendered on platforms like GitHub.
Click on "Deploy 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., "@repo-cartographer Generate a Mermaid diagram of the architecture in this repo"
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.
repo-cartographer
Understand any codebase in 60 seconds. An MCP server that turns any repository into an architecture diagram.
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.
Related MCP server: Code-Oracle
Example output
Running generate_diagram against this repo produces (a draft the model then refines):
flowchart TD
n0["src · 2 files"]
n1["src/lib · library code · 9 files"]
n2["src/resources · resource handlers · 1 file"]
n3["src/tools · tool implementations · 4 files"]
n0 --> n1
n0 --> n2
n0 --> n3
n1 --> n0
n3 --> n0
n3 --> n1A 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+.
# Run directly (no install)
npx -y repo-cartographer
# …or from source
git clone https://github.com/builditwithgk/repo-cartographer
cd repo-cartographer
npm install
npm run build
node dist/index.jsThe 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.
# Draw a diagram — path in, architecture.html out
npx -y repo-cartographer map ./my-project
npx -y repo-cartographer map ./my-project --level detail -o docs/architecture
npx -y repo-cartographer map ./my-project --format dot # Graphviz DOT instead of Mermaid
# Enforce architecture rules (exits 1 on an error-level violation — use it in CI)
npx -y repo-cartographer check ./my-project --config .cartographer.ymlZip-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:
# .cartographer.yml
rules:
forbidden:
- from: "src/ui/**"
to: "src/db/**"
reason: "UI must go through the service layer, not the DB directly."
cycles: error # error | warn | offAdopting on an existing codebase? Record today's violations as an accepted baseline, so only new ones fail the build:
npx -y repo-cartographer check . --update-baseline # writes .cartographer-baseline.jsonCommit 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:
# .github/workflows/architecture.yml
on: pull_request
permissions: { contents: read, pull-requests: write }
jobs:
architecture:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: builditwithgk/repo-cartographer@v1
with: { path: ., config: .cartographer.yml }This repo dogfoods it in .github/workflows/architecture.yml.
Full design + phases: docs/github-action.md.
Use it with Claude Code
claude mcp add repo-cartographer -- npx -y repo-cartographerThen ask: "Use repo-cartographer to map ./my-project and draw me an architecture diagram."
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"repo-cartographer": {
"command": "npx",
"args": ["-y", "repo-cartographer"]
}
}
}Use it with the OpenAI Agents SDK
Same server, a different model — the whole point of MCP:
import asyncio
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
async def main():
async with MCPServerStdio(
params={"command": "npx", "args": ["-y", "repo-cartographer"]},
) as cartographer:
agent = Agent(
name="Cartographer",
instructions=(
"Use the repo tools to gather facts, then refine the draft "
"Mermaid diagram into a clean architecture map."
),
mcp_servers=[cartographer],
)
result = await Runner.run(agent, "Map ./my-project and explain its architecture.")
print(result.final_output)
asyncio.run(main())Tools & resources
Tool | What it returns |
| The one-shot flow. Point it at a folder and get a downloadable architecture diagram ( |
| Languages, frameworks, entry points, top-level modules (with role guesses), and a manifest summary — as JSON facts. |
| Intra-repo import/require edges for JS/TS + Python. Nodes are files, auto-collapsed to module level for large repos. |
| A draft diagram. |
| Writes a self-contained, styled |
Resource | |
| Who built this and how to reach them (Markdown). |
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
npm run dev # run from source with tsx
npm run build # type-check + emit to dist/
npm test # unit tests (node:test, no build step needed)
npm run typecheck # type-check src/ and test/ together, no emitTests 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
Available Tools
5 toolsbuild_import_graphBuild import graphA
Extract intra-repo import/require relationships for JavaScript/TypeScript and Python. Nodes are files (auto-collapsed to module/directory level for large repos); edges are directed import relationships. Returns JSON.
Inputs: path (required).
generate_diagramGenerate diagramA
Combine scan + import facts into a DRAFT diagram string — Mermaid flowchart (default) or Graphviz DOT. level 'high' (default) shows modules/directories; 'detail' shows files grouped by module. This is a draft the calling model is expected to refine.
Inputs: path (required), level, format.
map_repoMap repository (one-shot)A
Point at a folder and get a downloadable architecture diagram in one call: runs scan + import-graph + render internally and returns the HTML path, a facts summary, and the draft diagram source inline. By default writes architecture.html plus the raw source (.mermaid or .dot) into the repo; pass outPath to write elsewhere. Use the granular tools (scan_repo, build_import_graph, generate_diagram, render_diagram) only when you need to compose the steps yourself.
Inputs: path (required), level, format, outPath.
render_diagramRender diagramA
Write a self-contained, shareable HTML page (renders via CDN: Mermaid, or Viz for Graphviz DOT) plus the raw source file (.mermaid or .dot). Returns the absolute paths written.
Inputs: source (required), outPath (required), format.
scan_repoScan repositoryA
Deterministically extract facts from a local repo: programming languages, frameworks/libraries, entry points, top-level modules (with role guesses), and a manifest summary. Returns JSON facts only — no interpretation.
Inputs: path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct role: scan_repo extracts facts, build_import_graph extracts import relationships, generate_diagram produces a draft string, render_diagram writes HTML files, and map_repo is a clearly labeled convenience wrapper that explicitly says when to use the granular tools. No two tools have overlapping purposes.
All tool names follow a consistent verb_noun pattern in snake_case: scan, build, generate, render, and map as verbs; repo, import_graph, and diagram as nouns. The naming scheme is uniform and predictable.
Five tools perfectly cover the repository mapping workflow. The high-level convenience tool plus four granular tools avoid bloat while providing flexibility. This is well within the ideal 3-15 range.
The tool set covers the full pipeline from repository scanning to dependency graph extraction to diagram generation and rendering. The convenience tool ties everything together, and there are no missing critical operations for the stated purpose.
Maintenance
Related MCP Connectors
Repository knowledge graph MCP server for codebase understanding and debugging.
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for rendering Mermaid diagrams and generating source-code diagrams, with tools to render text/files and produce dependency/class diagrams.55 npmMIT
- FlicenseNot gradedqualityDmaintenanceMCP server for automated architectural mapping, security vulnerability detection, ML asset tracking, and code metrics in local repositories.-
- FlicenseAqualityDmaintenanceMCP server for repository mapping, dependency analysis, and architecture diagram generation for JavaScript, TypeScript, and Python projects.412 npm-
- AlicenseNot gradedqualityBmaintenanceLocal-first MCP server that scans a repository once and answers architecture questions from an evidence-backed graph, enabling dependency analysis, impact analysis, and codebase exploration without re-reading the source tree.7MIT