# open-diagram for AI agents

This page is for AI coding agents, such as Claude Code, Cursor and Amp, and for the people who set them up. It lists each way an agent can use open-diagram, with the exact command. open-diagram draws architecture diagrams as SVG and PNG files from JSON, Mermaid or Python, and names each layout problem in plain words.

## How does an agent connect to the MCP server?

Add the server to the app's MCP settings, with one of the setups below. An MCP server is a small program that an AI app starts on your computer, so the AI can draw diagrams as one of its own actions. open-diagram's MCP server accepts JSON and Mermaid only, never Python, and writes files only inside one output folder.

Claude Code:

```bash
claude mcp add open-diagram -- uvx open-diagram mcp
```

Amp:

```bash
amp mcp add open-diagram -- uvx open-diagram mcp
```

In Amp, a server added to one folder's settings (`amp mcp add --workspace`) also needs `amp mcp approve open-diagram`.

Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "open-diagram": {
      "command": "uvx",
      "args": ["open-diagram", "mcp", "--out", "/Users/you/Documents/open-diagram"]
    }
  }
}
```

Replace `/Users/you/Documents/open-diagram` with the folder for the SVG and PNG files.

`uvx` is part of [uv](https://docs.astral.sh/uv/). The first time, it fetches open-diagram and Python 3.10 or later. uv keeps a copy of what it downloaded. To pick up a new release, add `--refresh` once after `uvx`.

Without uv, run `pip install open-diagram`. Then use `open-diagram` as the command and `mcp` as its first argument.

The server has five tools: `format_guide`, `template`, `check`, `describe` and `draw`. [MCP tools](https://open-diagram.dev/for-agents/mcp-tools.md) gives each tool's arguments and what it returns.

## How does an agent load the agent skill?

Install it with the [skills](https://skills.sh) tool. An agent skill is a folder of instructions that an agent loads when it needs them. open-diagram's skill is [`skills/open-diagram/SKILL.md`](https://github.com/lukendeasy/open-diagram/blob/main/skills/open-diagram/SKILL.md).

```bash
npx skills add lukendeasy/open-diagram --skill open-diagram --agent claude-code
```

This writes the skill to `.claude/skills/` in the current folder. Add `-g` to install it for all your projects. For another app, name that app after `--agent`.

In a copy of the open-diagram repo, you can copy the folder instead:

```bash
cp -r skills/open-diagram ~/.claude/skills/
```

## How does an agent use the command line?

Run `open-diagram` with one of these commands. Each one takes a JSON file (`.json`), a Mermaid flowchart (`.mmd` or `.mermaid`), or a Python script (`.py`) with a `build()` function that returns a `Diagram`.

```bash
open-diagram check plan.json      # lists the layout problems; writes no files
open-diagram describe plan.json   # prints what the picture says, in plain words
open-diagram draw plan.json       # writes plan.svg and plan.png next to plan.json
open-diagram new                  # lists the templates
open-diagram new azure_web_app    # writes azure_web_app.json to start from
```

`check` and `draw` exit with status 1 when the layout has problems. Status 2 means the file could not be read. The message after `error:` names the place, such as `columns[0][0].tiles[0]`.

PNG files need Chrome, Chromium or Edge. If the browser is not found, set `CHROME` to its path. The SVG is always written.

[Command line](https://open-diagram.dev/docs/cli.html) lists every option.

## How does an agent use the Python library?

Install it with pip, then write a script whose `build()` function returns a `Diagram`.

```bash
pip install open-diagram
python3 -c "import open_diagram; print(open_diagram.__version__)"
```

open-diagram needs Python 3.10 or later. Check a script with `open-diagram check script.py`. [Python](https://open-diagram.dev/docs/python.html) lists every block and placing method.

## Where are the docs as plain text?

They are in two text files and in the Markdown copy of each page.

- [llms.txt](https://open-diagram.dev/llms.txt) lists the pages, with one line for each.
- [llms-full.txt](https://open-diagram.dev/llms-full.txt) has the Docs pages and the pages in these sections as Markdown, one after another: Diagram examples, Compared, Layout problems, Guides, Prompts and For AI agents.
- Each Docs page, and each page in those six sections, has a Markdown copy at the same address, with `.md` in place of `.html`. This page's copy is [https://open-diagram.dev/for-agents.md](https://open-diagram.dev/for-agents.md).

## What are the steps for one diagram?

Write, check, fix, describe, then draw. The steps come from the agent skill. Each step names the command, then the MCP tool.

1. If you use the MCP server, call `format_guide` once.
2. Write the diagram as JSON, Mermaid or Python.
3. Run `open-diagram check plan.json`, or call `check`.
4. Fix every problem the check names.
5. Run the check again. Repeat until it reports `0 layout problem(s)`.
6. Run `open-diagram describe plan.json`, or call `describe`.
7. Compare the description with the request. Every system, state, owner and line the user named must be there, and nothing they did not name.
8. Run `open-diagram draw plan.json`, or call `draw`.
9. Look at the PNG.
10. Tell the user where the SVG and PNG are, and which facts in the picture are your assumptions.

A check that finds a problem prints one line for it:

```text
plan.json: 1 layout problem(s)
  - line 'web' -> 'ops' crosses 'orders'; route it with via_x/via_y, move a block, or pass cross_ok=True
```

After `"lane": "top"` was added to that link, which routes it above the picture, the check printed `plan.json: 0 layout problem(s)`. [Layout problem messages](https://open-diagram.dev/for-agents/layout-problem-messages.md) gives the fix for each message.

## Which version does this page describe?

Version 0.6.2, from the library's `pyproject.toml`. To upgrade an install made with pip, run `pip install -U open-diagram`.

Check PyPI for the latest version: [https://pypi.org/project/open-diagram/](https://pypi.org/project/open-diagram/)

Updated November 25, 2026. Web page: https://open-diagram.dev/for-agents.html

See also:

- [open-diagram MCP tools: names, arguments and results](https://open-diagram.dev/for-agents/mcp-tools.md)
- [An AGENTS.md block for drawing diagrams with open-diagram](https://open-diagram.dev/for-agents/agents-md-block.md)
- [Draw architecture diagrams with Claude Code and an MCP server](https://open-diagram.dev/guides/draw-diagrams-with-claude-code.md)
- [Set up a diagram MCP server in Cursor, Claude Desktop and Amp](https://open-diagram.dev/guides/mcp-server-in-cursor-claude-desktop-and-amp.md)

Pages:

- [open-diagram MCP tools: names, arguments and results](https://open-diagram.dev/for-agents/mcp-tools.md): The five tools of the open-diagram MCP server, with each argument, its type and default, what each tool returns, and which one writes files.
- [The open-diagram format guide, as the MCP server returns it](https://open-diagram.dev/for-agents/format-guide.md): The format guide that the open-diagram MCP server's format_guide tool returns: a JSON example, every key, Mermaid rules and fixes.
- [open-diagram layout problem messages and their fixes](https://open-diagram.dev/for-agents/layout-problem-messages.md): Every layout problem message open-diagram reports, in the exact words of the code, with what it means and how to fix it.
- [An AGENTS.md block for drawing diagrams with open-diagram](https://open-diagram.dev/for-agents/agents-md-block.md): A block to paste into your project's AGENTS.md or CLAUDE.md, so a coding agent draws diagrams with open-diagram and fixes each layout problem.
