diag2md-mcp
Officialdiag2md-mcp
Model Context Protocol (MCP) 服务器,为 AI 编码智能体提供 Draw.io C4 和 UML 架构约束以及图表转换能力。
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-mcpMCP 服务器配置
要将 diag2md-mcp 连接到您喜欢的 AI 助手或 MCP 客户端,请将服务器添加到您的客户端配置文件中(例如 mcp_config.json、claude_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 个核心工具:
工具名称 | 描述 | 参数 |
| 发现工作区中与 glob 模式匹配的所有 Draw.io 架构图表文件( |
|
| 批量扫描与 glob 模式匹配的工作区图表文件,进行转换,并将更新后的 |
|
| 批量扫描工作区图表文件,并直接将转换后的 Mermaid Markdown 作为上下文返回给 AI 助手。 |
|
服务器配置
MCP 服务器设置可以通过环境变量进行自定义:
环境变量 | 描述 | 默认值 |
| 用于发现图表文件的逗号分隔 glob 模式。 |
|
| 文件发现期间要忽略的逗号分隔 glob 模式。 |
|
| 默认转换图表类型( |
|
使用 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许可证
Available Tools
3 toolsconvert_diagrams_readA
Batch scan and convert all workspace diagram files (.xml, .drawio) into Mermaid Markdown, returning their content directly as AI context.
Inputs: patterns, diagramType.
convert_diagrams_writeA
Batch scan workspace diagrams matching glob patterns and convert them to updated .md files on disk.
Inputs: patterns, diagramType.
list_diagramsA
Discover all Draw.io architecture diagram files (.xml, .drawio) in the workspace using glob patterns.
Inputs: ignore, patterns.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
list_diagrams is clearly discovery-only, while the two convert tools are separated by output behavior: _write persists .md files to disk and _read returns content as AI context. There is no meaningful overlap between any pair.
All tool names follow a consistent verb_noun pattern in lowercase snake_case, using the same 'diagrams' resource. The _read/_write suffixes are a coherent way to distinguish output modes, and list_diagrams fits the pattern as an independent discovery action.
Three tools is a well-scoped set for a focused converter utility: discover source files, convert to files, and convert to context. Each tool addresses a distinct workflow step without unnecessary expansion.
The core workflow of finding Draw.io diagrams and converting them to Mermaid Markdown is fully covered in both output modes (disk and context). No obvious dead ends or missing lifecycle operations are apparent for this narrow domain.
Maintenance
Related MCP Connectors
Draw architecture diagrams, UML, planning boards and clickable wireframes from your AI assistant.
Software diagrams for developers, teams and agents — give your AI agents diagramming superpowers.
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…
Related MCP Servers
- AlicenseBqualityAmaintenanceEnables 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.131,503MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to generate professional UML diagrams (class, use case, activity, sequence) from natural language descriptions, producing editable .drawio files compatible with diagrams.net.7MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, update, and delete Draw.io diagrams, allowing automated generation of architectural diagrams, flowcharts, and visual documentation.MIT
- AlicenseAqualityBmaintenanceEnables AI coding agents to list, read, create, update, delete, and render PlantUML and Mermaid diagrams, and check them against the actual codebase to detect architecture drift.15100 npm1MIT