Excalidraw MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Supports containerized deployment of the MCP server for simplified integration and consistent environment.

  • Enables creation, modification, and manipulation of Excalidraw diagrams, including element control, grouping, alignment, and resource management.

  • Provides installation and dependency management through npm, allowing users to easily set up and run the MCP server.

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

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

特征

  • 完整的 Excalidraw 元素控制:创建、更新、删除和查询任何 Excalidraw 元素
  • 高级元素操作:分组、对齐、分布、锁定和解锁元素
  • 资源管理:访问和修改场景信息、库、主题和元素
  • 轻松集成:可与 Claude Desktop 和其他 LLM 平台配合使用
  • Docker 支持:使用容器化选项进行简单部署

API 工具参考

元素创建和修改

  • 创建元素
    • 创建一个新的 Excalidraw 元素(矩形、椭圆形、菱形等)
    • 所需输入: typexy坐标
    • 可选输入:尺寸、颜色、样式属性
  • 更新元素
    • 通过 ID 更新现有的 Excalidraw 元素
    • 必需输入:要更新的元素的id
    • 可选输入:要修改的任何元素属性
  • 删除元素
    • 删除 Excalidraw 元素
    • 必需输入:要删除的元素的id
  • 查询元素
    • 具有可选过滤功能的查询元素
    • 可选输入:按元素类型过滤的type ,使用键值对filter对象

资源管理

  • 获取资源
    • 获取特定资源,例如场景信息或所有元素
    • 必需输入: resource类型(场景、库、主题、元素)

元素组织

  • 组元素
    • 将多个元素组合在一起
    • 必需输入:要分组的元素 ID 的elementIds数组
  • 取消分组元素
    • 取消元素组组合
    • 必填输入:要取消分组的组的groupId
  • 对齐元素
    • 根据指定的对齐方式对齐多个元素
    • 必需输入: elementIds数组和alignment (左、中、右、上、中、下)
  • 分发元素
    • 在空间中均匀分布元素
    • 必需输入: elementIds数组和direction (水平或垂直)
  • 锁定元素
    • 锁定元素以防止修改
    • 必需输入:要锁定的元素的elementIds数组
  • 解锁元素
    • 解锁元素以允许修改
    • 必需输入:要解锁的元素的elementIds数组

与 Claude Desktop 集成

要将此服务器与 Claude Desktop 应用程序一起使用,请将以下配置添加到claude_desktop_config.json的“mcpServers”部分:

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

与 Cursor 集成

要将此服务器与 Cursor 一起使用,请在工作区中创建具有以下配置的.cursor/mcp.json文件:

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

请确保:

  1. /path/to/your/directory替换为 mcp_excalidraw 安装的实际绝对路径
  2. 如果.cursor目录不存在,则创建它
  3. 确保index.js的路径正确且文件存在

Docker 集成

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

安装指南

NPM 安装

# Install dependencies npm install # Start the server npm start

Docker 安装

# Build the Docker image docker build -t mcp/excalidraw . # Run the container docker run -i --rm mcp/excalidraw

配置选项

可以使用以下环境变量配置服务器:

  • LOG_LEVEL - 设置日志级别(默认值:“info”)
  • DEBUG - 启用调试模式(默认值:“false”)
  • DEFAULT_THEME - 设置默认主题(默认值:“light”)

使用示例

以下是一些如何使用 Excalidraw MCP 服务器的实际示例:

创建矩形元素

{ "type": "rectangle", "x": 100, "y": 100, "width": 200, "height": 100, "backgroundColor": "#ffffff", "strokeColor": "#000000", "strokeWidth": 2, "roughness": 1 }

查询特定元素

{ "type": "rectangle", "filter": { "strokeColor": "#000000" } }

对多个元素进行分组

{ "elementIds": ["elem1", "elem2", "elem3"] }

执照

此 Excalidraw MCP 服务器采用 MIT 许可证。您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详细信息,请参阅项目存储库中的 LICENSE 文件。

ID: hhg9min24v