i2y/d2mcp
If you are the rightful owner of d2mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The D2 MCP Server is a Model Context Protocol server that facilitates the creation and manipulation of D2 diagrams through AI assistants.
The D2 MCP Server is designed to provide advanced diagram generation and manipulation capabilities using the D2 scripting language, which converts text into diagrams. This server is particularly useful for AI assistants like Claude, enabling them to programmatically create, render, export, and save D2 diagrams. With the integration of the Oracle API, the server supports incremental diagram building, making it ideal for converting conversations into architecture diagrams, building flowcharts as requirements are discussed, creating entity relationship diagrams from database schemas, generating system diagrams from code analysis, and refining diagrams based on user feedback without starting over. The server offers a unified approach to diagram creation and supports exporting to various formats, including SVG, PNG, and PDF. It also includes 20 themes to enhance the visual appeal of diagrams.
Features
- Unified diagram creation with optional initial content
- Export diagrams to SVG, PNG, and PDF formats
- Incremental diagram building with Oracle API
- Support for 20 D2 themes (18 light + 2 dark)
- Standard MCP protocol for AI tool integration
Usages
usage with claude desktop stdio
{ "mcpServers": { "d2mcp": { "command": "/path/to/d2mcp", "args": ["-transport=stdio"] } } }
usage with claude desktop sse
{ "mcpServers": { "d2mcp": { "command": "/path/to/d2mcp", "args": ["-transport=sse", "-addr=:3000"] } } }
usage standalone stdio
bash ./d2mcp -transport=stdio
usage standalone sse
bash ./d2mcp -transport=sse
usage standalone streamable http
bash ./d2mcp -transport=streamable
Tools
d2_create
Create new diagrams with optional initial content
d2_export
Export diagrams to various formats (SVG, PNG, PDF)
d2_save
Save existing diagrams to files
d2_oracle_create
Create shapes and connections incrementally
d2_oracle_set
Set attributes on existing elements
d2_oracle_delete
Delete specific elements from diagrams
d2_oracle_move
Move shapes between containers
d2_oracle_rename
Rename diagram elements
d2_oracle_get_info
Get information about shapes, connections, or containers
d2_oracle_serialize
Get the current D2 text representation of the diagram