d2-mcp

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.

Category
Visit Server

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.

  1. Push this repo to GitHub
  2. In Render, create a new Blueprint and connect your repo
  3. Render will auto-detect render.yaml and 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

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.

Official
Featured
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

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.

Official
Featured
Python
graphlit-mcp-server

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.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured