Skip to main content
Glama
Excalidraw MCP Server

Excalidraw MCP Server

Excalidraw MCP 服务器:用于 LLM 集成的强大绘图 API

全面的模型上下文协议 (MCP) 服务器,可实现与 Excalidraw 图表和绘图的无缝交互。该服务器通过结构化、开发人员友好的 API,为 LLM(大型语言模型)提供创建、修改、查询和操作 Excalidraw 绘图的功能。

特征

  • 完整的 Excalidraw 元素控制
    创建、更新、删除和查询任何 Excalidraw 元素(矩形、椭圆、菱形、文本、箭头等),包括支持:

    • 位置( x , y )

    • 尺寸( width , height )

    • 样式( backgroundColor 、 strokeColor 、 strokeWidth 、 roughness 、 opacity )

    • 文本( text , fontSize , fontFamily )

    • 线几何( points )

    • 锁定( locked标志)

  • 高级元素操作
    对元素进行分组、取消分组、对齐、分布、锁定和解锁。

  • 场景和应用状态管理

    • 跟踪和修改场景级状态: theme 、 viewBackgroundColor 、 viewport (滚动和缩放)、 selectedElements 、 groups 。

    • 检索所有元素或单个场景属性的库。

  • 保存场景
    将当前场景(元素 + appState)导出到磁盘上的.excalidraw文件。

  • 资源管理
    访问和修改场景信息、元素库、主题和原始元素数据。

  • 轻松集成
    与 Claude Desktop、Cursor 以及任何其他支持 MCP 的 LLM 平台兼容。

  • Docker 支持
    简单的容器化部署,实现零依赖安装。


Related MCP server: Excalidraw MCP Server

API 工具参考

元素创建和修改

create_element

创建一个新的 Excalidraw 元素。

  • 输入

    {
      "type": "<element type>",
      "x": <number>,
      "y": <number>,
      "width": <number, optional>,
      "height": <number, optional>,
      "points": [{"x":<number>,"y":<number>}…],
      "backgroundColor": "<hex>",
      "strokeColor": "<hex>",
      "strokeWidth": <number>,
      "roughness": <number>,
      "opacity": <0–1>,
      "text": "<string>",
      "fontSize": <number>,
      "fontFamily": "<string>",
      "locked": <boolean>
    }
  • 输出

    { "id": "<generated‑id>", "type": "<element type>", "created": true }

update_element

更新现有元素的属性。

  • 输入

    {
      "id": "<element id>",
    }
  • 输出

    { "id": "<element id>", "updated": true, "version": <new‑version‑number> }

delete_element

从场景中移除一个元素。

  • 输入

    { "id": "<element id>" }
  • 输出

    { "id": "<element id>", "deleted": true }

query_elements

列出与可选过滤器匹配的元素。

  • 输入

    {
      "type": "<element type>",        
      "filter": { "<prop>": <value> }  
    }
  • 输出

    [ { /* element objects */ } … ]

资源管理

get_resource

检索场景或库信息。

  • 输入

    { "resource": "scene"|"library"|"theme"|"elements" }
  • 输出

    • 场景→ { theme, viewport: {x,y,zoom}, selectedElements: […] }

    • 库/元素→ { elements: [ … ] }

    • 主题→ { theme: "light"|"dark" }

元素组织

group_elements / ungroup_elements

对元素集合进行分组或取消分组。

  • 输入

    { "elementIds": ["id1","id2",…] }
    { "groupId": "<group id>" }
  • 输出

    { "groupId": "<new‑id>", "elementIds": […], "ungrouped": true? }

align_elements

将多个元素对齐到指定的边缘或中心。

  • 输入

    { "elementIds": […], "alignment": "left"|"center"|"right"|"top"|"middle"|"bottom" }
  • 输出
    { aligned: true, elementIds: […], alignment: "<alignment>" }

distribute_elements

水平或垂直均匀分布元素。

  • 输入

    { "elementIds": […], "direction": "horizontal"|"vertical" }
  • 输出
    { distributed: true, elementIds: […], direction: "<direction>" }

lock_elements / unlock_elements

防止或允许编辑元素。

  • 输入

    { "elementIds": [… ] }
  • 输出
    { locked: true|false, elementIds: […] }

场景管理

save_scene

将当前场景(元素 + appState)导出到.excalidraw文件。

  • 输入

    { "filename": "<optional, must end with .excalidraw>" }
  • 输出
    Scene saved successfully to <filename>或出现错误消息。


集成示例

克劳德桌面

"mcpServers": {
  "excalidraw": {
    "command": "node",
    "args": ["src/index.js"],
    "env": {
      "LOG_LEVEL": "info",
      "DEBUG": "false"
    }
  }
}

光标

创建.cursor/mcp.json :

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/src/index.js"],
      "env": { "LOG_LEVEL": "info", "DEBUG": "false" }
    }
  }
}

Docker

docker run -i --rm mcp/excalidraw

或者在 MCP 配置中:

"mcpServers": {
  "excalidraw": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/excalidraw"],
    "env": { "LOG_LEVEL": "info", "DEBUG": "false" }
  }
}

安装指南

# Install dependencies
npm install

# Run development server
npm start

Docker

docker build -t mcp/excalidraw .
docker run -i --rm mcp/excalidraw

配置选项

通过.env或容器中的环境变量设置:

  • LOG_LEVEL — 日志级别(默认值: "info" )

  • DEBUG — 调试模式( "true" / "false" ,默认值: "false" )

  • DEFAULT_THEME — 默认 UI 主题 ( "light" / "dark" ,默认值: "light" )


使用示例

创建并锁定矩形

{"type":"rectangle","x":50,"y":50,"width":100,"height":80,"backgroundColor":"#f3f3f3","strokeColor":"#333","locked":true}

{ "id":"abc123","type":"rectangle","created":true }

{"elementIds":["abc123"]}

将场景保存到文件

{"filename":"my_drawing.excalidraw"}

"Scene saved successfully to my_drawing.excalidraw"

Available Tools

12 tools
align_elementsC

Align elements to a specific position

Inputs: elementIds (required), alignment (required).

create_elementC

Create a new Excalidraw element

Inputs: type (required), x (required), y (required), width, +9 more.

delete_elementC

Delete an Excalidraw element

Inputs: id (required).

distribute_elementsD

Distribute elements evenly

Inputs: elementIds (required), direction (required).

get_resourceD

Get an Excalidraw resource

Inputs: resource (required).

group_elementsC

Group multiple elements together

Inputs: elementIds (required).

lock_elementsB

Lock elements to prevent modification

Inputs: elementIds (required).

query_elementsC

Query Excalidraw elements with optional filters

Inputs: type, filter.

save_sceneB

Saves the current Excalidraw elements and scene state to a .excalidraw file.

Inputs: filename.

ungroup_elementsB

Ungroup a group of elements

Inputs: groupId (required).

unlock_elementsB

Unlock elements to allow modification

Inputs: elementIds (required).

update_elementC

Update an existing Excalidraw element

Inputs: id (required), type, x, y, +10 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 12 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose targeting specific actions on Excalidraw elements or resources. There is no overlap between creation, deletion, updating, querying, grouping, locking, alignment, distribution, or file operations. The descriptions reinforce these distinct roles, making tool selection unambiguous.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using snake_case (e.g., create_element, delete_element, group_elements). The naming convention is uniform throughout the set, with verbs clearly indicating actions and nouns specifying targets, making the tools predictable and easy to understand.

    Tool Count5/5

    With 12 tools, the server is well-scoped for managing Excalidraw diagrams, covering essential operations like CRUD for elements, grouping, locking, alignment, distribution, querying, and file saving. Each tool serves a distinct and necessary function, with no redundancy or excessive complexity.

    Completeness5/5

    The tool set provides complete coverage for the Excalidraw domain, including full CRUD lifecycle for elements (create, query, update, delete), grouping/ungrouping, locking/unlocking, alignment/distribution, and scene saving. There are no obvious gaps; agents can perform all core diagram editing and management tasks without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers