drawio-parser-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@drawio-parser-mcpValidate this Draw.io XML for syntax errors"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Draw.io Parser MCP Server
一个用于验证和分析 Draw.io XML 语法的 MCP (Model Context Protocol) 服务器,专为检查 AI 生成的 Draw.io 图表内容设计。
功能特性
语法验证 - 检查 Draw.io XML 的语法正确性,发现错误和警告
结构解析 - 解析图表结构,提取单元格、边、图层等信息
图表分析 - 完整分析图表,同时返回验证结果和结构信息
摘要统计 - 快速获取图表统计信息(形状数、连接数等)
单元格查询 - 列出所有单元格或按 ID 查找特定单元格
Related MCP server: Draw.io Diagram Server
安装
使用 uv (推荐)
# 克隆项目
git clone https://github.com/dabian321/pyDrawioParserMCP.git
cd pyDrawioParserMCP
# 安装依赖
uv sync使用 pip
pip install -e .MCP 配置
将以下配置添加到你的 MCP 配置文件 (如 Claude Desktop 的 mcp.json):
{
"mcpServers": {
"drawio-parser-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/pyDrawioParserMCP",
"run",
"drawio-parser-mcp"
],
"env": {
"PYTHONIOENCODING": "utf-8"
}
}
}
}将
/path/to/pyDrawioParserMCP替换为项目实际路径
MCP 工具
工具名 | 描述 |
| 验证 Draw.io XML 语法和结构,返回错误、警告和建议 |
| 解析 Draw.io XML,提取单元格、边、图层和统计信息 |
| 完整分析:同时执行验证和解析 |
| 获取图表摘要统计信息 |
| 列出图表中所有单元格(形状和连接) |
| 按 ID 查找特定单元格 |
命令行使用
# 启动 MCP 服务器 (stdio 模式)
drawio-parser-mcp
# 验证单个文件
drawio-parser-mcp --check mydiagram.drawio
# 启用详细日志
drawio-parser-mcp -v使用示例
验证 AI 生成的 Draw.io 内容
from drawio_parser_mcp import DrawioValidator
validator = DrawioValidator()
xml_content = """
<mxfile>
<diagram id="test" name="Page-1">
<mxGraphModel>
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="Hello" style="rounded=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
"""
result = validator.validate(xml_content)
print(f"Valid: {result.valid}")
print(f"Errors: {result.error_count}, Warnings: {result.warning_count}")解析图表结构
from drawio_parser_mcp import DrawioParser
parser = DrawioParser()
structure = parser.parse(xml_content)
print(f"Pages: {len(structure.pages)}")
print(f"Total shapes: {structure.total_vertices}")
print(f"Total connections: {structure.total_edges}")项目结构
pyDrawioParserMCP/
├── src/drawio_parser_mcp/
│ ├── __init__.py # 包入口
│ ├── cli.py # 命令行接口
│ ├── server.py # MCP Server 实现
│ ├── parser.py # XML 解析器
│ ├── validator.py # 语法验证器
│ └── models.py # 数据模型
├── tests/ # 测试文件
├── architecture.drawio # 架构图
└── pyproject.toml # 项目配置验证规则
错误代码 | 描述 |
| XML 语法错误 |
| 无效的根元素 |
| 缺少 diagram 元素 |
| 缺少 id="0" 的根单元格 |
| 缺少 id="1" 的默认父单元格 |
| 引用了不存在的父单元格 |
| 边的源单元格不存在 |
| 边的目标单元格不存在 |
| 负数的宽度或高度 |
依赖
Python >= 3.10
mcp >= 1.0.0
pydantic >= 2.0.0
lxml >= 5.0.0
开发
# 安装开发依赖
uv sync --extra dev
# 运行测试
pytest
# 代码格式检查
ruff check src/License
MIT License
Available Tools
6 toolsanalyze_drawioB
Fully analyze Draw.io XML: validate syntax and parse structure. Returns both validation issues and parsed diagram structure.
| Name | Required | Description | Default |
|---|---|---|---|
| xml_content | Yes | The Draw.io XML content to analyze |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden. It clearly discloses that the tool validates and parses, and that it returns both validation issues and parsed structure. However, it does not explain error handling for malformed XML, whether any side effects occur, or how issues are represented.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two short clauses: it states what the tool does and what it returns. Both pieces of information earn their place, the core operation is front-loaded, and there is no fluff or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter analysis tool, the description covers the operation and return value sufficiently to make a call. However, with no output schema and no annotations, it leaves the return format vague and does not explain how this tool relates to the sibling validate and parse tools, so an agent may not know when this is the right choice.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% for the single xml_content parameter, so the schema already documents it. The description adds no substantial meaning beyond restating that the content is Draw.io XML, which matches the schema. The baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific resource (Draw.io XML) and states the exact operations: validate syntax and parse structure. It also says the tool returns both validation issues and parsed structure, which distinguishes it from the separate validate_drawio and parse_drawio siblings, though it does not name them explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance about when to use analyze_drawio versus validate_drawio, parse_drawio, or the other sibling tools. The description implies it combines validation and parsing, but it never states that an agent should choose this tool when it needs both results together.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
find_cellA
Find a specific cell by ID in a Draw.io diagram.
| Name | Required | Description | Default |
|---|---|---|---|
| cell_id | Yes | The ID of the cell to find | |
| xml_content | Yes | The Draw.io XML content |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral disclosure burden. 'Find' implies a read-only lookup, but the description does not state what happens when the cell is not found, whether the search is recursive across the whole diagram, or what output the agent should expect.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is an 11-word sentence with no wasted words. It front-loads the action and resource while staying immediately parsable.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple two-parameter lookup, the description is usable, but there is no output schema, no annotations, and no usage routing to alternatives. Return format and error behavior are left unspecified, which makes the description adequate yet incomplete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already describes both parameters with 100% coverage, including plain descriptions for xml_content and cell_id. The description adds little beyond identifying cell_id as the lookup key, which is already evident from the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a precise operation — find a specific cell by ID — on a clear resource, a Draw.io diagram. The 'specific... by ID' qualifier distinguishes it from list_cells, which would return cells more generally.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The intended use is implied: call this when you have a cell_id and need that specific cell from XML content. However, it does not explicitly say when to use this tool instead of siblings like list_cells or when not to use it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_diagram_summaryA
Get a concise summary of a Draw.io diagram. Returns statistics and overview without full structure details.
| Name | Required | Description | Default |
|---|---|---|---|
| xml_content | Yes | The Draw.io XML content to summarize |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It explicitly states what is returned (statistics and overview) and what is not returned (full structure details), giving the agent a clear expectation of the tool's scope. It does not mention error behavior or input validation, but the operation is a simple read-style summary with no side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is one tightly written sentence that front-loads the primary purpose and immediately clarifies the key limitation. Every word earns its place; there is no repetition or filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with one parameter and no output schema, the description adequately explains what the agent can expect: a concise summary with statistics and overview, but not full structure. It could be slightly richer by hinting at what kinds of statistics are included, but given the tool's low complexity, the description is sufficient for correct invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% and the only parameter, xml_content, is adequately documented as 'The Draw.io XML content to summarize'. The description adds no additional detail about expected encoding, size limits, or format nuances, so it provides no value beyond the schema—but the schema already covers the parameter sufficiently.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states a specific verb ('Get'), a resource ('Draw.io diagram'), and a concrete deliverable ('concise summary', 'statistics and overview'). It also distinguishes itself from structure-focused tools by explicitly saying it returns content 'without full structure details', which differentiates it from parse_drawio and list_cells.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'without full structure details' implies you should use this tool when you only need an overview, and that you would use parse_drawio or list_cells if you need the full structure. However, it never explicitly states when to choose this tool over the siblings, nor does it name any alternative or exclusion condition.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_cellsA
List all cells (shapes and connections) in a Draw.io diagram. Returns cell IDs, types, labels, and connections.
| Name | Required | Description | Default |
|---|---|---|---|
| xml_content | Yes | The Draw.io XML content | |
| include_system_cells | No | Include system cells (id 0, 1). Default: false |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry the full burden of behavioral disclosure. It communicates that the tool is read-only in nature ('List', 'Returns') and what output to expect, which is useful. However, it does not disclose behavior around malformed XML, how system cells are treated beyond the schema default, or any limitations on result size or structure.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences with no filler. The core action and output contract are front-loaded, and every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite lacking an output schema and annotations, the description states the input (implicitly the diagram XML), the scope of cells returned, and the output fields. It is nearly complete for a simple listing tool; the main gap is usage routing among siblings and error behavior, which are minor for this operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents both parameters adequately. The description does not add additional meaning about xml_content or include_system_cells beyond what the schema provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the operation as listing all cells in a Draw.io diagram, specifies that this includes shapes and connections, and states the returned fields (IDs, types, labels, connections). This makes the tool's purpose distinct from siblings like validate_drawio, parse_drawio, and find_cell.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives no explicit guidance on when to use this tool versus alternatives such as find_cell or get_diagram_summary. It implies a broad listing use case but does not state when a more targeted or analytical sibling would be preferable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
parse_drawioB
Parse Draw.io XML and extract diagram structure. Returns cells, edges, layers, and statistics.
| Name | Required | Description | Default |
|---|---|---|---|
| xml_content | Yes | The Draw.io XML content to parse |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full behavioral burden. It conveys that the operation is read-only and non-destructive via the verb 'Parse,' and it discloses the return payload ('cells, edges, layers, and statistics'). However, it does not address error behavior for malformed XML, size limits, or what happens when required elements are absent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with no filler. The verb and resource are front-loaded, and the second sentence lists the concrete output items, giving an agent actionable information in the fewest possible words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter tool with no output schema, the description is nearly complete: it names the input and enumerates the return categories. It lacks error-handling details and sibling differentiation, but those gaps are minor relative to the tool's low complexity, and the lack of an output schema is partially compensated by the explicit return enumeration.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the single parameter xml_content is already documented in the schema. The description's use of 'Draw.io XML' reinforces the parameter's meaning but adds no new semantic detail such as expected encoding, document size limits, or accepted XML variants. The baseline 3 applies since the schema handles the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Parse'), a resource ('Draw.io XML'), and the extracted output ('cells, edges, layers, and statistics'). This distinguishes it from validate_drawio, list_cells, and find_cell, but it does not explicitly differentiate itself from analyze_drawio or get_diagram_summary, which could plausibly produce the same 'statistics' and structural output.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is given on when to use this tool versus its siblings. The description never mentions analyze_drawio, validate_drawio, or get_diagram_summary, so an agent has no basis for deciding whether parsing, validating, analyzing, or summarizing is the right call for a given task.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
validate_drawioA
Validate Draw.io XML syntax and structure. Returns validation result with errors, warnings, and suggestions.
| Name | Required | Description | Default |
|---|---|---|---|
| xml_content | Yes | The Draw.io XML content to validate |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries the full behavioral disclosure burden. It clearly states that validation covers syntax and structure and that the result includes errors, warnings, and suggestions, giving the agent a solid contract. It does not explicitly state that there are no side effects, but validation is inherently non-mutating.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no waste. It front-loads the verb and resource, then states the return value components. Every word contributes to the agent's understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter validation tool with no output schema, the description covers the essential input/output contract: what is validated and what result categories to expect. It lacks explicit response format details and sibling-tool comparison, but these are minor for the tool's simplicity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the parameter already carries full meaning ('The Draw.io XML content to validate'). The tool description adds no extra parameter-level detail such as size limits, encoding expectations, or formatting requirements, so baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Validate') and a clear resource ('Draw.io XML syntax and structure'), and it states what the result contains (errors, warnings, suggestions). This clearly differentiates it from siblings like parse_drawio and analyze_drawio without needing to open the schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The purpose strongly implies when to use it — when Draw.io XML needs syntax/structure validation — but there is no explicit guidance about when not to use it or which sibling tool to prefer for parsing or analysis. The context is clear, but no alternative routing is provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v1.0.0- First observed
analyze_drawio - First observed
find_cell - First observed
get_diagram_summary - First observed
list_cells - First observed
parse_drawio - First observed
validate_drawio
TDQS
Scored across 6 tools
Most tools target distinct operations (validate, parse, summarize, list, find), but analyze_drawio overlaps with both validate_drawio and parse_drawio, creating two potential points of confusion. The descriptions make the distinctions clear, so the ambiguity is limited.
All tool names follow a consistent verb_noun pattern using snake_case (validate_drawio, parse_drawio, analyze_drawio, get_diagram_summary, list_cells, find_cell). The verbs are distinct and appropriate for each operation.
Six tools is a well-scoped set for a Draw.io parser. Each tool serves a clear purpose, and the combination covers validation, parsing, summarization, listing, and lookup without unnecessary bloat.
The tool surface covers the full read-only lifecycle for a diagram parser: validation, structural parsing, combined analysis, summary statistics, cell listing, and targeted lookup. There are no obvious missing operations for the stated purpose.
Maintenance
Related MCP Connectors
Render, validate, encode/decode PlantUML diagram-as-code; 22 diagram types. Free, no auth.
Deterministic validation for AI-generated artifacts: JSON Schema, OpenAPI response, SQL syntax.
Generate cloud architecture diagrams, flowcharts, and sequence diagrams.
Generate dynamic Mermaid diagrams and charts with AI assistance. Customize styles and export diagr…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceValidates Mermaid diagrams with comprehensive grammar parsing supporting 28+ diagram types. Processes markdown files, ZIP archives, and direct input with detailed error reporting and enterprise-grade performance capabilities.44 npm2Apache 2.0
- AlicenseBqualityCmaintenanceGenerates professional Draw.io compatible diagrams (flowcharts, sequence diagrams, network diagrams, and custom diagrams) from natural language prompts, outputting XML files that can be opened directly in Draw.io.1122 npm6MIT
- 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.1358 npm1,474MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to create and edit draw.io diagrams programmatically, supporting a wide range of diagram types and styles.61 PyPI5MIT