Skip to main content
Glama
README.md
![C4 Architect — local source, reviewable evidence, readable diagrams](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/hero.svg)

# C4 Architect

**Explore a TypeScript codebase without pasting the whole repository into a prompt.**

C4 Architect is a local [Model Context Protocol](https://modelcontextprotocol.io/) server that turns source imports into a versioned dependency graph, lets you review and name its architectural boundaries, and produces compact C4 diagrams. Use it from Codex, Claude Code, Claude Desktop, or another client that supports local MCP servers over `stdio`.

**Published alpha · [0.2.0-alpha.16](https://github.com/zrack/c4-architect-mcp/releases/tag/v0.2.0-alpha.16) · TypeScript / TSX · Local parsing · MIT licensed**

[Try the example](#try-the-example) · [Walk through my system](#walk-through-my-system) · [What depends on this file?](#what-depends-on-this-file) · [Get started](#get-started) · [npm package](https://www.npmjs.com/package/c4-architect-mcp) · [See the diagrams](#c4-diagrams) · [Contribute](https://github.com/zrack/c4-architect-mcp/blob/main/CONTRIBUTING.md) · [Roadmap](https://github.com/zrack/c4-architect-mcp/blob/main/ROADMAP.md)

## Try the example

**What happens if Oracle saves an event and the consumer restarts?** In the example below, Kafka sends the event again. The application finds the row it already saved, acknowledges the write, and the bridge can advance its checkpoint. Follow steps 5–11 on the right. [Open the full-size diagram](examples/three-tier-kafka-oracle/replay/results/after-kafka.svg)

[![Successful delivery beside a restart after Oracle commits. The integration bridge owns the Kafka checkpoint in both cases.](examples/three-tier-kafka-oracle/replay/results/after-kafka.png)](examples/three-tier-kafka-oracle/replay/results/after-kafka.svg)

With the walkthrough skill available in Codex, try this prompt.

> Try the Kafka and Oracle replay example. Show me what happens if Oracle saves the event and the consumer restarts. Who owns the checkpoint in each bridge placement?

With Node.js 22 or newer, install alpha.16 and run the example from any folder.

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
c4-architect-mcp demo replay
```

The demo simulates one event locally. It prints paths to a Markdown report and two diagrams. Each diagram pairs a successful write with a restart after Oracle commits. With the bridge before Kafka, the application owns the checkpoint. With the bridge after Kafka, the bridge owns it. [Bridge before Kafka](examples/three-tier-kafka-oracle/replay/results/before-kafka.svg) · [Bridge after Kafka](examples/three-tier-kafka-oracle/replay/results/after-kafka.svg) · [Six-case report, including failed writes](examples/three-tier-kafka-oracle/replay/results/report.md)

<details>
<summary>Prefer running from a source checkout?</summary>

Use Node.js 22 or newer. These commands build and run the example from this checkout.

```sh
npm ci
npm run build
node dist/index.js demo replay
```

To follow future prereleases, install `c4-architect-mcp@alpha`. [npm package](https://www.npmjs.com/package/c4-architect-mcp)

</details>

## Walk through my system

Open Codex with the walkthrough skill available. Start with a sentence about who sends something, who receives it, and what happens next.

> Walk through my system. Our web app receives orders from Kafka and stores them in Oracle. Draw the first diagram and ask me the question that matters most.

Codex saves an editable overview, a rendered diagram, and a short `walkthrough.md` in your project. The first question depends on what you tell it. If the consumer is unclear, it can ask who reads from Kafka. Once you name the consumer, it can ask how that component knows the Oracle write committed. [First-time results for both README paths](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.15/docs/reviews/alpha15-first-use/README.md)

<details>
<summary>Make the skill available in another project</summary>

After the global install above, run `npm root -g` to find the directory containing the installed `c4-architect-mcp` package. Copy its [solution-architect-walkthrough folder](.agents/skills/solution-architect-walkthrough) from `.agents/skills/` into your project's `.agents/skills/` directory, then open a new Codex chat there. You can explicitly select `$solution-architect-walkthrough` with your description.

</details>

## Solution architect walkthrough

Where an integration bridge sits changes which diagrams an architect should revisit. This skill compares alternative answers against the same set of diagrams, traces each finding to a node or arrow, and lists the questions that still need an owner’s answer.

> Use `$solution-architect-walkthrough` on the Kafka and Oracle RAC example. Compare a bridge that feeds Kafka with a bridge that consumes from Kafka and delivers to the application. Show which views need review and why.

### Kafka and Oracle RAC bridge comparison

In the [baseline design](examples/three-tier-kafka-oracle/walkthrough.json), the application consumes events from Kafka and writes records to Oracle RAC. A bridge that **publishes to Kafka** changes the publisher in **1 of 7 diagrams**. A bridge that **consumes from Kafka** takes over delivery to the application, so **6 of 7 diagrams** need structural review.

| Diagram | Bridge before Kafka · [alpha.14 report](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.14/examples/three-tier-kafka-oracle/walkthrough/reports/bridge-before-kafka.md) | Bridge after Kafka · [alpha.14 report](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.14/examples/three-tier-kafka-oracle/walkthrough/reports/bridge-after-kafka.md) |
| --- | --- | --- |
| System Context | Keep Kafka as the application's direct event source. | **Review R02.** Show the bridge as the application's direct event source. |
| Container | Keep the application server's dependency on Kafka. | **Review R03.** Show the bridge consuming from Kafka and delivering to the application server. |
| Data Flow | Keep the event record flowing from Kafka into processing. | **Review R05.** The incoming record now comes from the bridge. Processing still writes to Oracle RAC. |
| Component | Keep the Kafka consumer inside the application server. | **Review R02.** Identify the component that receives events from the bridge. |
| Code | Keep the processor's `InboundEvent` input. | Keep the same `InboundEvent` input. This scenario changes who delivers it. |
| Deployment | Keep the Kafka consumer in the application server runtime. | **Review R02.** Identify the runtime that hosts the bridge's consumer and show its connection to the application. |
| System Landscape | **Review R01.** Show the bridge publishing to Kafka. The originating business system is still unknown. | **Review R02.** Show the delivery path from Kafka through the bridge to the application. |

The R numbers identify arrows within each diagram. Both reports also flag Kafka's description in System Context, Container, Component and System Landscape for a wording update. Five questions stay open in both placements, including when to checkpoint Kafka relative to the Oracle commit.

To generate both reports from the published package on macOS or Linux, run these commands.

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
example="$(npm root -g)/c4-architect-mcp/examples/three-tier-kafka-oracle"
c4-architect-mcp review-walkthrough "$example/walkthrough.json" "$example/walkthrough/bridge-before-kafka.json" --out output/bridge-before.md
c4-architect-mcp review-walkthrough "$example/walkthrough.json" "$example/walkthrough/bridge-after-kafka.json" --out output/bridge-after.md
```

Open this repository in Codex to use the prompt above. Codex discovers the skill in the checkout’s `.agents/skills` directory.

Through MCP, call `review_architecture_walkthrough` with `manifestPath`, `scenarioPath`, and `outputPath`. Each review checks the authored evidence against the saved diagram models. To apply it to another system, see the [manifest and scenario format](.agents/skills/solution-architect-walkthrough/references/walkthrough-format.md).

### What happens if the consumer restarts after Oracle commits?

The [one-command demo](#try-the-example) runs both bridge placements. To change the event or acknowledgment policy, copy the [editable scenario](examples/three-tier-kafka-oracle/replay/scenario.json) and pass its path to `review-replay`. The command below runs the bundled input from a built checkout.

```sh
node dist/index.js review-replay examples/three-tier-kafka-oracle/replay/scenario.json --out output/replay
```

The fixture models persistence and restarts in memory. To try a design where the meaning of an acknowledgment is still open, set `bridgeAcknowledgment` to `unspecified` and compare the downstream checkpoint.

## What changed in this PR?

Try this prompt in Codex with this repository, or replace the PR URL with your own. You can also generate the report from GitHub’s Actions tab. [Set up the skill](#review-architecture-changes-for-a-pull-request) · [Run it in GitHub Actions](#run-the-review-in-github-actions)

> Use `$what-changed-in-this-pr` on https://github.com/zrack/c4-architect-mcp/pull/16. Show me the dependencies it added or removed in `src`, draw the focused diagram, and link each arrow to its import.

PR #16 added ten internal dependencies when it introduced `explain-this-file`. Follow **R06** from the CLI and **R08** from the MCP server. Both import the same renderer. The report matches every arrow to its source line and identifies the two type-only imports. [Read the Markdown report for all ten added dependencies](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.12/docs/reviews/pr-16/PR-16.md#dependency-changes).

[![Focused Component diagram of PR #16 with ten numbered arrows. R06 and R08 connect the CLI and MCP server to the explainFile renderer.](https://raw.githubusercontent.com/zrack/c4-architect-mcp/v0.2.0-alpha.12/docs/reviews/pr-16/PR-16.focus-9032b03b69eb2b17.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/v0.2.0-alpha.12/docs/reviews/pr-16/PR-16.focus-9032b03b69eb2b17.png)

## Explain this file

> Use $explain-this-file on `NoteEditor.tsx` in `./src`. What imports it, and what does it import? Show me the focused diagram and the source lines for both directions.

Try this prompt in a TakeNote checkout, or substitute a file from your own TypeScript project. On TakeNote's `src` snapshot, the skill narrows **108 nodes and 363 relationships to 15 nodes and 19 relationships**. Two arrows show where the editor fits.

- **Incoming · R01.** `TakeNoteApp.tsx` imports `NoteEditor`. [Read the import on line 11](https://github.com/taniarascia/takenote/blob/e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331/src/client/containers/TakeNoteApp.tsx#L11)
- **Outgoing · R19.** `NoteEditor.tsx` imports `PreviewEditor`. [Read the import on line 12](https://github.com/taniarascia/takenote/blob/e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331/src/client/containers/NoteEditor.tsx#L12)

The editor has one direct importer and 18 outgoing import statements. Ten of those statements reference packages whose installed files were unavailable in the clean checkout. The report lists every import and identifies those ten locations. [Read the generated report](https://github.com/zrack/c4-architect-mcp/blob/62d94bfb4fd4c17d9b5ca157eb5a07f13eb4da73/examples/takenote/NoteEditor.md) · [Open the full-size diagram](https://raw.githubusercontent.com/zrack/c4-architect-mcp/62d94bfb4fd4c17d9b5ca157eb5a07f13eb4da73/examples/takenote/NoteEditor.focus-fc1052d6a7d39748.png)

<a href="https://raw.githubusercontent.com/zrack/c4-architect-mcp/62d94bfb4fd4c17d9b5ca157eb5a07f13eb4da73/examples/takenote/NoteEditor.focus-fc1052d6a7d39748.png"><img src="https://raw.githubusercontent.com/zrack/c4-architect-mcp/62d94bfb4fd4c17d9b5ca157eb5a07f13eb4da73/examples/takenote/NoteEditor.focus-fc1052d6a7d39748.png" alt="TakeNoteApp imports NoteEditor, which imports PreviewEditor and 12 other modules or packages. Each arrow has an ID that matches the source report." width="700"></a>

Planning a change to the editor? The file-impact report follows its callers beyond the first import, from `TakeNoteApp.tsx` through `App.tsx` to the client entry point. [Trace the callers](#what-depends-on-this-file)

<details>
<summary><strong>Try it on your project or reproduce the TakeNote example</strong></summary>

From your project root, choose a TypeScript or TSX file under `src` and run the CLI with Node.js 22 or 24. The command writes a Markdown report and a focused PNG to `output/`.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 explain-file ./src NoteEditor.tsx --out output/NoteEditor.md
```

To use the prompt in Codex on macOS or Linux, install the package once and link its bundled skill. Then start a chat in the project you want to inspect.

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
mkdir -p "$HOME/.agents/skills"
ln -s "$(npm root -g)/c4-architect-mcp/.agents/skills/explain-this-file" "$HOME/.agents/skills/explain-this-file"
```

With the MCP server connected, you can also copy the installed package’s `.agents/skills/explain-this-file` folder into your project's `.agents/skills/` directory. [Read the skill](https://github.com/zrack/c4-architect-mcp/blob/62d94bfb4fd4c17d9b5ca157eb5a07f13eb4da73/.agents/skills/explain-this-file/SKILL.md)

To reproduce the diagram above, use a clean checkout of [the pinned TakeNote revision](https://github.com/taniarascia/takenote/tree/e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331) before installing its dependencies. Run this from the TakeNote root to include commit-pinned GitHub source links in the report.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 explain-file ./src NoteEditor.tsx --out output/NoteEditor.md \
  --github-repo taniarascia/takenote --commit e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331 --source-root src
```

</details>

![Workflow: parse local source, preserve evidence, declare boundaries, query and compare, render and export](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/workflow.svg)

## Start with evidence

An import is evidence of a code dependency. It does not, by itself, prove that two modules are separately deployed services, that an SDK call uses a particular protocol, or that a data flow is secure.

C4 Architect keeps that distinction visible. Source locations and content hashes support observed dependencies. Naming heuristics remain inferences. A separate boundary configuration records the systems, containers, and components that a person has declared. Rescanning the source preserves those declarations.

The result is a starting point for application and solution architecture review. Runtime behavior, organization structure, and enterprise architecture still need other evidence.

| Available in this alpha | Purpose |
| --- | --- |
| Local Tree-sitter analysis | Extract TypeScript and TSX dependencies without an LLM parsing the source files. |
| Versioned graph and source evidence | Save a graph for review, with source locations, file hashes, and analysis diagnostics. |
| Explicit boundary mapping | Give systems, containers, and components stable names through a separate configuration file. |
| Summary, neighborhood queries, and comparison | Inspect a saved graph without returning the entire graph every time. |
| [File impact](#what-depends-on-this-file) | Find direct and indirect importers before changing a file. Follow each reported path to its source lines. |
| Context, Container, and Component diagrams | Render a graph projection or a graph supplied by the caller. |
| Deployment, Dynamic, System Landscape, and Code diagrams | Render explicit nodes and relationships supplied by the caller. |
| [Data-flow diagrams](#native-data-flow-diagrams) | Follow named payloads between external entities, processes and data stores. |
| Compact PNG, SVG, and interactive HTML | Trace orthogonal connections, inspect relationship labels, and export a selected view. |

Export native shapes, nested deployment groups, and connector labels that you can edit in Draw.io. [Editable Draw.io export](#export-editable-drawio-diagrams)

Export a Structurizr DSL workspace with up to four views of the same model. [Structurizr DSL export](#export-a-structurizr-dsl-workspace)

Preview a diagram bundle locally, then publish its page and PNGs to a documentation workspace. [Azure DevOps Wiki](#publish-to-azure-devops-wiki) · [Confluence Cloud](#publish-to-confluence-cloud) · [Notion](#publish-to-notion)

Cross-repository mapping, additional languages, and assisted threat modeling are planned. [Roadmap](https://github.com/zrack/c4-architect-mcp/blob/main/ROADMAP.md)

## C4 diagrams

### Trail Notes examples

Start with the whole system, then zoom in as far as the question requires. These diagrams use the same fictional trail journal app. Select a preview to open the full-size PNG, or download its JSON to render it yourself. [C4 model diagram guide](https://c4model.com/diagrams)

#### Static structure

| 1. Context | 2. Container |
| --- | --- |
| See who uses Trail Notes and the system it depends on. | Zoom into the web app, Notes API, and database. |
| [![Trail Notes Context diagram](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-context.png)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-context.png) | [![Trail Notes Container diagram](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-container.png)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-container.png) |
| [Download Context JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-context.json) | [Download Container JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.5/trail-notes-container.json) |

| 3. Component | 4. Code |
| --- | --- |
| Follow a timed-out note submission and see who owns the retry. | See how the repository returns the original note ID or rejects a changed draft. |
| [![Trail Notes Component diagram](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/docs/images/trail-notes-retry-component.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/docs/images/trail-notes-retry-component.png) | [![Trail Notes Code diagram](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/docs/images/trail-notes-retry-code.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/docs/images/trail-notes-retry-code.png) |
| [Component JSON](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/diagrams/component.json) · [Retry with the same request](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/src/trail-client.ts#L21) · [All Component source links](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/README.md#component) | [Code JSON](https://raw.githubusercontent.com/zrack/c4-architect-mcp/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/diagrams/code.json) · [Return the existing note](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/src/note-repository.ts#L30) · [All Code source links](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/README.md#code) |

The first save commits before the simulated timeout. The retry returns the same note ID and leaves one stored note. [Run the TypeScript sample](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/README.md#run-the-demo) · [See the timeout in source](https://github.com/zrack/c4-architect-mcp/blob/5a48bd36068821d44fa266884759e30f7dd6738d/examples/trail-notes/src/demo.ts#L22)

For a Component example based on a real scan, follow the `App.tsx` → `CaseWorkspace.tsx` import in the [ReplayCase alpha.5 diagram](https://github.com/zrack/c4-architect-mcp/releases/tag/v0.2.0-alpha.5#replaycase-component-diagram).

#### Supporting views

Use these views to show the wider landscape, a sequence of interactions, or where the software runs.

| System Landscape | Dynamic | Deployment |
| --- | --- | --- |
| Place Trail Notes in the wider set of people and systems. | Follow the five steps for submitting a note. | See which hosts run the web app, API, and database. |
| [![Trail Notes System Landscape diagram](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-system-landscape.png)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-system-landscape.png) | [![Trail Notes Dynamic diagram](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-dynamic.png)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-dynamic.png) | [![Trail Notes Deployment diagram](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-deployment.png)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-deployment.png) |
| [Download System Landscape JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-system-landscape.json) | [Download Dynamic JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-dynamic.json) | [Download Deployment JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-deployment.json) |

##### Deployment comparison

The left view places the app and database on separate hosts. The right view shows the equipment at an illustrative visitor center and traces traffic from a field tablet through the firewall to the two servers.

[![Side-by-side Trail Notes deployment comparison with the README view on the left and the physical visitor center example on the right](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aed76d5f7c48a1f6c6c36eeee01acd5fbc60601d/docs/images/trail-notes-deployment-comparison.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aed76d5f7c48a1f6c6c36eeee01acd5fbc60601d/docs/images/trail-notes-deployment-comparison.png)

[README deployment JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.4/trail-notes-deployment.json) · [Physical deployment JSON](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aed76d5f7c48a1f6c6c36eeee01acd5fbc60601d/examples/trail-notes/diagrams/physical-deployment.json)

Download any example JSON and run `render-diagram` from the folder where you saved it. This command renders the Context example.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 render-diagram trail-notes-context.json --out TRAIL-NOTES.md
```

Open `TRAIL-NOTES.html` to explore the diagram.

### Native data-flow diagrams

Which path writes to Oracle? In the three-tier example below, a web request gets a response. A separate Kafka event reaches the application server, which writes an event-derived record to Oracle RAC. Each arrow names the data that moves and points toward its recipient.

![Web request and response alongside an inbound Kafka event processed and stored in Oracle RAC](https://raw.githubusercontent.com/zrack/c4-architect-mcp/v0.2.0-alpha.13/examples/three-tier-kafka-oracle/data-flow.png)

The [editable example](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.13/examples/three-tier-kafka-oracle/data-flow.json) uses `"c4Level": "DataFlow"`. Use `ExternalEntity` for sources and recipients outside the processes being described, `Process` for work that handles data, and `DataStore` for retained data. A flow connects a process to another process, an external entity or a store. Supply the payload names and directions from your design.

Download the [editable JSON](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.13/data-flow.json) and run this command in the folder where you saved it.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 render-diagram data-flow.json --out DATA-FLOW.md
```

Open `DATA-FLOW.html` and select Kafka to highlight its outgoing event. To generate the same diagram through MCP, pass the example JSON to `render_c4_mermaid` with `outputPath` set to `DATA-FLOW.md`.

The [seven-view walkthrough (PDF)](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.13/docs/reviews/three-tier-kafka-oracle/Walkthrough.pdf) places Data Flow on page 3, between Container and Component. Download the [offline walkthrough (ZIP)](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.13/Three-tier-architecture.zip) and open `Walkthrough.html` to explore the full example.

## Get started

Use Node.js 22 or 24 and npm. Run the pinned alpha without a checkout:

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 --help
```

The examples pin `0.2.0-alpha.16` for a repeatable setup. `c4-architect-mcp@alpha` follows the prerelease channel and currently selects `0.2.0-alpha.16`. npm's `latest` tag remains on `0.2.0-alpha.1`, the initial prerelease. There is no stable release yet.

The server communicates over `stdio`; starting it without a subcommand waits for an MCP client rather than opening a browser page or an HTTP port. The following configurations let your client start it through `npx`.

<details>
<summary><strong>Codex</strong></summary>

Add this to `~/.codex/config.toml`, or use the MCP server settings in the Codex desktop app:

```toml
[mcp_servers.c4-architect]
command = "npx"
args = ["-y", "c4-architect-mcp@0.2.0-alpha.16"]
```

You can also register it from the Codex CLI:

```sh
codex mcp add c4-architect -- npx -y c4-architect-mcp@0.2.0-alpha.16
```

Reconnect the server after configuration changes. See the [official Codex MCP setup guide](https://learn.chatgpt.com/docs/extend/mcp).

</details>

<details>
<summary><strong>Claude Code</strong></summary>

```sh
claude mcp add --transport stdio c4-architect -- npx -y c4-architect-mcp@0.2.0-alpha.16
```

Use `/mcp` to inspect the connection. See the [official Claude Code MCP documentation](https://code.claude.com/docs/en/mcp).

</details>

<details>
<summary><strong>Claude Desktop</strong></summary>

Open **Settings → Developer → Edit Config** and merge this entry with your existing `mcpServers` configuration:

```json
{
  "mcpServers": {
    "c4-architect": {
      "command": "npx",
      "args": ["-y", "c4-architect-mcp@0.2.0-alpha.16"]
    }
  }
}
```

Completely restart Claude Desktop after saving. For Windows JSON paths, use forward slashes or escape each backslash. See the [official local MCP server setup guide](https://modelcontextprotocol.io/docs/develop/connect-local-servers).

</details>

These are local `stdio` configurations. Verify the connection in your chosen client. If a desktop app cannot find `npx`, use the executable's absolute path. On Windows, a client that cannot launch `npx` directly can use `command: "cmd"` with `args: ["/c", "npx", "-y", "c4-architect-mcp@0.2.0-alpha.16"]`.

### Optional global installation

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
c4-architect-mcp --help
```

With a global installation, use `c4-architect-mcp` as the MCP command with no arguments, or use it in place of the pinned `npx` command below. Use an absolute executable path if your desktop client's PATH differs from your terminal's.

### Use the CLI directly

You can analyze and render without an MCP client:

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 analyze /absolute/path/to/project/src --level Component --out /absolute/path/to/project/architecture.graph.json --summary
npx -y c4-architect-mcp@0.2.0-alpha.16 summary /absolute/path/to/project/architecture.graph.json
npx -y c4-architect-mcp@0.2.0-alpha.16 render /absolute/path/to/project/architecture.graph.json --out /absolute/path/to/project/ARCHITECTURE.md
```

Replace `/absolute/path/to/project` with your project's location. Open the generated `ARCHITECTURE.html` beside the Markdown to explore the diagram.

For explicit compiler settings, add `--tsconfig /absolute/path/to/tsconfig.json` to `analyze`. The nearest `tsconfig.json` is otherwise discovered and read as data. Boundary configuration is loaded only when `--config` is supplied. The CLI also provides `query`, `diff`, and `review` commands. Use `--help` for their options.

### Run from a checkout or try the sample

Clone the repository to contribute, inspect the source, or try the included [synthetic order-service example](https://github.com/zrack/c4-architect-mcp/blob/main/examples/README.md):

```sh
git clone https://github.com/zrack/c4-architect-mcp.git
cd c4-architect-mcp
npm ci
npm test
node dist/index.js analyze examples/order-service/src --level Component --config examples/c4-architect.config.json --out output/order-service.graph.json --summary
node dist/index.js render output/order-service.graph.json --out output/ORDER-SERVICE.md
```

`npm test` builds `dist/index.js` and runs the automated tests. Open `output/ORDER-SERVICE.html` to explore the sample. To connect an MCP client to your checkout, use `node` as the command and the absolute path to `dist/index.js` as its only argument. After changing TypeScript, run `npm run build` and reconnect the server to load the new code.

## Analyze a project

Ask your connected client:

> Use c4-architect to analyze `/absolute/path/to/project/src` at the Component level. Save the graph to `/absolute/path/to/project/architecture.graph.json` and return a summary. Review the diagnostics and inferred boundaries, then use `render_architecture_graph` to save `/absolute/path/to/project/ARCHITECTURE.md`.

The analysis tool accepts:

```json
{
  "targetDir": "/absolute/path/to/project/src",
  "c4Level": "Component",
  "outputPath": "/absolute/path/to/project/architecture.graph.json",
  "responseMode": "summary"
}
```

`responseMode: "summary"` saves the complete graph locally and returns counts and status, keeping it out of the model's context until needed. It requires `outputPath`. The default `"graph"` mode returns the graph.

Use absolute paths: an MCP client's working directory may differ from the repository you want to analyze. Check diagnostics before treating a missing edge as an absent dependency. Static analysis cannot resolve every computed import or establish every runtime connection.

The current parser covers `.ts` and `.tsx`, excluding declaration files, dependency/build/output directories, and symlink trees. It uses one nearest or explicitly supplied `tsconfig.json` per scan; nested project configurations are not orchestrated automatically. Static imports, re-exports, and literal `import()` / `require()` dependencies are supported; computed dependencies and parse problems remain visible through diagnostics.

Existing CSS, SVG, and other local assets found through relative imports, `paths` aliases, or `baseUrl` produce an `UNSUPPORTED_MODULE_TYPE` diagnostic. The graph contains the TypeScript/TSX dependencies. An unresolved specifier that matches a configured alias produces an `UNRESOLVED_IMPORT` diagnostic.

To name architectural boundaries, supply `configPath` explicitly. The [example configuration](https://github.com/zrack/c4-architect-mcp/blob/main/examples/c4-architect.config.json) demonstrates the format:

```json
{
  "schemaVersion": "1.0",
  "system": { "id": "shop", "label": "Shop" },
  "defaultContainer": {
    "id": "application",
    "label": "Application",
    "technology": "TypeScript / Node.js"
  },
  "components": [
    { "id": "orders", "label": "Order orchestration", "paths": ["orders"] },
    { "id": "payments", "label": "Payments", "paths": ["payments"] }
  ]
}
```

`paths` are literal file or directory prefixes relative to `targetDir`, not globs. Give a component a `containerId` when mapping it into an explicitly configured container. Ambiguous matches are rejected. Unmapped files use the default container, which is inferred unless you configure it. Keep this configuration separate from the generated graph.

```json
{
  "targetDir": "/absolute/path/to/project/src",
  "c4Level": "Component",
  "configPath": "/absolute/path/to/project/c4-architect.config.json",
  "tsconfigPath": "/absolute/path/to/project/tsconfig.json",
  "outputPath": "/absolute/path/to/project/architecture.graph.json",
  "responseMode": "summary"
}
```

## Inspect before drawing

| Tool | Input | Result |
| --- | --- | --- |
| `review_architecture_walkthrough` | `manifestPath`, `scenarioPath`, `outputPath` | A Markdown report identifying the diagrams a design change affects, the supporting nodes or arrows, and open questions. |
| `review_replay_walkthrough` | `scenarioPath`, `outputDirectory` | Six Kafka and Oracle replay traces, a Markdown report, and success and restart diagrams paired by checkpoint owner. |
| `explain_architecture_file` | `targetDir`, `file`, `outputPath`. Optional `tsconfigPath`, `repository`, `commit`, `sourceRoot`, `maxNodes`, `maxEdges`. | A Markdown report and focused diagram of one file’s incoming and outgoing dependencies, with source locations and unresolved imports. |
| `analyze_architectural_boundaries` | `targetDir`, `c4Level`; optional `configPath`, `tsconfigPath`, `outputPath`, `responseMode` | A saved graph, full response, or compact summary at the requested C4 level. |
| `get_architecture_summary` | `graphPath` | A compact overview of a saved graph and its diagnostics. |
| `query_architecture_graph` | `graphPath`; optional `nodeId`, `search`, `direction`, `maxDepth`, `maxNodes`, `maxEdges`, `maxBytes`, `includeEvidence` | A bounded neighborhood or search, with truncation reported. |
| `analyze_file_impact` | `targetDir`, `file`, `outputPath`. Optional `tsconfigPath`, `maxDepth`, `maxNodes`. For GitHub links, supply `repository` and `commit` together, plus `sourceRoot` when scanning a subdirectory. | Direct and indirect importers grouped by distance, with a source-linked path for each file shown. |
| `compare_architecture_graphs` | `beforePath`, `afterPath`; optional `limit`, `maxBytes` | Change counts and bounded details for snapshots at the same C4 level. |
| `render_architecture_graph` | `graphPath`; optional `title`, `outputPath`, `focus`, `format` | Render a saved graph or a focused neighborhood. Use `format: "drawio"` for editable XML. |
| `render_c4_mermaid` | `title`, `c4Level`, `nodes`, `relationships`, optional `outputPath` | Mermaid source and a compact server-rendered PNG; saved SVG, PNG, HTML, and Markdown when requested. |
| `render_c4_drawio` | Authored diagram fields and an optional `outputPath` ending in `.drawio` | Editable Draw.io XML, with a file when requested. |
| `render_structurizr_dsl` | `input` with an authored diagram or workspace bundle and an optional `outputPath` ending in `.dsl` | Structurizr DSL with Context, Container, Component, or Deployment views. |
| `publish_to_ado_wiki` | `input` with `title`, optional `description`, and `diagrams`, plus `outputDir`. For publishing, add `publish: true` and `target`. | Local Azure DevOps Wiki preview with PNG attachments, and optional publication. |
| `publish_to_confluence` | The same diagram bundle and `outputDir`. For publishing, add `publish: true` and a Confluence Cloud `target`. | Local Confluence preview, storage XHTML, and PNG attachments, with optional publication. |
| `publish_to_notion` | The same diagram bundle and `outputDir`. For publishing, add `publish: true` and `target: { parentPageId }`. | Local Notion preview, page manifest, and PNGs. Publishing creates a child page with native image blocks. |

Queries default to `direction: "both"`, `maxDepth: 1`, `maxNodes: 25`, `maxEdges: 50`, and `maxBytes: 16000`. Source evidence is opt-in. Start with a summary, then search for a component or request its incoming or outgoing dependencies. Smaller views are usually easier to review than a complete repository drawing.

Render a saved graph directly:

```json
{
  "graphPath": "/absolute/path/to/project/architecture.graph.json",
  "outputPath": "/absolute/path/to/project/ARCHITECTURE.md"
}
```

For caller-supplied graphs, `render_c4_mermaid` remains available. To adapt an analysis projection manually, preserve its `nodes` and convert its `edges`:

```js
const relationships = analysis.edges.map(edge => ({
  from: edge.source,
  to: edge.target,
  label: edge.label,
  technology: edge.protocol === "unknown" ? undefined : edge.protocol,
}));
```

Source analysis produces `Context`, `Container`, and `Component` graphs. The corresponding renderer levels are `C4Context`, `C4Container`, and `C4Component`. Do not invent a protocol when the analysis has no evidence for it.

### Render authored architecture views

All seven C4 views can render explicit nodes and relationships. Use `render_c4_mermaid` with the diagram fields and an optional `outputPath`, or save the same diagram as JSON and run `npx -y c4-architect-mcp@0.2.0-alpha.16 render-diagram diagram.json --out DIAGRAM.md`. Both entry points produce Mermaid source, PNG, SVG, and interactive HTML alongside the Markdown when given an output path.

| `c4Level` | What to supply |
| --- | --- |
| `C4Code` | Code elements such as `Class`, `Interface`, `Function`, and `Type`, with relationships that describe calls, implementations, or dependencies. |
| `C4Landscape` | People and software systems across the scope, with relationships between them. |
| `C4Dynamic` | Participants as nodes and interactions in execution order in `relationships`. The renderer numbers the interactions in that order. |
| `C4Deployment` | `DeploymentNode` nodes for hosts or environments. Set `parentId` on the software instances or nested deployment nodes inside them. Relationships connect instances or deployment nodes that have no children. |

This deployment diagram places an API and its data store on the same host.

```json
{
  "title": "Orders on the application host",
  "c4Level": "C4Deployment",
  "nodes": [
    { "id": "host", "label": "Application host", "type": "DeploymentNode" },
    { "id": "api", "label": "Orders API", "type": "Container", "parentId": "host" },
    { "id": "db", "label": "Orders database", "type": "ContainerDb", "parentId": "host" }
  ],
  "relationships": [{ "from": "api", "to": "db", "label": "Reads and writes orders" }]
}
```

### Export editable Draw.io diagrams

Save the input as `physical-deployment.json` and run the export command from the same directory. [Trail Notes physical deployment JSON](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/examples/trail-notes/diagrams/physical-deployment.json)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 render-drawio physical-deployment.json --out trail-notes.drawio
```

Use **File → Open from → Device** to open the file in Draw.io. Drag a deployment group by its header to move its contents together. Double-click a group title or a relationship label to edit it. Connectors remain attached to their shapes as you move them. [Draw.io editor](https://app.diagrams.net/)

The same command also accepts a saved architecture graph. For MCP, send an authored diagram to `render_c4_drawio`, or set `format: "drawio"` on `render_architecture_graph` to export a saved graph or its focused neighborhood. Use a `.drawio` extension for the output path.

#### Trail Notes in Draw.io

Use the page tabs at the bottom of the editable file to switch views. Select any screenshot to open it full size. [Download the editable four-page Draw.io file](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.6/Trail-Notes-Four-Views.drawio)

| Context | Container |
| --- | --- |
| [![Trail Notes Context open in Draw.io](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Context-in-Drawio.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Context-in-Drawio.jpg) | [![Trail Notes Container open in Draw.io](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Container-in-Drawio.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Container-in-Drawio.jpg) |

| Component | Physical Deployment |
| --- | --- |
| [![Trail Notes Component open in Draw.io](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Component-in-Drawio.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Component-in-Drawio.jpg) | [![Trail Notes Physical Deployment open in Draw.io](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Physical-in-Drawio.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/aa01187fe81847c1155d178c561bf2af6741ba24/docs/reviews/drawio-export/Trail-Notes-Physical-in-Drawio.jpg) |

### Export a Structurizr DSL workspace

The Trail Notes workspace has four views of the same system. The Component view scopes the retry flow to the Notes API. Physical Deployment places instances of the web app, API, and database on the visitor center hardware.

Save the input as `structurizr-workspace.json` and run the export command from the same directory. [Trail Notes workspace input](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/examples/trail-notes/diagrams/structurizr-workspace.json)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 render-structurizr structurizr-workspace.json --out workspace.dsl
```

Point Structurizr Local at the output directory and use its diagram selector to switch views. Java or Docker is only needed to run the Structurizr viewer or validator. [Structurizr Local quickstart](https://docs.structurizr.com/local/quickstart)

The CLI and MCP tool accept an authored diagram or a workspace bundle with one diagram per level. A bundle uses shared node IDs, `systemId` for the software system, and `componentContainerId` for the Component view's container. Use `deploymentInstanceOf` to map deployment nodes that represent software instances to their logical IDs. The Trail Notes bundle maps `browser` to `web` and `database` to `db`.

#### Trail Notes in Structurizr

Open the editable workspace in Structurizr Local and use the diagram selector to switch views. Select any screenshot to open it at full size. [Download the editable workspace.dsl](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.7/workspace.dsl)

| Context | Container |
| --- | --- |
| [![Trail Notes Context open in Structurizr](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Context-in-Structurizr.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Context-in-Structurizr.jpg) | [![Trail Notes Container open in Structurizr](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Container-in-Structurizr.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Container-in-Structurizr.jpg) |

| Component | Physical Deployment |
| --- | --- |
| [![Trail Notes Component open in Structurizr](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Component-in-Structurizr.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Component-in-Structurizr.jpg) | [![Trail Notes Physical Deployment open in Structurizr](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Physical-Deployment-in-Structurizr.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/941ec79a12f3afd77fcf9ed093b858798ff9c688/docs/reviews/structurizr-export/Trail-Notes-Physical-Deployment-in-Structurizr.jpg) |

### Publish to Azure DevOps Wiki

Save the input as `structurizr-workspace.json` and run the command from the same directory to preview the four Trail Notes diagrams. The preview writes `index.html`, `page.md`, and the PNG attachments locally. Open `index.html` in a browser. [Trail Notes input](https://raw.githubusercontent.com/zrack/c4-architect-mcp/d38bdbc7ae49fcce37b0baee6d206f1b066a96f2/examples/trail-notes/diagrams/structurizr-workspace.json)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-ado-wiki structurizr-workspace.json --out trail-notes-wiki
```

To publish, supply an existing Azure DevOps Services wiki and a page path. Set either `AZURE_DEVOPS_BEARER_TOKEN` to a Microsoft Entra access token for Azure DevOps or `AZURE_DEVOPS_EXT_PAT` to a PAT with **Wiki (Read & write)** access in the process environment. The preview command works without credentials. [Azure DevOps authentication](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-ado-wiki structurizr-workspace.json \
  --out trail-notes-wiki --publish \
  --organization YOUR_ORG --project YOUR_PROJECT --wiki YOUR_WIKI --page /Trail-Notes
```

The MCP tool uses `target: { organization, project, wiki, pagePath }` and `publish: true` for the same operation. The publisher creates a dedicated page or updates an intact page it previously generated. Updates use Azure DevOps page versions to guard against concurrent edits. The Wiki API writes attachments separately before saving the page, so an interrupted attempt can leave uploaded PNGs behind. [Wiki page API](https://learn.microsoft.com/en-us/rest/api/azure/devops/wiki/pages/create-or-update?view=azure-devops-rest-7.1) · [Wiki attachments API](https://learn.microsoft.com/en-us/rest/api/azure/devops/wiki/attachments/create?view=azure-devops-rest-7.1)

#### Trail Notes wiki preview

The local preview shows Context, Container, Component, and Physical Deployment on one page. Select the screenshot to open it at full size. [Download the generated Markdown](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.8/page.md)

[![Full Trail Notes Azure DevOps Wiki preview showing all four diagrams](https://raw.githubusercontent.com/zrack/c4-architect-mcp/d38bdbc7ae49fcce37b0baee6d206f1b066a96f2/docs/reviews/ado-wiki-publishing/Trail-Notes-Wiki-Full-Page.jpg)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/d38bdbc7ae49fcce37b0baee6d206f1b066a96f2/docs/reviews/ado-wiki-publishing/Trail-Notes-Wiki-Full-Page.jpg)

### Publish to Confluence Cloud

Save the Trail Notes input as `structurizr-workspace.json` and run the preview command from the same directory. Open `trail-notes-confluence/index.html` and select a diagram to see its PNG at full size. The directory also contains `page.storage.xhtml`, the page body sent to Confluence, and four PNG attachments. [Trail Notes input](https://raw.githubusercontent.com/zrack/c4-architect-mcp/7891d5059309302cd746287b6de47eb747b74529/examples/trail-notes/diagrams/structurizr-workspace.json)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-confluence structurizr-workspace.json --out trail-notes-confluence
```

To publish, set `CONFLUENCE_EMAIL` and `CONFLUENCE_API_TOKEN` in the CLI or MCP server environment. The Atlassian account needs permission to create or update the page and upload attachments. Supply your Cloud site origin and numeric space ID. Add `--cloud-id` for a scoped API token with `read:page:confluence`, `write:page:confluence`, `read:attachment:confluence`, `read:content-details:confluence`, and `write:attachment:confluence`. [Atlassian API tokens](https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-confluence structurizr-workspace.json \
  --out trail-notes-confluence --publish --site https://YOUR_SITE.atlassian.net --space-id 123456
```

Use `--parent-id` to create a child page, or reuse the returned ID with `--page-id` to update a dedicated page created by C4 Architect. For MCP, call `publish_to_confluence` with `target: { site, spaceId }` and `publish: true`. The target accepts the optional fields `parentId`, `pageId`, and `cloudId`.

The publisher creates a placeholder page so Confluence can accept attachments before the page body is saved. If a publish is interrupted, check the reported page and retry with its ID. The publisher reuses matching attachments and uses the current published page version to reject a conflicting update. Use a separate page for manual editing and collaborative drafts. [Confluence pages API](https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/) · [Confluence attachments API](https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content---attachments/)

#### Trail Notes Confluence preview

The local preview shows Context, Container, Component, and Physical Deployment on one page. Select the screenshot to open it at full size. The preview command above generates the PNGs referenced by the XHTML. [Download page.storage.xhtml](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.9/page.storage.xhtml)

[![Full Trail Notes Confluence preview showing all four diagrams](https://raw.githubusercontent.com/zrack/c4-architect-mcp/7891d5059309302cd746287b6de47eb747b74529/docs/reviews/confluence-publishing/Trail-Notes-Confluence-Full-Page.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/7891d5059309302cd746287b6de47eb747b74529/docs/reviews/confluence-publishing/Trail-Notes-Confluence-Full-Page.png)

### Publish to Notion

Save the Trail Notes input as `structurizr-workspace.json` and run the preview command from the same directory. Open `trail-notes-notion/index.html` and select a diagram to see its PNG at full size. The output also contains a `page.json` manifest and the four PNGs. [Trail Notes input](https://raw.githubusercontent.com/zrack/c4-architect-mcp/b78cd30162e856f1b4ed3b5531d1850c341b88c6/examples/trail-notes/diagrams/structurizr-workspace.json)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-notion structurizr-workspace.json --out trail-notes-notion
```

To publish, share the parent page with a Notion connection that has **Insert content** access. Set `NOTION_API_TOKEN` in the CLI or MCP server environment. Supply the parent page ID as a UUID with or without hyphens. [Notion authorization and page access](https://developers.notion.com/guides/authorization/overview)

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 publish-notion structurizr-workspace.json \
  --out trail-notes-notion --publish --parent-page-id YOUR_PARENT_PAGE_ID
```

For MCP, use `publish_to_notion` with `target: { parentPageId }` and `publish: true`. Each publish creates a new child page in the workspace after all PNGs upload. The publisher uses direct uploads up to 20 MiB per PNG, subject to the workspace's own limit. If Notion cannot confirm page creation, check the parent page before retrying. [Notion file limits](https://developers.notion.com/guides/data-apis/working-with-files-and-media) · [Notion guidance for timed-out writes](https://developers.notion.com/reference/request-limits#retry-a-write-that-returns-503)

#### Trail Notes Notion preview

The local preview shows Context, Container, Component, and Physical Deployment on one page. Select the screenshot to open it at full size. The preview command above generates the PNGs referenced by the manifest. [Download page.json](https://github.com/zrack/c4-architect-mcp/releases/download/v0.2.0-alpha.10/page.json)

[![Full Trail Notes Notion preview showing all four diagrams](https://raw.githubusercontent.com/zrack/c4-architect-mcp/b78cd30162e856f1b4ed3b5531d1850c341b88c6/docs/reviews/notion-publishing/Trail-Notes-Notion-Full-Page.png)](https://raw.githubusercontent.com/zrack/c4-architect-mcp/b78cd30162e856f1b4ed3b5531d1850c341b88c6/docs/reviews/notion-publishing/Trail-Notes-Notion-Full-Page.png)

### Focus a diagram on one node

Both TakeNote diagrams use the same source snapshot. On the right, focusing on `NoteEditor.tsx` and its direct neighbors reduces the view from **108 nodes and 363 arrows** to **15 nodes and 19 arrows**. Follow `TakeNoteApp.tsx` → `NoteEditor.tsx` → `PreviewEditor.tsx` to see the difference.

![Full TakeNote diagram on the left and the focused NoteEditor diagram on the right, with two arrows called out to trace the path from TakeNoteApp to PreviewEditor](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/takenote-side-by-side.png)

[Full-size TakeNote comparison PNG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/takenote-side-by-side.png)

Use `query --search` to find the exact node ID for a focused diagram. These commands use the graph from the checkout example and show the outgoing dependencies of Order orchestration.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 query output/order-service.graph.json --search "Order orchestration" --depth 0
npx -y c4-architect-mcp@0.2.0-alpha.16 render output/order-service.graph.json --node component:orders --direction outgoing --out output/ORDER-SERVICE.outgoing.md
```

With `--node`, render defaults to both directions, depth 1, 25 nodes, and 50 relationships. Use `--direction incoming` or `--direction outgoing` to trace one direction. Set `--depth`, `--nodes`, and `--edges` to adjust the view. The diagram caption shows how much of the saved graph is included. The render result reports omitted nodes and relationships and whether a node or relationship limit was reached.

The focused Markdown relationship table and interactive HTML details show up to three source locations per relationship. Use the saved graph for the full evidence.

For MCP, pass `focus` to `render_architecture_graph`. Find the ID with `query_architecture_graph` using `search`.

```json
{
  "graphPath": "/absolute/path/to/project/architecture.graph.json",
  "outputPath": "/absolute/path/to/project/ARCHITECTURE.orders.md",
  "focus": {
    "nodeId": "component:orders",
    "direction": "outgoing",
    "maxDepth": 1,
    "maxNodes": 25,
    "maxEdges": 50
  }
}
```

### What depends on this file?

Use alpha.16 to see which callers to inspect before you change a TypeScript or TSX file. For Codex, install the package and link its skill on macOS or Linux.

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
mkdir -p "$HOME/.agents/skills"
ln -s "$(npm root -g)/c4-architect-mcp/.agents/skills/what-depends-on-this-file" "$HOME/.agents/skills/what-depends-on-this-file"
```

You can also copy the installed package’s `.agents/skills/what-depends-on-this-file` folder into your project's `.agents/skills/` directory. Run `npm root -g` to locate the package. Connect Codex to the alpha.16 MCP server using the [setup instructions](#get-started), then open a new chat in the project and try this prompt.

> Use `$what-depends-on-this-file` on TakeNote’s `NoteEditor.tsx` in `src`. Which files should I review first if I change the editor? Link every step back to the source.

The report starts with the files that import the editor directly. For each indirect dependent it shows a shortest path back to the editor and the source line for each hop. The default view follows up to three hops and includes up to 25 files, counting the selected file. It reports any limits or source-resolution gaps that affect the result.

In the TakeNote example, start with `TakeNoteApp.tsx`: it imports the editor and renders it beside the note list. `App.tsx` and the client entry point reach the editor indirectly. The clean source scan covered 76 TypeScript and TSX files and marked unresolved references in the report. [Editor render site](https://github.com/taniarascia/takenote/blob/e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331/src/client/containers/TakeNoteApp.tsx#L106) · [Focused diagram](examples/takenote/impact/NoteEditor.focus-7b1dcac22e33c69b.png)

To run the same analysis directly, use the CLI from the root of your project. Replace `NoteEditor.tsx` with the file you plan to change.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 impact-file ./src NoteEditor.tsx --out output/NoteEditor.md
```

To reproduce the published example with GitHub source links, run this from a clean checkout of the [pinned TakeNote revision](https://github.com/taniarascia/takenote/tree/e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331) before installing its dependencies.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 impact-file ./src client/containers/NoteEditor.tsx \
  --out output/NoteEditor.md --depth 3 --nodes 25 \
  --github-repo taniarascia/takenote --commit e0eddbb9a21ae4cf4c4c7c183f29cfd666e08331 --source-root src
```

The `analyze_file_impact` MCP tool produces the same report and diagram. Omit the GitHub revision options when scanning local edits so the source locations refer to the files you inspected. [Read the skill](.agents/skills/what-depends-on-this-file/SKILL.md) · [Read the generated NoteEditor impact report](examples/takenote/impact/NoteEditor.md) · [Regression, performance, and architect walkthrough](https://github.com/zrack/c4-architect-mcp/blob/v0.2.0-alpha.16/docs/reviews/file-impact-qa/README.md)

### Review architecture changes for a pull request

With Node.js 22 or 24 and Git installed, link the packaged skill on macOS or Linux:

```sh
npm install -g c4-architect-mcp@0.2.0-alpha.16
mkdir -p "$HOME/.agents/skills"
ln -s "$(npm root -g)/c4-architect-mcp/.agents/skills/what-changed-in-this-pr" "$HOME/.agents/skills/what-changed-in-this-pr"
```

Start a new Codex chat in your repository and try this prompt.

> Use $what-changed-in-this-pr on zrack/c4-architect-mcp#16. Show me which dependencies it added or removed and link each arrow to the import.

The skill compares committed TypeScript and TSX snapshots. Its focused diagram shows only changed relationships. Numbered arrows link to source in the interactive view and match the rows in the Markdown report. Additions point to the PR head, removals to the base. [Skill instructions](.agents/skills/what-changed-in-this-pr/SKILL.md)

PR #16 added ten dependencies when it introduced `explain-this-file`. Follow each arrow to the import that introduced it. [Read the PR #16 report](https://github.com/zrack/c4-architect-mcp/blob/fb550b7f5a7792fa0c66d0aed0cffc2aad09f89b/docs/reviews/pr-16/PR-16.md) · [View the focused diagram](https://github.com/zrack/c4-architect-mcp/blob/fb550b7f5a7792fa0c66d0aed0cffc2aad09f89b/docs/reviews/pr-16/PR-16.focus-9032b03b69eb2b17.png)

Pass `review` two saved graphs at the same C4 level and scan scope to see a changed component alongside its neighbors. For an added or changed dependency, this default view uses the head snapshot. If the only dependency changes are removals, it uses the base snapshot. The Markdown report also lists source edits and declared boundary changes. To compare boundary declarations, supply each revision's configuration to its scan.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 review base.graph.json head.graph.json --out PR-ARCHITECTURE.md
```

To reproduce the focused Actions view locally, use two Component graphs and add `--focus-changes`. For links to exact GitHub source lines, save each graph with `analyze --commit SHA`. Give `review` the same repository-relative source directory as both scans (use `.` for the repository root). For a PR from a fork, add `--head-github-repo FORK_OWNER/FORK_REPO`.

```sh
npx -y c4-architect-mcp@0.2.0-alpha.16 review base.graph.json head.graph.json \
  --focus-changes --github-repo OWNER/REPO --source-root src --out PR-ARCHITECTURE.md
```

#### Run the review in GitHub Actions

1. Open **Actions → PR architecture review → Run workflow** on the default branch and enter the PR number. Use a source directory tracked in both revisions, such as `src` (the default), or `.` for the repository root.
2. To post a comment with the dependency counts, both scan statuses, and a download link, select **Post an architecture review summary to the pull request**. It defaults to off. Re-running the same workflow run updates its comment.
3. When the run finishes, download and extract `pr-<number>-architecture-review-<attempt>`. Open `PR-ARCHITECTURE.md` for the full list of added, removed, and modified dependencies. Open the adjacent HTML diagram and select a numbered arrow to see its source link. Keep the extracted files together.

The workflow installs the published `c4-architect-mcp@0.2.0-alpha.12`, scans the base and head commits recorded by GitHub, and calls `review --focus-changes`. Additions link to the import in the head revision, removals to the import in the base revision, and modified dependencies to both. For fork PRs, head links use the fork when available. The diagram shows up to 25 dependency changes. The report and optional PR comment give totals for the full comparison. When zero dependencies change, the artifact contains just the Markdown report.

The read-only scan does not execute PR code. To resolve package imports, it stages each revision's dependencies separately using a supported public npm v3 lockfile, with integrity checks and install scripts disabled. If a lockfile is missing, uses workspaces, or cannot be staged, that revision is scanned from source alone. Check the report for partial scans and unresolved imports. It lists up to 25 unresolved locations per revision. Sign in to GitHub to download an Actions artifact while the run retains it.

##### Examples from GitHub Actions

| Pull request | What to trace in the uploaded report |
| --- | --- |
| [PR #16 report and diagram](https://github.com/zrack/c4-architect-mcp/blob/main/docs/reviews/actions-alpha12/pr-16/PR-ARCHITECTURE.md) | Ten added dependencies. Follow R06 from the CLI and R08 from the MCP server to the same new renderer. |
| [PR #14 report and diagram](https://github.com/zrack/c4-architect-mcp/blob/main/docs/reviews/actions-alpha12/pr-14/PR-ARCHITECTURE.md) | Thirteen added dependencies and three removed. Follow R16 to the preview's former renderer import at the base, then R06 to its new home in the shared wiki module at the head. |

The saved examples include the original Actions artifacts and source-link checks. [View the pilot results and both workflow runs](https://github.com/zrack/c4-architect-mcp/tree/main/docs/reviews/actions-alpha12)

##### Use the workflow in another repository

Save this caller as `.github/workflows/architecture-review.yml` on your repository's default branch. Open **Actions → Architecture review → Run workflow** in that repository. Enter the PR number and a directory tracked in both revisions, or use `.` to scan the repository root. The report and any focused diagram appear in the calling repository's run artifacts.

```yaml
name: Architecture review
on:
  workflow_dispatch:
    inputs:
      pr_number:
        description: Pull request number
        type: string
        required: true
      source_root:
        description: Repository-relative source directory
        type: string
        default: src

permissions:
  contents: read
  pull-requests: read

jobs:
  review:
    uses: zrack/c4-architect-mcp/.github/workflows/pr-architecture-review-report.yml@1ab91407555f60014d9c60e99513ba028c888eea
    with:
      pr_number: ${{ inputs.pr_number }}
      source_root: ${{ inputs.source_root }}
```

Existing callers can adopt the focused review by updating the `uses` commit to the one above. If your repository restricts reusable workflows, allow that reference in its Actions settings. To offer opt-in comments, call `pr-architecture-review.yml` at the same commit, grant the calling job `pull-requests: write`, and pass a Boolean `post_comment` input. The separate comment job posts only when requested. The scan always runs with read-only permissions.

##### Example output from PR #4

This earlier run used the alpha.3 single-component neighborhood view. Its optional comment shows how reviewers can reach the report from a pull request. [View the original comment on PR #4](https://github.com/zrack/c4-architect-mcp/pull/4#issuecomment-6716125585)

> **Component architecture review**
>
> `55419ce` → `4b39e25` · Base scan **complete** · Head scan **complete**
>
> Dependencies · **3 added**, **0 removed**, **0 changed**.
>
> [Download the Markdown report and focused diagram](https://github.com/zrack/c4-architect-mcp/actions/runs/42438222217/artifacts/13600353024)

The focused view shows the immediate neighbors of `cli.ts`. Follow **R01** to trace the new import of `renderers/review.ts`.

[Read the Markdown report](https://github.com/zrack/c4-architect-mcp/blob/main/docs/reviews/pr-4/PR-ARCHITECTURE.md) · [Open the full-size PNG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/reviews/pr-4/PR-ARCHITECTURE.focus-e758568899e88d5e.png) · [View the Actions run](https://github.com/zrack/c4-architect-mcp/actions/runs/42435820178)

![Focused Component diagram from PR #4 showing cli.ts and seven relationships, including R01 to renderers/review.ts](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/reviews/pr-4/PR-ARCHITECTURE.focus-e758568899e88d5e.png)

## Read the diagram

![Five-component order-service diagram derived from the checked-in TypeScript example](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-example.png)

*Five declared components and five source-observed dependencies from the checked-in [order-service example](https://github.com/zrack/c4-architect-mcp/blob/main/examples/README.md). The application is synthetic; the dependencies come from its actual source imports.*

[Full-size PNG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-example.png) · [Scalable SVG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-example.svg)

The server computes the image layout with ELK, compares horizontal and vertical arrangements, and reserves space for the wrapped labels it draws. PNG and SVG rendering do not require a browser at runtime. Mermaid remains a compatible source export; a client's Mermaid layout may differ from the server image.

The saved graph preserves the system/container hierarchy. Context, Container, and Component images show parent-container and inferred-boundary information in node descriptions. Authored Deployment diagrams can show nested hosts. Inspect those descriptions in the interactive view.

Saving `ARCHITECTURE.md` also writes `ARCHITECTURE.svg`, `ARCHITECTURE.png`, and `ARCHITECTURE.html` beside it. The Markdown shows the PNG, links to the interactive view, includes a relationship table, and retains the Mermaid source in a collapsed section.

<details>
<summary><strong>Explore the larger 20-node renderer example</strong></summary>

![Synthetic 20-node Component graph used to exercise compact routing and long relationship labels](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-20.png)

This separate stress fixture has 20 nodes and 35 relationships, including branching, cycles, shared dependencies, and long labels. Its connections are authored test data rather than extracted source dependencies.

[Full-size PNG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-20.png) · [Scalable SVG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/component-20.svg)

</details>

![Interactive Component diagram with Order orchestration selected and its incoming and outgoing connections highlighted](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/selection-example.png)

*The 20-node stress fixture with Order orchestration selected, saved through the interactive view's export buttons.*

[Full-size selected PNG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/selection-example.png) · [Scalable selected SVG](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/selection-example.svg)

Select a component to highlight outgoing connections in blue and incoming connections in brown. Other routes fade. Select a relationship ID to isolate that route and inspect its full label. Zoom, keyboard selection, Escape, and **Show all** help you move between details and the complete picture.

![Interactive diagram toolbar with full-size PNG and SVG export buttons](https://raw.githubusercontent.com/zrack/c4-architect-mcp/main/docs/images/export-toolbar.png)

**Export PNG** and **Export SVG** preserve the current selection and connection highlighting across the full diagram, regardless of zoom or scroll position. PNG exports at twice the diagram's natural dimensions; SVG remains scalable. The self-contained HTML works as a local file without contacting the MCP server or an external service.

Automatic layout cannot make every graph readable at every size. Crossings can remain, and a large full-graph image may need zoom. Use selection and bounded graph queries to follow a particular change or dependency.

See [image provenance and regeneration instructions](https://github.com/zrack/c4-architect-mcp/blob/main/docs/images/README.md) to reproduce these examples.

## Local execution and data

The parser reads local source files and does not call an LLM API. Generated diagrams and their interaction code are self-contained. Your MCP client receives the tool results, and its own settings determine whether those results are sent to a model or another service. Review those settings before analyzing private source.

Analysis reads the source statically and writes the requested artifacts locally. The wiki and workspace publishers also default to a local preview. With an explicit publish request and destination, they upload the generated page and diagram images. [Publishing scope and credentials](https://github.com/zrack/c4-architect-mcp/blob/main/SECURITY.md#publishing-diagrams)

## Develop and verify

From a repository checkout:

```sh
npm ci
npm test
npm run test:package
npm run test:layout
```

The regular tests cover parsing, graph contracts, graph operations, rendering, and MCP behavior. The package check exercises a packed installation. The layout check uses real browser geometry and downloads against synthetic 12-node and 20-node fixtures. It checks labels, routes, arrowheads, compactness, highlighting, keyboard controls, and selection-aware PNG/SVG exports.

The layout check uses installed Google Chrome by default. To use Playwright Chromium:

```sh
npx playwright install chromium
C4_BROWSER_CHANNEL=chromium npm run test:layout
```

For PowerShell, set `$env:C4_BROWSER_CHANNEL = "chromium"` before running the test. Browser reports and generated fixtures are written under `output/playwright/component-scale/`. These checks cover the included cases, not every possible graph topology.

The [CI workflow](https://github.com/zrack/c4-architect-mcp/blob/main/.github/workflows/ci.yml) configures tests on Node.js 22 and 24 across Linux, macOS, and Windows, plus a Chromium layout job. See the [GitHub Actions runs](https://github.com/zrack/c4-architect-mcp/actions) for results.

## Build this with us

Useful contributions start with a concrete case: an import that resolves incorrectly, a boundary that is hard to express, or a diagram whose route is difficult to follow. Small, sanitized fixtures are especially valuable.

- **Report a bug:** include a minimal input, expected result, diagnostics, and a screenshot for rendering problems.
- **Improve analysis:** add source evidence and a regression fixture; keep observed facts separate from inference.
- **Improve diagrams:** test the actual SVG and exported images, including selected views.
- **Design an extension:** discuss its graph contract before adding a new language, renderer, or publisher.
- **Improve documentation:** try the setup on your platform and client, and report the exact versions used.

Read [CONTRIBUTING.md](https://github.com/zrack/c4-architect-mcp/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/zrack/c4-architect-mcp/blob/main/CODE_OF_CONDUCT.md), and the [roadmap](https://github.com/zrack/c4-architect-mcp/blob/main/ROADMAP.md). Public API details may change during the alpha; preserve a copy of important graph snapshots and boundary configurations.

## License

C4 Architect is available under the [MIT License](https://github.com/zrack/c4-architect-mcp/blob/main/LICENSE). You may use, modify, and redistribute it, including commercially, subject to the license terms. Dependency licenses and attribution requirements remain applicable; see [NOTICE](https://github.com/zrack/c4-architect-mcp/blob/main/NOTICE) and [third-party notices](https://github.com/zrack/c4-architect-mcp/blob/main/THIRD_PARTY_NOTICES.md).

TDQS

B3.4/5.0

Scored across 6 tools

Disambiguation3/5

Four tools (analyze, get_summary, query, compare) have clearly distinct verbs on the same graph resource, which is fine. However, render_architecture_graph and render_c4_mermaid both produce a compact C4 image plus Mermaid source plus optional Markdown/SVG/PNG/HTML files, making their boundaries nearly indistinguishable and forcing the agent to guess which to call.

Naming Consistency4/5

All six tools follow a consistent snake_case verb_noun pattern (analyze_*, get_*, render_*, query_*, compare_*). Minor deviation: two of them use 'architecture' as the noun while render_c4_mermaid uses the 'c4_mermaid' domain phrasing, which also breaks the resource-naming symmetry.

Tool Count5/5

Six tools is well-scoped for an architecture-analysis pipeline: analysis, summary, query, compare, and rendering. Every tool maps to a real stage in the workflow, with only the duplicate renderer arguably removable.

Completeness4/5

The lifecycle is well covered: parse dependencies, persist a graph, read a summary, explore a bounded neighborhood, diff two graphs, and render. Minor gap: no tool to list, delete, or explicitly re-validate/refresh saved graphs, so agents lack discovery and cleanup operations.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues