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
408 stars

MCP Excalidraw Server is a TypeScript-based system that combines Excalidraw's drawing capabilities with Model Context Protocol (MCP) integration, allowing AI agents like Claude to create and manipulate diagrams in real-time on a live canvas. The system consists of two independent components: a Canvas Server that runs the web interface and an MCP Server that connects to AI assistants.

Installation

Setting Up the Canvas Server

Option A: Local Canvas Server

  1. Clone the repository and install dependencies:

    git clone https://github.com/yctimlin/mcp_excalidraw.git
    cd mcp_excalidraw
    npm install
    
  2. Build the project:

    npm run build
    
  3. Start the Canvas Server:

    npm run canvas
    
  4. Access the canvas at http://localhost:3000

Option B: Docker Canvas Server

Using pre-built image (recommended):

docker pull ghcr.io/yctimlin/mcp_excalidraw-canvas:latest
docker run -d -p 3000:3000 --name mcp-excalidraw-canvas ghcr.io/yctimlin/mcp_excalidraw-canvas:latest

Or build locally:

git clone https://github.com/yctimlin/mcp_excalidraw.git
cd mcp_excalidraw
docker build -f Dockerfile.canvas -t mcp-excalidraw-canvas .
docker run -d -p 3000:3000 --name mcp-excalidraw-canvas mcp-excalidraw-canvas

Then access the canvas at http://localhost:3000

Setting Up the MCP Server

The MCP server connects your AI assistant to the canvas. You can use either local or Docker installation.

MCP Server Configuration for IDEs

Configuration for Claude Desktop

Edit your claude_desktop_config.json file:

Local MCP Server (Recommended)

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"],
      "env": {
        "EXPRESS_SERVER_URL": "http://localhost:3000",
        "ENABLE_CANVAS_SYNC": "true"
      }
    }
  }
}

Replace /absolute/path/to/mcp_excalidraw with your actual installation path.

Docker MCP Server

{
  "mcpServers": {
    "excalidraw": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--network", "host",
        "-e", "EXPRESS_SERVER_URL=http://localhost:3000",
        "-e", "ENABLE_CANVAS_SYNC=true",
        "ghcr.io/yctimlin/mcp_excalidraw:latest"
      ]
    }
  }
}

Configuration for Claude Code

Create or edit .mcp.json in your project root:

Local MCP Server (Recommended)

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"],
      "env": {
        "EXPRESS_SERVER_URL": "http://localhost:3000",
        "ENABLE_CANVAS_SYNC": "true"
      }
    }
  }
}

Docker MCP Server

{
  "mcpServers": {
    "excalidraw": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--network", "host",
        "-e", "EXPRESS_SERVER_URL=http://localhost:3000",
        "-e", "ENABLE_CANVAS_SYNC=true",
        "ghcr.io/yctimlin/mcp_excalidraw:latest"
      ]
    }
  }
}

Configuration for Cursor IDE

Edit .cursor/mcp.json:

Local MCP Server (Recommended)

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_excalidraw/dist/index.js"],
      "env": {
        "EXPRESS_SERVER_URL": "http://localhost:3000",
        "ENABLE_CANVAS_SYNC": "true"
      }
    }
  }
}

Usage

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
    }
  ]
}

Troubleshooting

Canvas Not Loading

  • Ensure npm run build completed successfully
  • Check that dist/index.html and dist/frontend/ directory exist
  • Verify canvas server is running on port 3000
  • Check if port 3000 is already in use

Elements Not Syncing

  • Confirm canvas server is running and accessible at http://localhost:3000
  • Check ENABLE_CANVAS_SYNC=true in MCP server environment configuration
  • Verify EXPRESS_SERVER_URL points to correct canvas server URL
  • Check browser console for WebSocket connection errors
  • For Docker: Ensure --network host flag is used

WebSocket Connection Issues

  • Check browser console for WebSocket errors
  • Ensure no firewall blocking WebSocket connections on port 3000
  • Try refreshing the browser page
  • Verify canvas server is running: curl http://localhost:3000/health

Docker Issues

  • For Canvas Container: Check if running with docker ps | grep canvas
  • For MCP Container: Ensure --network host and -i flag are used
  • Check environment variables are properly set

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