For agents
Plotwork for AI agents
How an AI agent finds, reads, and uses Plotwork: the files it can read without connecting, the ways to call the tools, and the loop that gets a valid diagram.
For
- Claude Code
- Cursor
- VS Code
- Claude Desktop
- Codex
- GitHub Copilot
- Gemini CLI
- ChatGPT
TL;DR
| Question | Answer |
|---|---|
| What is Plotwork? | A small text language and renderer for twenty-nine kinds of diagram, from flow, sequence, and database to Gantt, state, mind map, and treemap, written by AI agents and drawn the same way everywhere: in a README, in your editor, and over MCP. |
| How does an agent call it? | Over MCP, locally or hosted, or over HTTP. Every way runs the same 20 tools, which the tool reference lists. |
| Which clients work? | Any MCP client. The connecting guide has the settings for Claude Code, Cursor, VS Code, and Claude Desktop, and the rules file says where Codex, GitHub Copilot, and Gemini CLI read their instructions. ChatGPT, Claude, and VS Code show a drawing inline. |
| What does it cost to start? | The local MCP server needs no key and no account. The hosted MCP server and the HTTP API need an API key, and the hosted MCP server also accepts a browser sign-in. |
| Where do I read the docs without a browser? | https://docs.plotwork.dev/llms.txt indexes every page. Add .md to the address of any page to get it as Markdown. |
| Which tool do I call first? | get_diagram_syntax once to read the language, then draw_diagram with the source. For a common architecture, call find_pattern first. |
| What if the source is wrong? | draw_diagram returns every error with its line, column, and hint, and draws nothing until the source is valid. Fix them all and call again. |
What the server tells your agent
The MCP server sends this guidance to a client when it connects. It is listed here for an agent that reads the docs before it has a connection. The rules file holds the same text ready to paste into a project.
- Draws flow, sequence, database schema, git graph, Gantt chart, class diagram, state, timeline, user journey, mind map, treemap, share chart, quadrant chart, layered architecture, C4 diagram, matrix, Sankey diagram, XY chart, tree, swimlane, requirement diagram, block diagram, packet diagram, kanban board, radar chart, use case diagram, Venn diagram, fishbone diagram, and Wardley map diagrams from a small line-oriented text language.
- Prefer the workflow tools: each does the work of several single tools in one call.
- When you are unsure which kind of diagram fits, call
suggest_diagramwith the request in plain words and any data: it ranks the kinds and gives a starter that parses; for a whole document,plan_document_diagramsreturns the sections a picture would help, each with a starter. - When the diagram should come from a file the person has (SQL, Prisma, or Drizzle models, an OpenAPI document, a GraphQL or Protocol Buffers schema, Terraform, Bicep, ARM, Pulumi, CloudFormation, the CDK, or a serverless.yml, docker-compose, a Dockerfile, Kubernetes manifests, Helm, Kustomize, nginx configuration, a Backstage catalog, a Structurizr workspace, AsyncAPI documents, a GitHub Actions workflow, a GitLab CI/CD or Azure Pipelines pipeline, a dbt project, the package manifests of a JavaScript workspace, a draw.io diagram, CSV or JSON data, a folder listing, or a git log), call
import_sourcewith its text and format: it builds the whole diagram from the file in one call, and its diagnostics say what was left outget_diagram_syntaxwith topic import-formats says what each format reads. - For a request to draw a common architecture, such as a three-tier network, a serverless API, a container platform, or a queue with workers, call
find_patternfirst with the request in plain words; when a pattern fits, calldraw_from_patternwith its id, a provider flavour (neutral, aws, azure, or gcp), and slot values that rename its parts, orget_patternto read and edit its source, and when nothing fits, write the diagram from scratch withdraw_diagram. - To make an organisation's approved pattern (a diagram with fixed parts every team draws the same and {{slot}} markers for what each team fills in), write a pattern file:
get_patternwith file true gives one to start from, and https://docs.plotwork.dev/schemas/plotwork.pattern.json (opens in a new tab) describes every field. - Check it with
check_pattern, fix every problem it names, and send each source it returns todraw_diagram; then save it as.pattern.json for the Patterns tab to import. - Call
get_diagram_syntaxonce with no kind to read the shared language, and again with kind set to the kind you draw for its statements, limits, and example. - Write the source and call
draw_diagram: it returns every error with line, column, and hint and draws nothing until the source is valid, so fix every error and call again; once valid it returns the warnings, an outline to check the meaning, and the SVG for light and dark. - You cannot look at an SVG, so the answer carries no SVG text unless you pass svg "always": it gives viewUrl for the person, saveCommand to write the files, and the pictures go to the diagram viewer.
- Every check ran on the drawing all the same.
- Pass svg "never" to check a diagram most cheaply, and svg "always" only when you need the SVG text in the answer.
- To change a diagram that already exists as a Plotwork SVG, a hosted link such as https://cdn.plotwork.dev/d/ (opens in a new tab)<22 characters>.svg or an .svg file in the repository, call
read_diagramfirst with its url or its text, change the source it returns withedit_diagram(rename, set an option, add, remove, or move a statement) or by hand anddraw_diagram, then write the SVG file again;compare_diagramssays what changed, for a review. - Set embedSource true on
draw_diagramwhenever you save an SVG into a repository, so the file carries its source andread_diagramcan give it back next time; the source is then readable by anyone who has the file. - To save a valid diagram into the person's repository, run the saveCommand a drawing tool returns in a shell, changing --out to the path you want (add --scheme dark for the dark picture): the Plotwork command line reads the diagram from the link on that machine, fetches nothing, and writes the SVG with its source embedded, so you never copy the SVG yourself.
- With no shell, draw with svg "always" and embedSource true and write the returned svg.
- Give viewUrl to a person to look at the diagram, and svgUrl or pngUrl to download it in their browser; neither is a file address for curl.
- When the person wants a diagram in their own web page or React app, interactive and optionally live, call
embed_diagramwith its hosted link or SVG text (format react for React, live for a /l/ or /o/ link, pin for exactly that picture) and paste the snippet it returns instead of writing an img tag. - An item with no icon= gets the icon its label names when the engine is sure, so name each item for what it is and leave icon= out: a product draws its mark ("Postgres", "Kafka", "Databricks"), a cloud product its provider's icon ("Amazon S3"), and a common part or role its plain icon ("Load balancer", "Circuit breaker", "Data lake", "Read replica", "Customers", "CI/CD"), within the node type you chose; icon=none keeps one item plain and icons=off on the header keeps them all plain.
- For a finished look, label flow arrows with verbs ("reads", "publishes", "replicates", "pushes image", "deploys to") so they draw icons, and an arrow into or out of a queue labelled with a message name draws send or receive; add role= (data, async, identity, private) to the lines that carry those, and give groups a type=; style in
get_diagram_syntaxsays more, and its topic icon-words lists every word that draws an icon. - Use
map_iconsto choose icons for many names at once: it answers with the icon a label of that name draws, so its answer and the picture agree; it never guesses, so choose from the candidates for an ambiguous name, and never invent an icon. - To move Mermaid to Plotwork, call
convert_mermaidwith one diagram, read every diagnostic and its hint, then choose node types and icons; for a whole Markdown file callsync_markdownwith the document, its path, and convertMermaid true, write the returned markdown and files, then review the diff. - When the repository has a plotwork.config.json (or .plotwork/config.json) at its root, read it and pass it as settings to every tool that takes settings: its defaults fill the header options the source leaves out, and broken style rules come back as warnings to fix.
- Use
validate_diagram,outline_diagram,render_diagram, andsearch_iconsonly for one fine-grained step. - Choose node types and tones for meaning; colors come from the colour theme, theme=
on the header (plotwork, slate, ocean, forest, sunset, mono, contrast), and cannot be set one by one. - You cannot see the picture, so read quality in the answer: its measures (crossings, aspectRatio, emptySpace, smallestTextPx) and its hints, each naming the option to change, such as direction=down or spacing=compact.
- On a flow header spacing=compact packs the boxes for a dense page and spacing=roomy spreads them for a slide.
The tools
11 workflows do a whole job in one call, and 9 single tools do one step. Prefer a workflow.
| Tool | Kind | What it does | A request that leads to it |
|---|---|---|---|
draw_diagram | Workflow | Checks, describes, and draws a diagram. | Draw a diagram of how a user signs in through an API that checks a database. |
edit_diagram | Workflow | Changes diagram source with typed operations, on every kind, and checks the result. | Rename the Auth API node to gateway and add a session cache it writes to. |
convert_mermaid | Workflow | Converts one Mermaid diagram (flowchart or graph, sequenceDiagram, erDiagram, gitGraph, gantt, classDiagram, stateDiagram, timeline, journey, mindmap, treemap-beta or treemap, pie, quadrantChart, C4Context or C4Container or C4Component or C4Dynamic or C4Deployment, sankey-beta or sankey, xychart-beta or xychart, treeView-beta or treeView, requirementDiagram, block-beta or block, packet or packet-beta, kanban, radar-beta or radar, usecase-beta or usecase, venn-beta or venn, ishikawa-beta or ishikawa, wardley-beta, architecture-beta, zenuml) to Plotwork source. | Convert this Mermaid flowchart to Plotwork. |
import_source | Workflow | Turns a file into a finished diagram in one call. | Draw our database schema from this SQL. |
map_icons | Workflow | Finds an icon for each of up to 40 service or product names in one call, such as the services of an architecture. | Which icons should I use for S3, Lambda, Postgres and a queue on AWS? |
sync_markdown | Workflow | Turns the diagram fences of a Markdown document into pictures, as data. | Replace the Mermaid diagrams in README.md with Plotwork diagrams. |
suggest_diagram | Workflow | Picks the kind of diagram for a request in plain words, such as "permission matrix for these endpoints and roles" or "where our cloud spend goes", with optional pasted data (a table, a list, numbers by period). | Which diagram should I use to show who can call which endpoint? |
plan_document_diagrams | Workflow | Reads a whole document (Markdown, HTML, or plain text pasted from Confluence, Notion, or Google Docs), splits it by its headings, and returns the sections a picture would help. | Which parts of this design doc need a diagram? |
find_pattern | Workflow | Finds a ready-made, checked architecture diagram for a request such as "three tier network", "serverless api", or "two availability zones". | Draw a three-tier network with load balancers. |
get_pattern | Workflow | Returns one pattern filled for a flavour. | Show me the three-tier network pattern for Azure and rename the office network to Branch office. |
draw_from_pattern | Workflow | Fills a pattern and draws it in one call. | Draw a two-zone network on AWS with a replicated database. |
read_diagram | Single tool | Read the source of an existing Plotwork SVG so you can edit the diagram. | One step of a larger job. |
compare_diagrams | Single tool | Compare two versions of a diagram by meaning, for a pull request review. | One step of a larger job. |
check_pattern | Single tool | Check a pattern file before you publish it to an organisation or save it to import. | One step of a larger job. |
get_diagram_syntax | Single tool | Read the diagram language as data. | One step of a larger job. |
validate_diagram | Single tool | Check diagram source without drawing it: every error in one pass, each with line, column, and a fix hint, plus quality warnings. | One step of a larger job. |
render_diagram | Single tool | Render valid source to a self-contained, accessible SVG in the light, dark, or auto scheme and an optional colour theme, with its pixel size and quality warnings. | One step of a larger job. |
outline_diagram | Single tool | Describe valid diagram source as plain text. | One step of a larger job. |
search_icons | Single tool | Find bundled icon names by keyword, idea, product, or abbreviation ("postgres", "token exchange", "s3", "cosmos db"). | One step of a larger job. |
embed_diagram | Single tool | Write a snippet that shows a Plotwork picture in a web page or a React app with the viewer @plotwork.official/viewer (pan, zoom, trace). | One step of a larger job. |
Ways to call them
| Way | Address | What it needs |
|---|---|---|
| Local MCP server | npx -y @buun_group/plotwork-mcp@0.12.0 | Node 22 or later. No key, no account, and no network unless you opt in to usage sharing. |
| Hosted MCP server, with a key | https://mcp.plotwork.dev/mcp | An API key in the X-API-Key header or as a bearer value. |
| Hosted MCP server, with a sign-in | https://mcp.plotwork.dev/mcp-oauth | A Plotwork account. The client opens a browser and you approve the connection. |
| HTTP API | https://api.plotwork.dev/v1 | An API key, sent the same way. Each tool has a route, listed in the rules file. |
The connecting guide has the exact setting for each client.
See also
| Doc | Why |
|---|---|
| llms.txt and Markdown pages | Every file an agent can read without a browser, and when to fetch each |
| Rules file for your agent | The guidance above, ready to paste into CLAUDE.md or AGENTS.md |
| Prompts and recipes | Requests that work and the tools an agent calls for each |
| Connecting an agent | Setting up Claude Code, Cursor, VS Code, and other clients |
| Language reference | Every word the diagram language accepts |