Skip to main content
Glama

Draw.io MCP 服务器

让我们使用最广泛的绘图工具 Draw.io (Diagrams.net) 来进行一些“氛围绘图”。

Discord channel Build project Version

主要亮点

  • 从/向 XML、SVG(嵌入 XML)或 PNG(嵌入 XML)导入和导出图表 v2.0.0

  • 具有航点和自动自连接器路由的边缘几何控制 v2.0.0

  • 用于嵌套形状和分组的父子关系 v2.0.0

  • 在同一个单体仓库中统一服务器和扩展 v2.0.0

  • 内置 Draw.io 编辑器 - 无需浏览器扩展 v1.8.0

  • MCP 服务器,允许 AI 智能体控制 Draw.io 图表

  • 通过 MCP 工具进行程序化图表创建、检查和修改

  • 用于复杂图表的图层管理

  • 适用于任何 MCP 客户端(Claude Desktop、Claude Code、Zed、Codex 等)

Related MCP server: Draw.io MCP Server

简介

Draw.io MCP 服务器为 AI 智能体带来了 Draw.io 绘图功能。它提供了可以创建、读取、更新和删除图表元素的 MCP 工具,让 AI 助手能够自动构建架构图、流程图和可视化文档。

有两种使用方式:

  1. 内置编辑器 - 服务器直接托管 Draw.io,可在浏览器中访问

  2. 浏览器扩展 - 通过扩展连接到在浏览器中运行的 Draw.io

要求

  • Node.js (v20 或更高版本) - MCP 服务器的运行时环境

  • MCP 客户端 - Claude Desktop、Claude Code、Zed、Codex、OpenCode 或任何兼容 MCP 的主机

对于内置编辑器

无需额外要求 - 使用 --editor 标志即可开箱即用。

对于浏览器扩展

可选

  • pnpm - 首选包管理器(npm 也可以正常工作)

快速入门

1. 配置您的 MCP 主机

将服务器添加到您的 MCP 客户端配置中:

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "drawio": {
      "command": "npx",
      "args": ["-y", "drawio-mcp-server", "--editor"]
    }
  }
}
claude mcp add-json drawio '{"type":"stdio","command":"npx","args":["-y","drawio-mcp-server","--editor"]}'

添加到 ~/.config/zed/settings.json:

{
  "context_servers": {
    "drawio": {
      "command": "npx",
      "args": ["-y", "drawio-mcp-server", "--editor"],
      "env": {}
    }
  }
}

编辑 ~/.codex/config.toml:

[mcp_servers.drawio]
command = "npx"
args = ["-y", "drawio-mcp-server", "--editor"]

添加到项目根目录下的 opencode.json 或 ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "drawio": {
      "type": "local",
      "command": ["npx", "-y", "drawio-mcp-server", "--editor"],
      "enabled": true
    }
  }
}

对于其他 MCP 客户端和详细配置(包括 pnpm 选项),请参阅 Configuration。

2. 打开编辑器

重启 MCP 主机后,打开:http://localhost:3000/

3. 开始绘图

您可以尝试以下示例提示词:

"创建一个事件驱动的架构图,显示一个带有生产者、消费者和三个后端服务的消息队列"

"绘制一个 CRUD API 图,包含一个数据库、API 网关和四个带有各自端点的微服务"

"添加一个名为 'Background' 的新图层并将所有装饰元素移动到该图层,然后为注释创建一个新图层"

您的 AI 助手现在可以使用 MCP 工具控制图表了。

功能

该服务器为以下内容提供 MCP 工具:

  • 图表检查 - 读取形状、图层和单元格属性

  • 图表修改 - 添加/编辑/删除形状、边缘和标签

  • 图层管理 - 创建、切换和组织图层

请参阅 Tools Reference 获取可用工具的完整列表。

安装

该服务器作为 MCP 主机的一部分运行。所有受支持客户端(Claude Desktop、Claude Code、Zed、Codex、oterm)的详细配置(包括 npm 和 pnpm 选项)可在 Configuration 中找到。

替代方案:浏览器扩展

除了内置编辑器外,您还可以使用 浏览器扩展 连接到在浏览器中运行的 Draw.io。这可以在有或没有 --editor 标志的情况下工作。

  1. 在浏览器中打开 Draw.io

  2. 安装 Draw.io MCP 浏览器扩展:

  3. 确保扩展已连接(图标上有绿色信号覆盖)

不带 --editor 的配置:

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

有关更多详细信息,请参阅 扩展文档。

相关资源

Configuration - CLI 标志和高级选项

Tools Reference - 完整的 MCP 工具文档

Troubleshooting

Prompt examples

Contributing

Architecture

Development

星标历史

评估

MSeeP.ai Security Assessment Badge

Available Tools

13 tools
add-cell-of-shapeC

This tool allows you to add new vertex cell (object) on the current page of a Draw.io diagram by its shape name. It accepts multiple optional input parameter.

Inputs: shape_name (required), x, y, width, +3 more.

add-edgeC

This tool creates an edge, sometimes called also a relation, between two vertexes (cells).

Inputs: source_id (required), target_id (required), text, style.

add-rectangleC

This tool allows you to add new Rectangle vertex cell (object) on the current page of a Draw.io diagram. It accepts multiple optional input parameter.

Inputs: x, y, width, height, +2 more.

delete-cell-by-idC

Deletes a cell, whether it is a vertex or edge.

Inputs: cell_id (required).

edit-cellA

Update properties of an existing vertex/shape cell by its ID. Only provided fields are modified; unspecified properties remain unchanged.

Inputs: cell_id (required), text, x, y, +3 more.

edit-edgeA

Update properties of an existing edge by its ID. Only provided fields are modified; unspecified properties remain unchanged.

Inputs: cell_id (required), text, source_id, target_id, +1 more.

get-selected-cellB

This tool allows you to retrieve selected cell (whether vertex or edge) on the current page of a Draw.io diagram. The response is a JSON containing attributes of the cell.

Inputs: no named parameters.

get-shape-by-nameA

Retrieve a specific shape by its name from all available shapes in the diagram's library. It returns the shape and also the category it belongs.

Inputs: shape_name (required).

get-shape-categoriesB

Retrieves available shape categories from the diagram's library. Library is split into multiple categories.

Inputs: no named parameters.

get-shapes-in-categoryC

Retrieve all shapes in the provided category from the diagram's library. A shape primarily contains style based on which you can create new vertex cells.

Inputs: category_id (required).

list-paged-modelA

Retrieves a paginated view of all cells (vertices and edges) in the current Draw.io diagram. This tool provides access to the complete model data with essential fields only, sanitized to remove circular dependencies and excessive data. It allows to filter based on multiple criteria and attribute boolean logic. Useful for programmatic inspection of diagram structure without overwhelming response sizes.

Inputs: page, page_size, filter.

set-cell-dataC

Sets or updates a custom attribute on an existing cell.

Inputs: cell_id (required), key (required), value (required).

set-cell-shapeC

Updates the visual style of an existing vertex cell to match a library shape by name.

Inputs: cell_id (required), shape_name (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 13 tools

    Disambiguation3/5

    The tools have clear purposes but some overlap exists, such as add-cell-of-shape and add-rectangle both adding vertex cells, which could cause confusion. However, descriptions help differentiate them by shape specificity, and most tools target distinct actions like editing, deleting, or retrieving cells.

    Naming Consistency4/5

    Tool names follow a consistent verb_noun pattern with minor deviations, such as list-paged-model using 'paged' instead of a direct noun. Most names are clear and readable, like delete-cell-by-id and get-shape-by-name, maintaining a predictable structure throughout the set.

    Tool Count5/5

    With 13 tools, the count is well-scoped for a diagram editing server, covering essential operations like adding, editing, deleting, and retrieving cells and shapes. Each tool earns its place by addressing specific needs in diagram manipulation without being overwhelming.

    Completeness4/5

    The toolset provides comprehensive coverage for diagram editing, including CRUD operations for cells and edges, shape management, and data inspection. Minor gaps exist, such as no direct tool for creating new pages or handling diagram-level properties, but agents can work around these with existing tools.

    Maintenance

    ActivityMaintained
    ResponsivenessMixed handling

    Related MCP Connectors

    Related MCP Servers