Skip to main content
Glama
README.md
# ArchiPilot

**An MCP server that turns an AI agent's description into a validated, animated, interactive diagram, delivered as one self-contained HTML file.**

Ask your agent to "draw the architecture of this repo" or "show the login flow as a sequence diagram". ArchiPilot checks the diagram, lays it out, and writes a single page you can open, explore, present and share. It makes no network requests.

![An ArchiPilot architecture diagram in dark theme](docs/images/overview-dark.png)

## Features

- **10 diagram types:** architecture, workflow, sequence, data flow, lifecycle, ERD, class, tree, timeline and waterfall.
- **One-page explainers:** the answer first, then reasons, steps, tables, option comparisons and embedded diagrams.
- **Guided tour:** press **Tour** and the camera travels through the flow one connection at a time. At each step it lights up both ends, runs a comet along the link and shows a caption: *from → to · label*.
- **Live motion:** press **Live** and a comet runs along every connection in step order, ripples into its target and makes it glow. Pages open still, and animation is never included in exports or print.
- **Built to explore:** hover over any item to see its details and its upstream and downstream connections. Click a neighbor to jump to it. Zoom and pan large diagrams.
- **Validated output:** strict checks that report each problem with an exact JSON path, and identical output for identical input. Each page embeds its source and a hash, so tampering is detected.
- **Light and dark themes**, full keyboard support, screen-reader labels, and respect for your system's reduced-motion setting.
- **Export** any diagram as SVG or PNG.

| Guided tour | Sequence diagram, light theme |
|---|---|
| ![The tour player framing one connection](docs/images/tour-dark.png) | ![A sequence diagram with live motion](docs/images/sequence-light.png) |

## Install

You need **Node.js 18 or newer** and Git. ArchiPilot runs from a clone; it is not published to npm.

1. Clone the repository and install its one dependency:

   ```bash
   git clone https://github.com/VinodhDeva/archipilot.git
   ```

   ```bash
   cd archipilot && npm install
   ```

2. Register the server. In **Claude Code**, run this from inside the clone to make ArchiPilot available in every project:

   ```bash
   claude mcp add --scope user archipilot -- node "$(pwd)/server.mjs"
   ```

   For **other MCP clients** (Claude Desktop, Cursor, Windsurf, VS Code and others), add this to the client's MCP configuration, with the absolute path to your clone:

   ```json
   {
     "mcpServers": {
       "archipilot": {
         "command": "node",
         "args": ["/absolute/path/to/archipilot/server.mjs"]
       }
     }
   }
   ```

3. Restart the client and check that the five `diagram_*` tools appear.

## Usage

Ask your agent for a diagram in plain words, for example:

- "Draw the architecture of this repo."
- "Show the checkout request as a sequence diagram."
- "Map the order states and their transitions."
- "Explain whether we should move to a managed queue, as a one-page explainer."

The agent picks a type, writes the diagram as JSON and calls `diagram_finalize`. The result is saved in your project under `.diagrams/<type>-<slug>-<timestamp>/`:

| File | Contents |
|---|---|
| `<slug>.html` | The diagram. Open it in any browser. |
| `candidate.json` | The diagram source the agent wrote. |
| `<slug>.receipt.json` | Which checks passed, with any diagnostics and the file's hash. |

## Viewer controls

| Control | Key | What it does |
|---|---|---|
| **Tour** | <kbd>T</kbd> | Starts the guided walk through the flow. In the tour: <kbd>←</kbd> / <kbd>→</kbd> step, <kbd>Space</kbd> pauses or resumes, <kbd>Esc</kbd> ends and returns the view to where you started. |
| **Live / Still** | <kbd>L</kbd> | Plays or stops the flow animation. Choosing Live is remembered. |
| **◐** | | Switches between light and dark themes. |
| **SVG / PNG** | | Downloads the diagram without any animation or selection. |
| Hover or <kbd>Tab</kbd> to an item | | Shows its details, upstream connections (amber) and downstream connections (green). |
| Click an item | <kbd>Enter</kbd> | Pins the details panel. Click a listed neighbor to jump to it. <kbd>Esc</kbd> closes it. |
| **− / + / Fit / 100%** | <kbd>Ctrl</kbd>/<kbd>⌘</kbd> + scroll | Zooms. Drag the background to pan. |

## Tools

| Tool | What it does |
|---|---|
| `diagram_guide` | Recommends a diagram type for a question or scenario. |
| `diagram_authoring_context` | Returns the authoring tips, JSON schema and a worked example for one type. |
| `diagram_finalize` | Validates, renders and checks a diagram, then writes the HTML file and its receipt. This is the main tool. |
| `diagram_validate` | Validates a diagram without writing anything. |
| `diagram_check` | Checks an existing HTML file for tampering or corruption. |

## Diagram types

| Type | Use it for |
|---|---|
| `architecture` | Components, services, data stores and the boundaries around them. |
| `workflow` | Processes with steps, decisions, approvals and outcomes. |
| `sequence` | Calls and replies between participants, in time order. |
| `dataflow` | Where data comes from, how it is transformed, and who consumes it. |
| `lifecycle` | States and the transitions between them. |
| `erd` | Database tables, their columns and keys, and relationships with cardinality. |
| `class` | Classes and interfaces, their members, and how they relate. |
| `tree` | Single-parent hierarchies: folders, org charts, capability breakdowns. |
| `timeline` | Timestamped events on lanes, such as an incident review. |
| `waterfall` | Nested spans on a time axis, such as a request trace. |
| `explainer` | A one-page answer that can embed any of the types above. |

Every field of every type is documented in the [schema reference](docs/schema-reference.md). The [examples](examples/) folder has one worked diagram per type.

## Configuration

| Variable | Default | Meaning |
|---|---|---|
| `DIAGRAM_WORKDIR` | The server's working directory | The folder where `.diagrams/` is created and relative paths are resolved. |

## Documentation

- [Guide](docs/guide.md): how it works, choosing a type, every tool and diagnostic code, output files, checks, troubleshooting and development.
- [Schema reference](docs/schema-reference.md): every field of every type, generated from [`schemas/`](schemas/).

## Development

```bash
npm install
```

```bash
npm test
```

The tests render every example through the real MCP server and check each output. See [Development](docs/guide.md#development) for the code layout.

## License

MIT. See [LICENSE](LICENSE). Third-party notices are in [NOTICE](NOTICE). Graph layout uses [dagre](https://github.com/dagrejs/dagre), under the MIT license.