Create, edit, validate, render, and export D2 diagrams with confined workspace access.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
A Model Context Protocol (MCP) server that provides D2 diagram generation and manipulation capabilities.
D2 is a modern diagram scripting language that turns text to diagrams. This MCP server allows AI assistants like Claude to create, render, export, and save D2 diagrams programmatically.
The server provides 16 MCP tools for complete-source authoring, validation, rendering, embedded D2 guidance, and incremental Oracle editing.
With the new Oracle API integration, AI assistants can now build and modify diagrams incrementally, making it perfect for:
All export formats use bundled Go renderers; no rsvg-convert, ImageMagick, or Chromium installation is required.
The embedded capability catalog is based on the official D2 language tour, D2 API documentation, and D2 v0.9.0 release.
The image defaults to STDIO transport and confines local imports, assets, and exports to the mounted /workspace directory. The container runs as a non-root user, so the mounted directory must be writable by that user when saving exports.
Release tags publish the server as io.github.RecursiveFunctions/d2mcp in the official MCP Registry. Registry publication and editor-gallery indexing are separate, so a newly published version might not appear immediately in an editor's search results.
Compatible clients can also use the portable .mcp.json configuration in this repository. It requires Docker and mounts the current workspace at /workspace.
Client configurations are generated from server.json, so they always use the same immutable container version.
| Client | Installation |
|---|---|
| VS Code | Use the installation URL, Official MCP Registry, or companion extension |
| VSCodium and Positron | Install the RecursiveFunctions.d2mcp companion extension from Open VSX |
| Cursor | Use the generated MCP configuration |
| Windsurf | Use the generated MCP configuration |
| Trae | Use the generated install URL or project configuration |
| Antigravity | Use the generated MCP configuration |
| Zed | Use the generated manual configuration while Zed completes Official Registry integration |
| Kilo Code | Install from Kilo Marketplace after its catalog PR is accepted, or use the portable configuration |
| Cline | Install from Cline Marketplace after curator approval, or follow the Docker instructions above |
Run make generate-adapters after changing release metadata. CI runs make verify-adapters and rejects stale client configurations.
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
For STDIO transport (recommended for Claude Desktop):
For SSE transport:
Replace /path/to/d2mcp with the actual path to your built binary.
d2mcp now supports multiple transport protocols:
The traditional stdio transport for direct process communication:
HTTP-based transport that allows network connectivity:
SSE Configuration Options:
-addr: Address to listen on (default: ":3000")-base-url: Base URL for SSE endpoints (auto-generated if not specified)-base-path: Base path for SSE endpoints (default: "/mcp")-keep-alive: Keep-alive interval in seconds (default: 30)SSE Endpoints: When running in SSE mode, the following endpoints are available:
http://localhost:3000/mcp/ssehttp://localhost:3000/mcp/messageThe modern HTTP-based transport that simplifies bidirectional communication:
Streamable HTTP Configuration Options:
-addr: Address to listen on (default: ":3000")-endpoint-path: Endpoint path for Streamable HTTP (default: "/mcp")-heartbeat-interval: Heartbeat interval in seconds (default: 30)-stateless: Enable stateless mode (default: false)Streamable HTTP Endpoint: When running in Streamable HTTP mode, a single endpoint handles all communication:
http://localhost:3000/mcpThe server confines imports, local images, and saved files to named workspace roots. The default root is the server's current working directory.
-workspace-root is repeatable. Local path traversal and symlink escapes are rejected. Remote assets require HTTPS and are subject to DNS/IP, redirect, timeout, MIME, and response-size checks; loopback and private-network destinations are rejected.
Create a new diagram with optional initial content (unified approach):
Empty diagram (for Oracle API workflow):
With initial D2 content and a named workspace for imports/assets:
Export a diagram using a bundled renderer and layout engine:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/d2-mcp-server)<a href="https://allmcps.com/mcp/d2-mcp-server"><img src="https://allmcps.com/api/badge/d2-mcp-server?style=directory" alt="D2 MCP Server on AllMCPs" /></a>