MCP Sequence Diagram Server

MCP Sequence Diagram Server

Generates sequence diagram images from Mermaid syntax or natural language descriptions, supporting multiple output formats (SVG, PNG) with customizable themes and dimensions.

Category
访问服务器

README

MCP Sequence Diagram Server

A Model Context Protocol (MCP) server that generates sequence diagram images using Mermaid syntax.

Features

  • Generate sequence diagrams from Mermaid syntax
  • Convert natural language descriptions to sequence diagrams
  • Support for multiple output formats (SVG, PNG)
  • Customizable themes and dimensions
  • Syntax validation
  • File output with custom naming

Installation

  1. Clone or create the project directory:
mkdir mcp-sequence-diagram-server
cd mcp-sequence-diagram-server
  1. Install dependencies:
npm install
  1. Make the script executable:
chmod +x index.js

Usage

As MCP Server

Add to your MCP client configuration:

{
  "mcpServers": {
    "sequence-diagram": {
      "command": "node",
      "args": ["index.js"],
      "cwd": "/path/to/your/mcp-sequence-diagram-server"
    }
  }
}

Available Tools

1. generate_sequence_diagram

Generate a sequence diagram from Mermaid syntax.

Parameters:

  • diagram (required): Mermaid sequence diagram syntax
  • format (optional): Output format ('svg' or 'png', default: 'svg')
  • filename (optional): Custom filename for output
  • width (optional): Image width in pixels (default: 800)
  • height (optional): Image height in pixels (default: 600)
  • theme (optional): Mermaid theme ('default', 'dark', 'forest', 'neutral')

Example:

{
  "diagram": "sequenceDiagram\n    Alice->>Bob: Hello Bob, how are you?\n    Bob-->>Alice: Great!",
  "format": "svg",
  "filename": "greeting_sequence"
}

2. create_diagram_from_description

Create a sequence diagram from natural language description.

Parameters:

  • description (required): Natural language description
  • participants (optional): Array of participant names
  • format (optional): Output format ('svg' or 'png')
  • filename (optional): Custom filename

Example:

{
  "description": "User logs in. Server validates credentials. Server returns authentication token.",
  "participants": ["User", "Server"],
  "format": "png"
}

3. validate_mermaid_syntax

Validate Mermaid sequence diagram syntax.

Parameters:

  • diagram (required): Mermaid syntax to validate

Mermaid Sequence Diagram Syntax

Basic Syntax

sequenceDiagram
    participant A as Alice
    participant B as Bob
    
    A->>B: Hello Bob, how are you?
    B-->>A: Great!
    A-)B: See you later!

Message Types

  • A->>B: message - Solid arrow (synchronous)
  • A-->>B: message - Dashed arrow (asynchronous response)
  • A-)B: message - Open arrow (asynchronous)
  • A-xB: message - Cross arrow (lost message)

Advanced Features

sequenceDiagram
    participant C as Client
    participant S as Server
    participant D as Database
    
    C->>S: Login Request
    
    alt successful case
        S->>D: Query User
        D-->>S: User Data
        S-->>C: Login Success
    else failure case
        S-->>C: Login Failed
    end
    
    Note over C,S: Session established
    
    loop every minute
        C->>S: Heartbeat
        S-->>C: ACK
    end

Examples

Example 1: API Authentication Flow

{
  "diagram": `sequenceDiagram
    participant Client
    participant API
    participant Auth
    participant Database
    
    Client->>API: POST /login
    API->>Auth: Validate credentials
    Auth->>Database: Query user
    Database-->>Auth: User data
    Auth-->>API: Token
    API-->>Client: 200 OK + JWT`,
  "format": "svg",
  "filename": "auth_flow"
}

Example 2: Natural Language

{
  "description": "Customer places order. System checks inventory. Payment is processed. Order confirmation is sent.",
  "participants": ["Customer", "System", "Payment", "Inventory"],
  "format": "png"
}

Development

Running in Development Mode

npm run dev

Testing the Server

You can test the server using any MCP client or by running it directly:

node index.js

Troubleshooting

Common Issues

  1. Puppeteer Installation: If Puppeteer fails to install, try:
npm install puppeteer --unsafe-perm=true --allow-root
  1. Linux Dependencies: On Linux, you may need additional packages:
sudo apt-get install -y libgbm-dev gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
  1. Memory Issues: For large diagrams, you may need to increase Node.js memory:
node --max-old-space-size=4096 index.js

License

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选