
peng-shawn/mermaid-mcp-server
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
peng-shawn/mermaid-mcp-server — это кандидат на MCP-сервер, импортированный из https://github.com/peng-shawn/mermaid-mcp-server.
Обзор
peng-shawn/mermaid-mcp-server — это кандидат на MCP-сервер, импортированный из https://github.com/peng-shawn/mermaid-mcp-server.
Обзор (машинный перевод)
Сервер Model Context Protocol (MCP), который преобразует диаграммы Русалок в изображения PNG или SVG-файлы. Этот сервер позволяет ассистентам ИИ и другим приложениям создавать визуальные диаграммы из текстовых описаний с использованием синтаксиса Mermaid markdown.
Особенности
- Преобразование кода диаграммы Русалки в PNG-изображения или SVG-файлы
- Поддерживает несколько тем диаграмм (по умолчанию, лес, тёмная, нейтральная)
- Настраиваемые цвета фона
- Использует Puppeteer для высококачественного безголового рендеринга браузера
- Реализует протокол MCP для бесшовной интеграции с ассистентами ИИ
- Гибкие варианты вывода: напрямую возвращать изображения/SVG или сохранять на диск
- Обработка ошибок с подробными сообщениями об ошибках
Как это работает
Сервер использует Puppeteer для запуска браузера без головы, рендеринга диаграммы Русалочки в SVG и, по необходимости, для захвата скриншота отрисованной диаграммы. Процесс включает в себя:
- Запуск безголового браузера
- Создание HTML-шаблона с кодом Mermaid
- Загрузка библиотеки Mermaid.js
- Рендеринг диаграммы в SVG
- Либо сохранить SVG напрямую, либо сделать скриншот в формате PNG
- Либо прямое возвращение образа/SVG, либо сохранение на диск
Строительство
Использование
Использование с Claude desktop
Эта страница переведена автоматически. Технические детали смотрите в оригинале.
README
Показан фрагмент оригинального README. Открыть оригинал.
Mermaid MCP Server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images or SVG files. This server allows AI assistants and other applications to generate visual diagrams from textual descriptions using the Mermaid markdown syntax.
Features
- Converts Mermaid diagram code to PNG images or SVG files
- Supports multiple diagram themes (default, forest, dark, neutral)
- Customizable background colors
- Uses Puppeteer for high-quality headless browser rendering
- Implements the MCP protocol for seamless integration with AI assistants
- Flexible output options: return images/SVG directly or save to disk
- Error handling with detailed error messages
How It Works
The server uses Puppeteer to launch a headless browser, render the Mermaid diagram to SVG, and optionally capture a screenshot of the rendered diagram. The process involves:
- Launching a headless browser instance
- Creating an HTML template with the Mermaid code
- Loading the Mermaid.js library
- Rendering the diagram to SVG
- Either saving the SVG directly or taking a screenshot as PNG
- Either returning the image/SVG directly or saving it to disk
Requirements
- Node.js 22.12.0 or later
Security notice: versions before 0.3.0 depend on Puppeteer and Mermaid releases with known vulnerabilities. Please upgrade to 0.3.0 or later. The configurations below use
@latestsonpxpicks up new releases.
Build
npx tsc
Usage
Use with Claude desktop
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": ["-y", "@peng-shawn/mermaid-mcp-server@latest"]
}
}
}
Use with Cursor and Cline
env CONTENT_IMAGE_SUPPORTED=false npx -y @peng-shawn/mermaid-mcp-server@latest
You can find a list of mermaid diagrams under ./diagrams, they are created using Cursor agent with prompt: “generate mermaid diagrams and save them in a separate diagrams folder explaining how renderMermaidPng work”
Run with inspector
Run the server with inspector for testing and debugging:
npx @modelcontextprotocol/inspector node dist/index.js
The server will start and listen on stdio for MCP protocol messages.
Learn more about inspector here.
Installing via Smithery
To install Mermaid Diagram Generator for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @peng-shawn/mermaid-mcp-server --client claude
Docker and Smithery Environments
When running in Docker containers (including via Smithery), you may need to handle Chrome dependencies:
-
The server now attempts to use Puppeteer’s bundled browser by default
-
If you encounter browser-related errors, you have two options:
Option 1: During Docker image build:
- Set
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=truewhen installing Puppeteer
- Set
Установка
npx -y @peng-shawn/mermaid-mcp-server@latestКонфигурация
{
"mcpServers": {
"mermaid": {
"command": "npx",
"args": ["-y", "@peng-shawn/mermaid-mcp-server@latest"]
}
}
}