d2-mcp
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.
README
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 |
|---|---|
compile |
D2 source code → SVG. 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). |
Resources
| Resource | Description |
|---|---|
d2://syntax-reference |
Complete D2 language syntax reference in markdown. |
Local Development
npm install
npm run build
npm start
The server starts on port 3000 by default (override with PORT env var).
- Health check:
GET /health - MCP 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:
/health - Plan: 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 |
|---|---|---|
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 |
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.