D2 MCP App
MCP App · UI in chath0rv maintains this Go MCP server for validating and rendering D2 diagrams. Release 2.0.0 bundles D2 0.9.0 and publishes an optional ui://d2/viewer resource that previews rendered diagrams with pan, zoom, fit, source copy and supported PNG downloads.
Not for: A visual diagram editor or document store. The viewer is read-only, the --ui flag is off by default, and the shipped server keeps no persistent diagram state.
Source and setup verified on 2026-11-05
VisualizationQuick facts
- Maintainer
- h0rv (community)
- Release
- d2-mcp 2.0.0 with D2 0.9.0
- Transports
- stdio, Streamable HTTP, legacy SSE
- UI evidence
- ui://d2/viewer; text/html;profile=mcp-app
- UI switch
- --ui; disabled by default
What you can do
- Validate D2 syntax and return located diagnostics
- Render diagrams as PNG, SVG or ASCII
- Use bundled Dagre, ELK or open-source TALA layouts
- Preview output with pan, zoom, fit and D2 source copy
- Optionally read approved local .d2 files and write artifacts
Requirements
- A d2-mcp 2.0.0 release binary, or Go 1.27.2+ to build it
- An MCP Apps-compatible host for the inline viewer
- The --ui flag when starting the server
Choose the 2.0.0 binary for Linux, macOS or Windows and verify it against the published SHA256SUMS file.
On Linux or macOS run chmod +x, then place the binary on PATH or keep its absolute path.
Add --ui to the stdio or HTTP command. Without that flag, the same diagram tools work but no app resource is advertised.
{
"mcpServers": {
"d2": {
"command": "/absolute/path/d2-mcp",
"args": ["--transport", "stdio", "--ui"]
}
}
}Always confirm the latest setup instructions with the maintainer before installing.
>Questions
Does d2-mcp include a real MCP App viewer?
Yes. With --ui it serves ui://d2/viewer as text/html;profile=mcp-app and links compatible diagram tools to that resource.
Do I need the separate D2 executable?
No. The 2.0.0 release binaries bundle D2, the supported layout engines and native PNG rendering.
Can I edit a diagram directly in the viewer?
No. The viewer previews tool output and lets you copy source; ask the agent to change the D2 source and render again.
>Related Apps
Interactive 3D globe viewer using CesiumJS for geospatial visualization
Interactive 3D scene renderer with Three.js for stunning visualizations
Real-time GLSL shader renderer for creative visual effects