Excalidraw MCP server

Enables LLMs to create and manipulate Excalidraw diagrams through a Node.js API that provides tools for element creation, modification, querying, and organization for AI-assisted diagramming and visual collaboration.
Back to servers
Setup instructions
Provider
yctimlin
Release date
Mar 16, 2025
Language
TypeScript
Stats
261 stars

MCP Excalidraw Server combines Excalidraw's drawing capabilities with Model Context Protocol (MCP) integration, allowing AI agents to create and manipulate diagrams in real-time on a live canvas. This server enables both human users and AI systems to collaborate on visual diagrams with real-time synchronization.

Installation

Recommended: Local Development Setup

1. Clone the Repository

git clone https://github.com/yctimlin/mcp_excalidraw.git
cd mcp_excalidraw
npm install

2. Build the Frontend

npm run build

3. Start the System

Option A: Production Mode (Recommended)

# Start canvas server (serves frontend + API)
npm run canvas

Option B: Development Mode

# Start both canvas server and Vite dev server
npm run dev

4. Access the Canvas

Open your browser and navigate to:

http://localhost:3000

Alternative Installation Methods (In Development)

NPM Package (Beta)

# Currently debugging tool registration
npm install -g mcp-excalidraw-server
npx mcp-excalidraw-server

Docker Version (Coming Soon)

# Canvas sync improvements in progress
docker run -p 3000:3000 mcp-excalidraw-server

Usage Guide

For End Users

  1. Open the canvas at http://localhost:3000
  2. Check connection status (should show "Connected")
  3. AI agents can now create diagrams that appear in real-time
  4. Use "Clear Canvas" to remove all elements

For AI Agents (via MCP)

The MCP server provides these tools for creating visual diagrams:

Basic Element Creation

// Create a rectangle
{
  "type": "rectangle",
  "x": 100,
  "y": 100, 
  "width": 200,
  "height": 100,
  "backgroundColor": "#e3f2fd",
  "strokeColor": "#1976d2",
  "strokeWidth": 2
}

Create Text Elements

{
  "type": "text",
  "x": 150,
  "y": 125,
  "text": "Process Step",
  "fontSize": 16,
  "strokeColor": "#333333"
}

Create Arrows & Lines

{
  "type": "arrow",
  "x": 300,
  "y": 130,
  "width": 100,
  "height": 0,
  "strokeColor": "#666666",
  "strokeWidth": 2
}

Batch Creation for Complex Diagrams

{
  "elements": [
    {
      "type": "rectangle",
      "x": 100,
      "y": 100,
      "width": 120,
      "height": 60,
      "backgroundColor": "#fff3e0",
      "strokeColor": "#ff9800"
    },
    {
      "type": "text", 
      "x": 130,
      "y": 125,
      "text": "Start",
      "fontSize": 16
    }
  ]
}

Integration with Claude Desktop

Recommended: Using Local Installation

For the local development version (most stable), add this configuration to your claude_desktop_config.json:

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"]
    }
  }
}

Important: Replace /absolute/path/to/mcp_excalidraw with the actual absolute path to your cloned repository.

Alternative Configurations (Beta)

NPM Package (Beta Testing)

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

Docker Version (Coming Soon)

{
  "mcpServers": {
    "excalidraw": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "mcp-excalidraw-server"]
    }
  }
}

Integration with Other Tools

Cursor IDE

Add to your .cursor/mcp.json:

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"]
    }
  }
}

VS Code MCP Extension

For VS Code MCP extension, add to your settings:

{
  "mcp": {
    "servers": {
      "excalidraw": {
        "command": "node",
        "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"]
      }
    }
  }
}

Environment Variables

Variable Default Description
EXPRESS_SERVER_URL http://localhost:3000 Canvas server URL for MCP sync
ENABLE_CANVAS_SYNC true Enable/disable canvas synchronization
DEBUG false Enable debug logging
PORT 3000 Canvas server port
HOST localhost Canvas server host

Available MCP Tools

Element Management

  • create_element - Create any type of Excalidraw element
  • update_element - Modify existing elements
  • delete_element - Remove elements
  • query_elements - Search elements with filters

Batch Operations

  • batch_create_elements - Create complex diagrams in one call

Element Organization

  • group_elements - Group multiple elements
  • ungroup_elements - Ungroup element groups
  • align_elements - Align elements (left, center, right, top, middle, bottom)
  • distribute_elements - Distribute elements evenly
  • lock_elements / unlock_elements - Lock/unlock elements

Resource Access

  • get_resource - Access scene, library, theme, or elements data

Troubleshooting

NPM Package Issues

  • Symptoms: MCP tools not registering properly
  • Solution: Use local development setup
  • Status: Actively debugging

Docker Version Notes

  • Symptoms: Elements may not sync to canvas immediately
  • Solution: Use local development setup
  • Status: Improving synchronization reliability

Canvas Not Loading

  • Ensure npm run build completed successfully
  • Check that dist/index.html exists
  • Verify canvas server is running on port 3000

Elements Not Syncing

  • Confirm MCP server is running (npm start)
  • Check ENABLE_CANVAS_SYNC=true in environment
  • Verify canvas server is accessible at EXPRESS_SERVER_URL

WebSocket Connection Issues

  • Check browser console for WebSocket errors
  • Ensure no firewall blocking WebSocket connections
  • Try refreshing the browser page

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp_excalidraw" '{"command":"npx","args":["-y","excalidraw-mcp"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp_excalidraw": {
            "command": "npx",
            "args": [
                "-y",
                "excalidraw-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp_excalidraw": {
            "command": "npx",
            "args": [
                "-y",
                "excalidraw-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later