D2
MCP server by d2lang Community
Renders D2 text diagrams to SVG, validates D2 source, and ships an agent skill for AI clients. Aimed at developers and writers who create diagrams from text in docs, CI and blog posts.
Install D2
Built from the published package, never by AI.
claude mcp add d2 -- uvx d2langRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"d2": {
"args": [
"d2lang"
],
"command": "uvx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"d2": {
"args": [
"d2lang"
],
"command": "uvx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"d2": {
"args": [
"d2lang"
],
"command": "uvx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add d2 -- uvx d2lang{
"mcpServers": {
"d2": {
"args": [
"d2lang"
],
"command": "uvx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add d2 uvx d2langGemini CLI was replaced by Antigravity CLI in June 2026 and remains only for enterprise licences and paid API keys.
MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the d2 block.
About
D2 is a modern diagram scripting language that turns text into diagrams. You write D2 source in a file and run the d2 command to create an SVG. The CLI also includes d2 validate, which checks a diagram for errors and warnings and can output diagnostics as JSON, and d2 --watch, which gives a live browser preview.
D2 can also be used as a library from Go through d2lib, or from JavaScript and TypeScript through @d2lang/d2. The project lists an official agent skill that installs with npx skills add d2lang/d2 for several AI coding clients. The source does not describe MCP tools, storyboards or motion lint, so those parts of the listing are not confirmed here. D2 is open source under the Mozilla Public License 2.0 and is aimed at people who make diagrams, docs and blog posts from text.
Written from the project's README and checked against it.
What you need
- macOS or Linux for the install script
- x64 Windows for the MSI installer
- uv, optional, to run the CLI with uvx d2lang
Try asking
- Validate this D2 diagram and list any errors or warnings.
- Render this D2 script to an SVG file named hello.svg.
- Show me how to connect shapes with labels in D2 syntax.
Good to know
- The source does not mention an MCP server, so the MCP listing is not confirmed by it.
- Storyboards and motion lint from the listing description do not appear in the source.
- After installation, D2 does not use the internet except to check for version updates.
Security check
C- Downloads a script from the internet and runs itIn
README.md:curl -fsSL https://d2lang.com/install.sh | sh
Checked automatically: README.md. This looks for known risky patterns and is not a full audit. How grades work
What you can do with it
- Turning text into architecture diagrams
- Validating D2 diagram source in CI
- Rendering diagrams for docs and blog posts
Alternatives to D2
All alternatives →Turns GitHub repositories into architecture diagrams, written explanations, Mermaid source and narrated explainer videos. Built for developers who want to understand a codebase, and for AI agents that need to read one.
Mocks, records, and chaos-tests HTTP(S) dependencies for development and testing. One port serves many protocols, including gRPC, WebSockets, and LLM chat APIs. Built for developers and testers who need stand-in services during tests.
Provides MCP server and CLI tools that let AI coding agents build, test and manage iOS and macOS projects with Xcode and simulators. It is aimed at developers working on Apple platform apps.
Creates editable draw.io diagrams in AI chat from Mermaid, PlantUML, CSV or draw.io XML. Built for people who want diagrams from text prompts that stay editable in draw.io.
Indexes your code, git history, tests and decisions on your machine so AI coding agents can query the index instead of re-reading files. Built for developers who want fewer files opened and clearer answers about change risk and code health.
Gives your AI assistant hosted codebase intelligence for repos indexed on repowise.dev. Use it to ask how code works, what a change may break, and which tests to run.
Compare with GitDiagram, mockserver or XcodeBuildMCP
D2: common questions
Does D2 collect telemetry?
No. The source says D2 does not use an internet connection after installation, except to check for version updates from GitHub periodically.
Does D2 need a browser to run?
No. The source says D2 can run entirely server-side.
Where can I get help with D2?
The source says the best way to get help is to ask on the D2 Discord. Feature requests and bug reports go to GitHub Issues.
How do I install D2?
In Claude Code run claude mcp add d2 -- uvx d2lang. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.
Is D2 the official server?
D2 is a community project by d2lang, not verified by a company domain.
Is D2 free?
The code is published under the MPL-2.0 licence. The service it connects to may have its own pricing.
Is D2 safe to use?
It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade C (downloads a script from the internet and runs it). Review the code before you install. How grades work.
What are alternatives to D2?
Similar MCP servers: GitDiagram, mockserver, XcodeBuildMCP, draw.io.
Does D2 work with ChatGPT?
Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.
