AI Agents Guide

Connect Claude Code to a diagram tool: the command, the flag, the first prompt

By the engineer who builds Datadef, from client work on data platforms · Reviewed August 21, 2026

Claude Code has already read your repository by the time you ask it for a diagram. What it lacks is a surface to draw on, which is what an MCP diagram server provides. The setup is one command, with one flag that silently decides whether anything works, and one first prompt that decides whether the output is presentable.

6 min readFor Claude Code users who want diagrams out of the session, not Mermaid in it

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

141/20003 credits left
Try:

No account needed · Editable canvas, not a picture

The command, and the flag that matters

Create an API key from the MCP and integrations page in settings, copy it once because it is shown a single time, then register the server. Add --scope user to make it available in every project, or --scope project to write it into a .mcp.json your teammates get with the repository.

The --transport http part is not optional. Without it, claude mcp add treats the URL as a stdio command and tries to execute it as a binary. Nothing errors loudly; the server simply never appears in the session, which is the single most common reason people conclude that an MCP server is broken.

claude mcp add --transport http datadef https://datadef.io/mcp \
  --header "Authorization: Bearer dd_live_YOUR_KEY"

# then restart Claude Code, and inside a session:
/mcp

Verify before you prompt

Run /mcp inside a session. A connected Datadef server reports 36 tools: nine that operate on whole diagrams, including create_diagram, edit_diagram, export_diagram, repo_status, and repo_refresh, plus 27 canvas tools prefixed canvas_ for nodes, edges, zones, lineage, layout, and validation.

If the count is zero or the server is missing, work through four things in order. The transport flag, from the previous section. A restart, since the client reads its server list at startup. The key, which is shown once and cannot be recovered, only replaced. And the plan, since tool calls need a paid plan while the signup trial covers the evaluation.

The first prompt does more work than the setup

Tell the agent to read the design guide before it draws. get_design_guide returns the design standard byte for byte, because the server imports the text the Datadef generator is prompted with rather than paraphrasing it. A diagram an agent builds by hand therefore comes out in the same idiom as a generated one.

What that text carries is concrete, not advice. Aim for 12 to 20 nodes with no more connections than nodes, and 25 to 40 only when depth was explicitly asked for. Never connect an edge to a zone, because zones have no ports and the edge renders detached; connect the node inside or use a flow arrow. Run canvas_layout_canvas once after a structural change and not at all after deliberate manual placement, which it would discard. The three tools an agent reaches for first, canvas_add_nodes, canvas_group_nodes, and canvas_describe_canvas, carry a pointer to the guide in their descriptions, but saying it in the prompt is more reliable than hoping.

The second thing worth asking for is validation. canvas_validate_canvas checks for orphans and overlaps, and canvas_measure_canvas reports the size, which is the part a text-only model fundamentally cannot do about its own output. A session that ends with a validate call produces a diagram you can put in a review; one that ends at add_nodes usually does not.

The diagram is not stuck in the chat. Everything the agent creates is a project in your workspace, openable on the canvas, editable by hand, and embeddable as a live image that keeps matching the canvas.

Good first prompt:

  Call get_design_guide first. Then read this repo and draw the
  architecture as a Datadef diagram: zones per domain, real service
  names, labelled edges. Validate the canvas before you finish and
  give me the link.

What the agent will not do on its own

It will not notice tomorrow that the architecture changed. Tools run inside a session, so an agent-drawn diagram is exactly as current as the last time you asked. For a diagram that keeps up without a session, connect the repository itself and let it regenerate daily, then let the agent check on it with repo_status and bring it forward with repo_refresh when it is behind.

Put the rule where the agent reads it

A line in CLAUDE.md saying which project id holds the architecture diagram, and that structural changes should be applied with edit_diagram rather than a fresh generation, saves the same explanation every session. See agent workflows for documentation.

FAQ

What is the command to add a diagram MCP server to Claude Code?

claude mcp add --transport http datadef https://datadef.io/mcp --header "Authorization: Bearer YOUR_KEY", then restart Claude Code. Add --scope user to register it for every project, or --scope project to write it into a .mcp.json shared with the repository.

The server does not appear in /mcp. What is wrong?

Most often the transport flag is missing. Without --transport http, the CLI treats the URL as a stdio command and tries to run it as a binary, so the server never registers and nothing reports an error. The other frequent causes are not restarting the client after adding the server, and a mistyped key.

Where does the API key come from?

From the MCP and integrations page in Datadef settings. A key is displayed once at creation and cannot be retrieved later, only revoked and replaced. ChatGPT is the exception among clients: it connects through an OAuth sign-in with no pasted key.

Can I edit an existing diagram from Claude Code instead of making a new one?

Yes. list_diagrams returns what is in your workspace, get_diagram fetches one, and edit_diagram applies a plain-language change to it. For fine control there are 27 canvas tools that add, connect, group, move, and validate individual elements.

Does the agent send my source code to the server?

No. It reads the repository locally and sends only the structure it decided to draw: node labels, zones, edges, and column names where lineage was requested. No tool in the server accepts source files.