Skip to main content
Glama

diag2md-mcp

Model Context Protocol (MCP) 服务器,为 AI 编码智能体提供 Draw.io C4 和 UML 架构约束以及图表转换能力。

GitHub Release License: MIT TypeScript

diag2md-mcp 通过将 C4 和 UML 图实时转换为结构化的 Mermaid Markdown,在 Draw.io 架构图(.xml.drawio)与 AI 编码智能体(如 Antigravity、Cursor、Claude Desktop 和 VS Code MCP 客户端)之间架起桥梁。

diag2md 提供支持。


主要功能

  • 自动工作区发现:扫描项目目录,查找与可配置的 glob 模式(**/architecture/**/*.xml**/*.drawio)匹配的 Draw.io 图表文件。

  • 高性能内存中转换:在内存中将 Draw.io XML 模型转换为 Mermaid C4 & UML Markdown,避免子 shell 进程生成开销。

  • AI 上下文提供器(convert_diagrams_read:动态读取并转换图表,在聊天会话期间直接为 AI 编码助手提供丰富的架构上下文。

  • 批量图表同步(convert_diagrams_write:通过在图表源文件旁生成 .md 文件,使架构文档保持最新。


Related MCP server: drawio-mcp

快速开始

通过 npx 运行

你可以直接运行 MCP 服务器,无需预先安装:

npx -y diag2md-mcp

全局安装

npm install -g diag2md-mcp

MCP 服务器配置

要将 diag2md-mcp 连接到您喜欢的 AI 助手或 MCP 客户端,请将服务器添加到您的客户端配置文件中(例如 mcp_config.jsonclaude_desktop_config.json、Cursor 或 Antigravity 的 MCP 设置)。

推荐方案(全局安装的包)

{
  "mcpServers": {
    "diag2md-mcp": {
      "command": "diag2md-mcp"
    }
  }
}

备选方案:本地构建源码

{
  "mcpServers": {
    "diag2md-mcp": {
      "command": "node",
      "args": ["/path/to/diag2md-mcp/dist/index.js"]
    }
  }
}

备选方案:通过 npx 按需运行

{
  "mcpServers": {
    "diag2md-mcp": {
      "command": "npx",
      "args": ["-y", "diag2md-mcp"]
    }
  }
}

MCP 工具参考

diag2md-mcp 向 AI 编码智能体提供 3 个核心工具:

工具名称

描述

参数

list_diagrams

发现工作区中与 glob 模式匹配的所有 Draw.io 架构图表文件(.xml.drawio)。

patterns (可选 string[])ignore (可选 string[])

convert_diagrams_write

批量扫描与 glob 模式匹配的工作区图表文件,进行转换,并将更新后的 .md 文件写入磁盘。

patterns (可选 string[])diagramType (可选 "c4" | "uml")

convert_diagrams_read

批量扫描工作区图表文件,并直接将转换后的 Mermaid Markdown 作为上下文返回给 AI 助手。

patterns (可选 string[])diagramType (可选 "c4" | "uml")


服务器配置

MCP 服务器设置可以通过环境变量进行自定义:

环境变量

描述

默认值

DIAG2MD_PATTERNS

用于发现图表文件的逗号分隔 glob 模式。

**/architecture/**/*.xml, **/architecture/*.xml, **/*.drawio

DIAG2MD_IGNORE

文件发现期间要忽略的逗号分隔 glob 模式。

**/node_modules/**, **/dist/**, **/.git/**

DIAG2MD_TYPE

默认转换图表类型(c4uml)。

c4

使用 env 模式的配置示例

您可以直接在 MCP 服务器 JSON 配置中使用 env 块配置自定义搜索模式:

{
  "mcpServers": {
    "diag2md-mcp": {
      "command": "diag2md-mcp",
      "env": {
        "DIAG2MD_PATTERNS": "**/architecture/**/*.xml, **/docs/**/*.drawio",
        "DIAG2MD_IGNORE": "**/tmp/**, **/node_modules/**",
        "DIAG2MD_TYPE": "c4"
      }
    }
  }
}

使用 patterns 的动态工具调用示例

AI 助手或工具还可以在每次请求时动态覆盖搜索模式:

{
  "name": "convert_diagrams_read",
  "arguments": {
    "patterns": [
      "**/architecture/**/*.xml",
      "**/docs/**/*.drawio"
    ]
  }
}

开发

# Clone the repository
git clone https://github.com/diag2md/diag2md-mcp.git
cd diag2md-mcp

# Install dependencies
npm install

# Build TypeScript to JavaScript dist/
npm run build

# Run unit tests
npm run test

# Run type checker
npm run typecheck

许可证

MIT © polymatic.ventures

Install Server
F
license - not found
A
quality
B
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
    A
    maintenance
    Enables AI agents to programmatically create, modify, and analyze Draw.io diagrams through the Model Context Protocol. Supports generating architectural diagrams, flowcharts, and visualizations with bidirectional communication between AI systems and Draw.io.
    13
    74
    1,443
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables AI assistants to generate professional UML diagrams (class, use case, activity, sequence) from natural language descriptions, producing editable .drawio files compatible with diagrams.net.
    7
    74
    ISC

View all related MCP servers

Related MCP Connectors

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

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

  • AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).

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/diag2md/diag2md-mcp'

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