D2 MCP Server

A Model Context Protocol (MCP) server for working with [D2: Declarative Diagramming](https://d2lang.com/), enabling seamless integration of diagram

Local serverstdioGo

What is the D2 MCP MCP server?

D2 mcp mcp server connects D2 MCP to AI assistants that speak the Model Context Protocol. A Model Context Protocol (MCP) server for working with D2: Declarative Diagramming, enabling seamless integration of diagram creation and validation into your development workflow.

What D2 MCP does

A Model Context Protocol (MCP) server for working with D2: Declarative Diagramming, enabling seamless integration of diagram creation and validation into your development workflow.

Tools it exposes

Once connected, the assistant can call this tool directly:

  • Debugging — The Debugging tool exposed by this server

Installing the d2 mcp mcp server

The server is distributed via npm as @modelcontextprotocol/inspector, so most clients can run it without a manual build step. Add it to your MCP client's configuration and restart the client to pick it up — the copy-paste configs for Claude Desktop, Claude Code and Cursor are on this page.

Where it fits

Developer-tool servers are usually the first ones people connect, because they turn "help me with this code" into an assistant that can actually read the repo and act on it. D2 MCP sits in that group, and the shape of its toolset — Debugging — tells you what it is really for. Worth comparing against the other developer tools servers in this directory before you commit to one, since several overlap in scope but differ sharply in setup cost and permissions.

Practical notes

  • This server runs locally, so it operates with whatever access your machine and its credentials already have. Scope that deliberately rather than by default.
  • Maintained by h0rv, written in Go.
  • MCP clients ask for confirmation before each tool call by default. Keep that on while you learn what the d2 mcp mcp server actually does with your data.
  • Every entry in this directory is reviewed by hand before it goes live, and details are checked against the project's own documentation.

Available tools

ToolWhat it does
DebuggingThe Debugging tool exposed by this server.

How to install the D2 MCP MCP server

{
    "mcpServers": {
        "d2": {
            "command": "/YOUR/ABSOLUTE/PATH/d2-mcp",
            "args": ["--image-type", "png"]
        }
    }
}

Configuration as documented by the project. Restart the client after saving.

Example prompts to try

  • Use D2 MCP to Debugging.

Frequently asked questions

It connects D2 MCP to MCP-compatible AI assistants such as Claude and Cursor, exposing 1 tool (Debugging) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with D2 MCP directly.