Skip to main content
Glama

Claude Mermaid MCPサーバー

Claude CodeでMermaidダイアグラムをレンダリングするためのMCPサーバーです。ライブリロード機能と、専門的なガイダンスを提供する組み込みスキルを備えています。

ダイアグラムを洗練させるたびに、ブラウザでリアルタイムに更新され、自動的にレンダリングされます。反復的なダイアグラム開発やドキュメント作成のワークフローに最適です。

デモ

✨ 機能

  • 🔄 ライブリロード - 編集に合わせてブラウザ上のダイアグラムが自動更新されます

  • 🎨 複数の保存形式 - SVG、PNG、またはPDFとしてエクスポート可能

  • 🌈 テーマ - デフォルト、forest、dark、neutralのテーマから選択可能

  • 📐 カスタマイズ可能 - 寸法、スケール、背景色を制御可能

  • 🪄 インタラクティブプレビュー - ドラッグによるパン、ブラウザ操作によるズーム、ワンクリックでの位置リセットが可能

  • ⬇️ ブラウザエクスポート - プレビューから直接SVGまたはPNGとしてダイアグラムをダウンロード可能

  • 🗂️ 複数のプレビュー - preview_idを使用して、複数のダイアグラムを同時に作業可能

  • 💾 永続的な作業ファイル - ライブプレビューは ~/.config/claude-mermaid/live に保存されます

  • 🤖 組み込みスキル - ダイアグラム作成のためのベストプラクティスと専門的なガイダンスを提供するClaudeスキルが含まれています

Related MCP server: mcp-mermaid-validator

アーキテクチャ

アーキテクチャ図

ユーザーワークフロー図

依存関係図

🚀 クイックスタート

1. インストール

プラグインインストール(推奨)

Claude Codeでマーケットプレイスを追加し、プラグインをインストールします:

/plugin marketplace add veelenga/claude-mermaid
/plugin install claude-mermaid@claude-mermaid

その後、Claude Codeを再起動してプラグインを有効にします。

npmから:

npm install -g claude-mermaid

ソースから:

git clone https://github.com/veelenga/claude-mermaid.git
cd claude-mermaid
npm install && npm run build && npm install -g .

2. インストールの確認

プラグインインストール: MCPサーバーは自動的に設定されます。確認のみ行ってください:

/mcp

MCPサーバーリストに mermaid が表示されるはずです。

npmインストール: MCPサーバーを手動で設定します:

claude mcp add --scope user mermaid claude-mermaid

その後、確認します:

claude mcp list

mermaid: claude-mermaid - ✓ Connected と表示されるはずです。

🔌 その他のMCPクライアント設定

このサーバーはClaude Codeに最適化されていますが、MCP互換クライアントであればどれでも動作します。他の一般的なツールでの設定方法は以下の通りです:

Codex MCP設定ファイル (~/.codex/mcp_settings.json) に追加します:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

またはCodex CLI経由で設定します:

codex mcp add mermaid claude-mermaid

Cursor MCP設定ファイル (.cursor/mcp.json または設定) に追加します:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

またはCursorの設定UIを使用します:

  1. Cursor設定を開く (Cmd/Ctrl + ,)

  2. MCP Serversに移動

  3. コマンド claude-mermaid で新しいサーバーを追加

VSCodeで Cline拡張機能 を使用している場合:

  1. VSCode設定を開く (Cmd/Ctrl + ,)

  2. "Cline MCP" を検索

  3. MCP設定JSONに追加:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

WindsurfのMCP設定ファイルに追加します:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

設定ファイルの場所はプラットフォームによって異なります:

  • macOS: ~/Library/Application Support/Windsurf/mcp.json

  • Linux: ~/.config/windsurf/mcp.json

  • Windows: %APPDATA%\Windsurf\mcp.json

Gemini CLIのMCP設定ファイル (~/.gemini/mcp.json) に追加します:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

またはGemini CLIを使用して設定します:

gemini config mcp add mermaid --command claude-mermaid

MCP互換クライアントであれば、標準設定を使用してください:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid"
    }
  }
}

インストール後、コマンド claude-mermaid がPATHで利用可能になっているはずです。

注意: クライアントによっては実行ファイルへのフルパスが必要な場合があります:

  • パスの確認: which claude-mermaid (Unix/macOS) または where claude-mermaid (Windows)

  • 設定で絶対パスを使用: "command": "/path/to/claude-mermaid"

💡 使用方法

Claude CodeにMermaidダイアグラムを作成するよう自然に依頼してください。プラグインとしてインストールされている場合、組み込みの mermaid-diagrams スキルが専門的なガイダンス、ベストプラクティス、自動ワークフロー管理を提供します。

基本的な例

"Create a Mermaid diagram showing the user authentication flow"
"Draw a sequence diagram for the payment process"
"Generate a flowchart for the deployment pipeline"

高度な例

カスタムフォーマット:

"Create a dark theme architecture diagram with transparent background"
"Generate a forest theme flowchart and save to ./docs/flow.svg"

特定の出力フォーマット:

"Create an ER diagram and save as PDF to ./docs/schema.pdf"
"Save the flowchart as PNG to ./docs/flow.png"

注意: ブラウザはライブプレビュー用に常にSVGを表示しますが、保存は選択したフォーマットで行われます。

反復的な改善:

"Create a class diagram for the User module"
// Browser opens with live preview
"Add the Address and Order classes with relationships"
// Diagram updates automatically in browser!

完全な例

"Create a flowchart and save to ./docs/auth-flow.svg:

graph LR
    A[User Login] --> B{Valid Credentials?}
    B -->|Yes| C[Access Granted]
    B -->|No| D[Access Denied]
    C --> E[Dashboard]
    D --> F[Try Again]

    style A fill:#e1f5ff
    style C fill:#d4edda
    style D fill:#f8d7da
"

ダイアグラムは ./docs/auth-flow.svg に保存され、ライブリロードが有効な状態でブラウザで開かれます。

🔧 ツールとパラメータ

MCPサーバーによって公開されているツールは2つあります:

  1. mermaid_preview — ライブプレビューをレンダリングして開く

  • diagram (string, 必須) — Mermaidダイアグラムコード

  • preview_id (string, 必須) — このプレビューセッションの識別子。複数のダイアグラムを同時に扱う場合は異なるIDを使用してください (例: architecture, flow)。

  • format (string, デフォルト svg) — svg, png, pdf のいずれか。ライブプレビューは svg でのみ利用可能です。

  • theme (string, デフォルト default) — default, forest, dark, neutral のいずれか。

  • background (string, デフォルト white) — 背景色。例: transparent, white, #F0F0F0。

  • width (number, デフォルト 800) — ダイアグラムの幅(ピクセル単位)。

  • height (number, デフォルト 600) — ダイアグラムの高さ(ピクセル単位)。

  • scale (number, デフォルト 2) — 高品質出力のためのスケール係数。

  1. mermaid_save — 現在のライブダイアグラムをパスに保存する

  • save_path (string, 必須) — 保存先パス (例: ./docs/diagram.svg)。

  • preview_id (string, 必須) — mermaid_preview で使用した preview_id と一致する必要があります。

  • format (string, デフォルト svg) — svg, png, pdf のいずれか。このフォーマットのライブ作業ファイルがまだ存在しない場合、保存前にオンデマンドでレンダリングされます。

🎯 ライブリロードの仕組み

  1. 初回レンダリング: http://localhost:3737/{preview_id} でブラウザにダイアグラムを開きます

  2. 変更: Claude Codeを通じてダイアグラムを編集します

  3. 自動更新: ブラウザがWebSocket経由で変更を検出し、リロードします

  4. ステータスインジケーター: 緑の点 = 接続済み、赤の点 = 再接続中

ライブサーバーはポート3737-3747を使用し、利用可能なポートを自動的に検索します。

ライブプレビューの操作

  • パン: ダイアグラムをクリックしてドラッグし、移動します

  • ズーム: ブラウザのズーム機能を使用します (Ctrl/Cmd + +/- またはトラックパッドでのピンチズーム)

  • 位置リセット: ステータスバーの ⊙ ボタンをクリックしてダイアグラムを中央に戻します

  • エクスポート: ⬇ ボタンをクリックしてSVGまたはPNGとしてダウンロードします

注意事項

  • ライブプレビューは svg フォーマットでのみ利用可能です。PNG/PDFはライブリロードなしでレンダリングされます。

  • シーケンス図の場合、Mermaidは sequenceDiagram 内の style ディレクティブをサポートしていません。

🖥️ スタンドアロンサーバー

--serve フラグを使用して、AIエージェントなしでプレビューサーバーを起動できます:

claude-mermaid --serve

これにより、以前にレンダリングされたすべてのダイアグラムを含むダイアグラムギャラリーがブラウザで開かれます。Claude Codeセッション外でダイアグラムを閲覧・エクスポートするのに便利です。

🛠️ 開発

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Watch mode for development
npm run dev

# Start the MCP server directly
npm start

📝 トラブルシューティング

エラー: Cannot find package 'puppeteer':

これは稀な環境固有の問題です。以下の解決策を試してください:

  1. claude-mermaidをグローバルにインストール:

    npm install -g claude-mermaid
  2. Claude Codeでプラグインを再インストール:

    /plugin uninstall claude-mermaid
    /plugin install claude-mermaid@claude-mermaid

サーバーが接続されない:

# Check if server is installed
claude-mermaid -v

# Reinstall if needed
npm install -g claude-mermaid

# Verify MCP configuration
claude mcp list

Permission deniedエラー:

# Make sure the binary is executable
chmod +x $(which claude-mermaid)

ポートが既に使用中:

  • サーバーはポート3737-3747を使用します

  • 利用可能なポートを自動的に検索します

  • 他のプロセスがこれらのポートを使用していないか確認してください: lsof -i :3737-3747

ダイアグラムがレンダリングされない、またはライブリロードが機能しない:

サーバーは ~/.config/claude-mermaid/logs/ にログを出力します:

  • mcp.log - ツールリクエストとダイアグラムレンダリング

  • web.log - HTTP/WebSocket接続とライブリロード

MCP設定でデバッグログを有効にします:

{
  "mcpServers": {
    "mermaid": {
      "command": "claude-mermaid",
      "env": {
        "CLAUDE_MERMAID_LOG_LEVEL": "DEBUG"
      }
    }
  }
}

その後、ログを確認します:

# View MCP operations
tail -f ~/.config/claude-mermaid/logs/mcp.log

# View WebSocket connections
tail -f ~/.config/claude-mermaid/logs/web.log

利用可能なログレベル: DEBUG, INFO (デフォルト), WARN, ERROR, OFF

🤝 貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

📄 ライセンス

MIT - 詳細は LICENSE ファイルを参照してください

🔗 リンク

👀 参照

このプロジェクトが気に入った場合は、以下も興味があるかもしれません

  • preview-skills — ブラウザでファイルを視覚化するためのプレビュー用スキル (markdown, csv, json, mermaidなど)

ホスト型デプロイ

ホスト型デプロイは Fronteir AI で利用可能です。

Available Tools

2 tools
mermaid_previewA

Render a Mermaid diagram and open it in browser with live reload. Takes Mermaid diagram code as input and generates a live preview. Supports themes (default, forest, dark, neutral), custom backgrounds, dimensions, and quality scaling. The diagram will auto-refresh when updated. Use mermaid_save to save to disk. IMPORTANT: Automatically use this tool whenever you create a Mermaid diagram for the user. NOTE: Sequence diagrams do not support style directives - avoid using 'style' statements in sequenceDiagram.

Inputs: diagram (required), preview_id (required), format, theme, +4 more.

mermaid_saveA

Save the current live Mermaid diagram to a file path. This copies the already-rendered diagram from the live preview to the specified location. Use this after tuning your diagram with mermaid_preview.

Inputs: save_path (required), preview_id (required), format.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have perfectly distinct purposes: mermaid_preview renders and displays a diagram in a browser with live updates, while mermaid_save saves the rendered diagram to disk. There is no overlap or ambiguity between them, as each handles a separate stage of the diagram workflow.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun pattern with the 'mermaid_' prefix: mermaid_preview and mermaid_save. The naming is clear, predictable, and uniform throughout the set, making it easy for an agent to understand their functions.

    Tool Count3/5

    With only two tools, the set feels thin for a Mermaid diagram server, as it lacks operations like editing, exporting to different formats, or managing themes programmatically. However, it covers the core preview-and-save workflow, so it's borderline but not severely mismatched.

    Completeness3/5

    The tools provide basic functionality for previewing and saving diagrams, but there are notable gaps: no tool for creating or editing diagrams from scratch, no support for different output formats (e.g., PNG, SVG), and no way to manage themes or settings beyond the preview. This limits the server's utility for full diagram lifecycle management.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers