Labsco
MCP SERVER

D2 MCP Server

by i2y

Build D2 diagrams incrementally — add one shape at a time, then export to SVG, PNG or PDF.

Diagrams & Charts
Summary
Diagrams that survive a change of mind.

The incremental editing tools are the point: instead of regenerating the whole diagram whenever a detail changes, you add one shape, move one node into a container, or rename one element, and everything else stays where it was. Serialising back to D2 text means the result leaves the conversation in a form you can keep editing by hand.

What it is

A D2 diagram server. It creates a diagram empty or from D2 source you already have, then edits it piece by piece — adding shapes and connections, setting attributes, moving, renaming and deleting elements — and exports or saves the result.

What you get
  • A diagram created empty for incremental building, or with initial D2 content
  • Shapes and connections added one at a time to an existing diagram
  • Attributes set on any element — shape, label, fill and the rest
  • Elements moved between containers, renamed, or deleted along with their children
  • Information read back about a shape, an edge, or a container's children
  • The current diagram serialised back to D2 text, including everything added incrementally
  • Export to SVG, PNG or PDF, or saved straight to a path you name
  • Every D2 theme, light and dark
  • A choice of transports: stdio, event-stream, or streaming HTTP
Requirements

A built binary — the project is Go and compiles to a single executable. PNG and PDF export need a local converter such as librsvg or ImageMagick; SVG needs nothing extra. No account, no key.

Setup effort

One command — go install github.com/i2y/d2mcp/cmd@latest