loading…
Search for a command to run...
loading…
Enables AI assistants to compile, validate, and explore D2 diagrams using the official D2 WASM package. It provides tools for generating SVGs with custom layout
Enables AI assistants to compile, validate, and explore D2 diagrams using the official D2 WASM package. It provides tools for generating SVGs with custom layouts, themes, and icons directly from D2 source code.
MCP server for the D2 diagram language. Compile, validate, and explore D2 diagrams from any MCP-compatible AI assistant.
Uses the native D2 CLI binary (installed automatically in the Docker image) to compile diagrams into SVG and PNG.
| Tool | Description |
|---|---|
compile |
D2 source code → SVG/PNG. Supports layout engines, themes, sketch mode, dark themes, multi-board targeting, and more. |
validate |
Check D2 syntax without rendering. Returns validity status and error details. |
list_themes |
List all available D2 themes with IDs (light and dark). |
list_layouts |
List available layout engines (dagre, elk). |
list_icons |
Browse icons from icons.terrastruct.com by category (AWS, GCP, Azure, K8s, dev, essentials, tech). |
| Resource | Description |
|---|---|
d2://syntax-reference |
Complete D2 language syntax reference in markdown. |
D2_PATH env var to the binary location.scripts/download-icons.sh ./icons then set ICONS_DIR=./icons to enable local icon resolution. Without this, icon URLs are passed through to the D2 CLI as-is.npm install
npm run build
npm start
For development with auto-reload:
npm run dev
The server starts on port 3000 by default (override with PORT env var).
GET /healthPOST /mcp (Streamable HTTP transport)| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
HTTP server port |
D2_PATH |
d2 |
Path to the D2 CLI binary (resolved via PATH by default) |
ICONS_DIR |
./icons |
Directory containing downloaded SVG icons for local resolution |
This project includes a Dockerfile and render.yaml blueprint for one-click deployment to Render. The Docker image automatically installs the D2 CLI binary and downloads all icons at build time.
render.yaml and deployOr manually create a Web Service with:
/healthOnce deployed, configure your MCP client to connect via Streamable HTTP:
{
"mcpServers": {
"d2": {
"url": "https://your-service.onrender.com/mcp"
}
}
}
Replace the URL with your actual Render service URL (or http://localhost:3000/mcp for local).
| Parameter | Type | Description |
|---|---|---|
code |
string | D2 source code (required) |
layout |
"dagre" | "elk" |
Layout engine (default: dagre) |
sketch |
boolean | Hand-drawn sketch mode |
themeID |
integer | Theme ID (see list_themes) |
darkThemeID |
integer | Dark mode theme ID |
pad |
integer | Padding in pixels (default: 100) |
center |
boolean | Center SVG in viewbox |
scale |
number | Scale factor (default: fit to screen) |
target |
string | Target board for multi-board diagrams |
animateInterval |
integer | Animation interval (ms) for multi-board SVGs |
noXMLTag |
boolean | Omit XML declaration for HTML embedding |
MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"d2-mcp": {
"command": "npx",
"args": []
}
}
}