claude-mermaid
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サーバーは自動的に設定されます。確認のみ行ってください:
/mcpMCPサーバーリストに mermaid が表示されるはずです。
npmインストール: MCPサーバーを手動で設定します:
claude mcp add --scope user mermaid claude-mermaidその後、確認します:
claude mcp listmermaid: 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-mermaidCursor MCP設定ファイル (.cursor/mcp.json または設定) に追加します:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}またはCursorの設定UIを使用します:
Cursor設定を開く (Cmd/Ctrl + ,)
MCP Serversに移動
コマンド
claude-mermaidで新しいサーバーを追加
VSCodeで Cline拡張機能 を使用している場合:
VSCode設定を開く (Cmd/Ctrl + ,)
"Cline MCP" を検索
MCP設定JSONに追加:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}WindsurfのMCP設定ファイルに追加します:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}設定ファイルの場所はプラットフォームによって異なります:
macOS:
~/Library/Application Support/Windsurf/mcp.jsonLinux:
~/.config/windsurf/mcp.jsonWindows:
%APPDATA%\Windsurf\mcp.json
Gemini CLIのMCP設定ファイル (~/.gemini/mcp.json) に追加します:
{
"mcpServers": {
"mermaid": {
"command": "claude-mermaid"
}
}
}またはGemini CLIを使用して設定します:
gemini config mcp add mermaid --command claude-mermaidMCP互換クライアントであれば、標準設定を使用してください:
{
"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つあります:
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) — 高品質出力のためのスケール係数。
mermaid_save— 現在のライブダイアグラムをパスに保存する
save_path(string, 必須) — 保存先パス (例:./docs/diagram.svg)。preview_id(string, 必須) —mermaid_previewで使用したpreview_idと一致する必要があります。format(string, デフォルトsvg) —svg,png,pdfのいずれか。このフォーマットのライブ作業ファイルがまだ存在しない場合、保存前にオンデマンドでレンダリングされます。
🎯 ライブリロードの仕組み
初回レンダリング:
http://localhost:3737/{preview_id}でブラウザにダイアグラムを開きます変更: Claude Codeを通じてダイアグラムを編集します
自動更新: ブラウザがWebSocket経由で変更を検出し、リロードします
ステータスインジケーター: 緑の点 = 接続済み、赤の点 = 再接続中
ライブサーバーはポート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':
これは稀な環境固有の問題です。以下の解決策を試してください:
claude-mermaidをグローバルにインストール:
npm install -g claude-mermaidClaude 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 listPermission 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 toolsmermaid_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
Scored across 2 tools
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.
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.
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.
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
Related MCP Connectors
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
MCP server to assist with JxBrowser development.
Collaborative whiteboard MCP server — create objects, connectors, C4 diagrams, and manage boards
MCP server for querying Forkast documentation
Related MCP Servers
- AlicenseBqualityBmaintenanceA Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.1301 npm234MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that validates and renders Mermaid diagrams.157MIT
- AlicenseNot gradedqualityDmaintenanceA lightweight MCP server that provides real-time Mermaid diagram syntax validation with support for all diagram types.3MIT
- AlicenseAqualityDmaintenanceAn MCP server that generates diagrams from Mermaid code in multiple formats (PNG, PDF, SVG).21MIT