Docs / For AI agents

open-diagram MCP tools: names, arguments and results

This page is for AI agents connected to the open-diagram MCP server, and for the people who set them up. It gives the five tools, each argument with its type and default, what each tool returns, and which tool writes files. The facts come from src/open_diagram/mcp_server.py in version 0.6.2.

Updated

Which tools does the server have?

Five tools. Only draw writes files.

ToolArgumentsWrites files
format_guidenoneNo
templatename: str = ""No
checksource: str, format: str = "auto"No
describesource: str, format: str = "auto"No
drawsource: str, format: str = "auto", name: str = "diagram", picture: bool = TrueYes: NAME.svg and NAME.png

Each tool carries hints: labels the server sends to the app about what the tool does. format_guide, template, check and describe have readOnlyHint: true and openWorldHint: false: they change nothing and reach no outside service. draw has readOnlyHint: false, destructiveHint: false and openWorldHint: false.

When an app connects, the server sends it these instructions:

open-diagram draws architecture diagrams that check their own layout.
Workflow: call format_guide once; write the diagram as JSON (or Mermaid), or start from a template (call template
with no name to list them); call check and fix every problem it names until it reports 0; then call draw, look at the
picture, and compare its description with what the user asked for.

What does format_guide return?

It returns the format guide as text: a JSON example to copy, every key, Mermaid support, and how to fix each kind of layout problem. The text ends with Icons available: and the icon names, such as aws/s3. The full text is on Format guide.

It takes no arguments.

{}

What does template return?

With no name, it returns the list of templates. With a name, it returns that template as JSON text, to start from.

  • name (string, default ""): the template's name.
{}
Templates (call template with a name to get one as JSON):
- aws_etl: Data ingestion on AWS in six numbered sections, from orchestration to dashboards
- aws_architecture: An AWS account, network and subnets around an API, a function, a database and storage
- azure_web_app: A web app on Azure behind Front Door, with its database and cache inside a virtual network
- gcp_event_pipeline: An event pipeline on Google Cloud from Pub/Sub to a warehouse and a forecast model
{"name": "azure_web_app"}

An unknown name, such as nope, fails with no template named 'nope'; templates: aws_etl, aws_architecture, azure_web_app, gcp_event_pipeline.

What does check return?

It returns the number of layout problems and one line for each. It builds the diagram in memory and writes no files.

  • source (string, required): the diagram as JSON or Mermaid text, up to 200,000 characters.
  • format (string, default "auto"): "json", "mermaid" or "auto". With "auto", text that starts with { is read as JSON. Any other text is read as Mermaid.

A JSON diagram goes in as text, with its quotes escaped:

{"source": "{\"title\": \"Order flow\", \"columns\": [[{\"id\": \"web\", \"title\": \"Website\", \"tiles\": [\"Checkout\"]}], [{\"id\": \"orders\", \"title\": \"Order service\", \"tiles\": [\"Orders\"]}]], \"links\": [{\"from\": \"web\", \"to\": \"orders\"}]}"}
0 layout problem(s)

A Mermaid flowchart goes in the same way:

{"source": "flowchart LR\n  A[Web app] --> B[Search API]", "format": "mermaid"}

When there are problems, the last line asks for a fix:

1 layout problem(s)
- line 'web' -> 'ops' crosses 'orders'; route it with via_x/via_y, move a block, or pass cross_ok=True
Fix every problem above and run check again.

What does describe return?

It returns what the diagram says in plain words: the title, the key, each block with its tiles and states, the groups, and every line with its label. It takes the same source and format as check, and writes no files.

{"source": "flowchart LR\n  A[Web app] -->|query| B[Search API]\n  B -.-> C[Search index]"}
Flowchart
States shown: Live. Solid lines: data flows today. Dotted lines: connection to build.

Blocks, left to right:
- Web app
- Search API
- Search index
Lines:
- Web app -> Search API, labeled "query"
- Search API -> Search index (connection to build)

What does draw write and return?

It writes NAME.svg and NAME.png into the output folder. It returns the layout problems, the file paths, the size, the description, and the picture.

  • source (string, required) and format (string, default "auto"): as for check.
  • name (string, default "diagram"): the file name, without an extension.
  • picture (boolean, default true): if true and the PNG was written, the result also carries the PNG as an image.
{"source": "flowchart LR\n  A[Web app] -->|query| B[Search API]\n  B -.-> C[Search index]", "name": "search-flow"}

The text part of the result, with the output folder /Users/you/Documents/open-diagram:

0 layout problem(s)

Files:
- /Users/you/Documents/open-diagram/search-flow.svg
- /Users/you/Documents/open-diagram/search-flow.png
Size: 640 x 218 px; smallest text 10.5 px

What the picture says:

After What the picture says: comes the same text that describe returns for this source.

Rules for the files:

  • draw writes the files even when the layout has problems.
  • A file with the same name is replaced.
  • In name, each run of characters other than A to Z, a to z, 0 to 9, _ and - becomes one -. Dashes at the ends are removed, and the name is cut to 80 characters. "../order flow" becomes order-flow, so no file lands outside the output folder.
  • If the PNG cannot be made, the result says PNG skipped:, then the reason, then The SVG is written. PNG files need Chrome, Chromium or Edge.

Where does the server write files, and where does it read icons?

It writes to the folder given with --out when the app starts it. Without --out, it uses the OPEN_DIAGRAM_OUT environment variable. Without either, it uses an open-diagram folder in the folder where the app starts the server. If that folder is the top of the disk or cannot be written, it uses open-diagram in the home folder.

open-diagram mcp [--out FOLDER] [--icons FOLDER]

Icons come from the built-in icons and from each --icons folder. Without --icons, the server reads the OPEN_DIAGRAM_ICONS environment variable: folders separated by the system's path separator. It never reads an icon from a path written in the diagram text.

open-diagram-mcp is the same command under its older name.

What happens when the source has a mistake?

The tool fails with a message that names the place of the mistake. Fix that spot and call the tool again. These messages came from the code:

MistakeMessage
Text that is not JSONnot valid JSON: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
An unknown keycolumns[0][0].tiles[1]: unknown key(s) 'colour'; allowed: icon, label, status, sub
No titlediagram: missing required key 'title'
Text that is not a flowchartline 1: expected 'flowchart LR' or 'graph TD' first, got 'hello'
A wrong formatformat must be 'json', 'mermaid' or 'auto'
Text over the limitthe diagram text is N characters; the limit is 200000

See also