Provides a comprehensive D2 language syntax reference as a resource in Markdown format.
Compiles D2 diagram source code into SVG images, supporting layout engines, themes, and various rendering options.
Allows for the generation of SVG output with or without XML declarations to facilitate embedding in HTML or other XML-based documents.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@d2-mcprender a d2 diagram for a microservices architecture in sketch mode"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
d2-mcp
MCP server for the D2 diagram language. Compile, validate, and explore D2 diagrams from any MCP-compatible AI assistant.
Uses the official @terrastruct/d2 WASM package — no CLI binary needed.
Tools
Tool | Description |
| D2 source code → SVG. Supports layout engines, themes, sketch mode, dark themes, multi-board targeting, and more. |
| Check D2 syntax without rendering. Returns validity status and error details. |
| List all available D2 themes with IDs (light and dark). |
| List available layout engines ( |
| Browse icons from icons.terrastruct.com by category (AWS, GCP, Azure, K8s, dev, essentials, tech). |
Resources
Resource | Description |
| Complete D2 language syntax reference in markdown. |
Local Development
npm install
npm run build
npm startThe server starts on port 3000 by default (override with PORT env var).
Health check:
GET /healthMCP endpoint:
POST /mcp(Streamable HTTP transport)
Deployment (Render)
This project includes a Dockerfile and render.yaml blueprint for one-click deployment to Render.
Push this repo to GitHub
In Render, create a new Blueprint and connect your repo
Render will auto-detect
render.yamland deploy
Or manually create a Web Service with:
Environment: Docker
Health Check Path:
/healthPlan: Free
Connecting to the MCP Server
Once 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).
Compile Tool Options
Parameter | Type | Description |
| string | D2 source code (required) |
|
| Layout engine (default: dagre) |
| boolean | Hand-drawn sketch mode |
| integer | Theme ID (see |
| integer | Dark mode theme ID |
| integer | Padding in pixels (default: 100) |
| boolean | Center SVG in viewbox |
| number | Scale factor (default: fit to screen) |
| string | Target board for multi-board diagrams |
| integer | Animation interval (ms) for multi-board SVGs |
| boolean | Omit XML declaration for HTML embedding |
License
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.