Skip to main content
Glama

d2-mcp

D2ダイアグラム言語用のMCPサーバーです。MCP互換のAIアシスタントからD2ダイアグラムをコンパイル、検証、探索できます。

ネイティブのD2 CLIバイナリ(Dockerイメージに自動インストール済み)を使用して、ダイアグラムをSVGおよびPNGにコンパイルします。

ツール

ツール

説明

compile

D2ソースコード → SVG/PNG。レイアウトエンジン、テーマ、スケッチモード、ダークテーマ、マルチボードターゲットなどをサポート。

validate

レンダリングせずにD2構文をチェック。有効性ステータスとエラーの詳細を返します。

list_themes

利用可能なすべてのD2テーマ(ライトおよびダーク)をID付きで一覧表示します。

list_layouts

利用可能なレイアウトエンジン(dagreelk)を一覧表示します。

list_icons

icons.terrastruct.comのアイコンをカテゴリ(AWS、GCP、Azure、K8s、dev、essentials、tech)別に閲覧します。

Related MCP server: PlantUML MCP Server

リソース

リソース

説明

d2://syntax-reference

Markdown形式の完全なD2言語構文リファレンス。

ローカル開発

前提条件

  • Node.js 22+

  • D2 CLId2lang.com からインストールするか、D2_PATH環境変数にバイナリの場所を設定してください。

  • アイコン(オプション)scripts/download-icons.sh ./icons を実行し、ICONS_DIR=./icons を設定してローカルアイコン解決を有効にします。これを行わない場合、アイコンURLはそのままD2 CLIに渡されます。

npm install
npm run build
npm start

自動リロード付きの開発用:

npm run dev

サーバーはデフォルトでポート3000で起動します(PORT環境変数で上書き可能)。

  • ヘルスチェック: GET /health

  • MCPエンドポイント: POST /mcp (ストリーミング可能なHTTPトランスポート)

環境変数

変数

デフォルト

説明

PORT

3000

HTTPサーバーポート

D2_PATH

d2

D2 CLIバイナリへのパス(デフォルトではPATH経由で解決)

ICONS_DIR

./icons

ローカル解決用にダウンロードされたSVGアイコンを含むディレクトリ

デプロイ (Render)

このプロジェクトには、Render へのワンクリックデプロイ用の Dockerfilerender.yaml ブループリントが含まれています。Dockerイメージは、ビルド時に自動的にD2 CLIバイナリをインストールし、すべてのアイコンをダウンロードします。

  1. このリポジトリをGitHubにプッシュします

  2. Renderで新しい Blueprint を作成し、リポジトリを接続します

  3. Renderが自動的に render.yaml を検出し、デプロイします

または、以下のように Web Service を手動で作成します:

  • 環境: Docker

  • ヘルスチェックパス: /health

  • プラン: Free

MCPサーバーへの接続

デプロイ後、ストリーミング可能なHTTP経由で接続するようにMCPクライアントを設定します:

{
  "mcpServers": {
    "d2": {
      "url": "https://your-service.onrender.com/mcp"
    }
  }
}

URLを実際のRenderサービスURL(ローカルの場合は http://localhost:3000/mcp)に置き換えてください。

Compileツールのオプション

パラメータ

説明

code

string

D2ソースコード(必須)

layout

"dagre"

"elk"

レイアウトエンジン(デフォルト: dagre)

sketch

boolean

手書きスケッチモード

themeID

integer

テーマID(list_themesを参照)

darkThemeID

integer

ダークモードテーマID

pad

integer

パディング(ピクセル単位、デフォルト: 100)

center

boolean

SVGをビューボックスの中央に配置

scale

number

スケール係数(デフォルト: 画面に合わせる)

target

string

マルチボードダイアグラムのターゲットボード

animateInterval

integer

マルチボードSVGのアニメーション間隔(ms)

noXMLTag

boolean

HTML埋め込み用にXML宣言を省略

ライセンス

MIT

F
license - not found
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to generate and render Mermaid diagrams (flowcharts, sequence diagrams, etc.) as PNG/SVG images with local file saving and HTTP access URLs. Supports batch processing and intelligent caching for efficient diagram creation.
    1
    12
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables the dynamic generation of various software development diagrams, such as flowcharts, sequence diagrams, and architecture diagrams, using Mermaid syntax. It includes tools for diagram validation and provides instructions for exporting results to multiple formats including SVG and PNG.

View all related MCP servers

Related MCP Connectors

  • Generate dynamic Mermaid diagrams and charts with AI assistance. Customize styles and export diagr…

  • Create, validate, edit, export (markdown/svg/png/mermaid), and search JSON Canvas files.

  • Let Claude, Cursor, or ChatGPT author Mermaid diagrams your team can read and share.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ryanmccauley/d2-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server