Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Validates and parses Draw.io XML syntax, enabling analysis and verification of diagram structures, especially for AI-generated content.

README.md

Draw.io Parser MCP Server

一个用于验证和分析 Draw.io XML 语法的 MCP (Model Context Protocol) 服务器,专为检查 AI 生成的 Draw.io 图表内容设计。

功能特性

  • 语法验证 - 检查 Draw.io XML 的语法正确性,发现错误和警告
  • 结构解析 - 解析图表结构,提取单元格、边、图层等信息
  • 图表分析 - 完整分析图表,同时返回验证结果和结构信息
  • 摘要统计 - 快速获取图表统计信息(形状数、连接数等)
  • 单元格查询 - 列出所有单元格或按 ID 查找特定单元格

安装

使用 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 工具

| 工具名 | 描述 | |--------|------| | validate_drawio | 验证 Draw.io XML 语法和结构,返回错误、警告和建议 | | parse_drawio | 解析 Draw.io XML,提取单元格、边、图层和统计信息 | | analyze_drawio | 完整分析:同时执行验证和解析 | | get_diagram_summary | 获取图表摘要统计信息 | | list_cells | 列出图表中所有单元格(形状和连接) | | find_cell | 按 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_SYNTAX_ERROR | XML 语法错误 | | INVALID_ROOT | 无效的根元素 | | NO_DIAGRAM | 缺少 diagram 元素 | | MISSING_ROOT_CELL | 缺少 id="0" 的根单元格 | | MISSING_DEFAULT_PARENT | 缺少 id="1" 的默认父单元格 | | INVALID_PARENT | 引用了不存在的父单元格 | | INVALID_EDGE_SOURCE | 边的源单元格不存在 | | INVALID_EDGE_TARGET | 边的目标单元格不存在 | | NEGATIVE_WIDTH/HEIGHT | 负数的宽度或高度 |

依赖

  • 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

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Other servers.