Skip to main content
Glama

Excalidraw MCP Server

A headless, in-memory Model Context Protocol server enabling AI agents to programmatically generate, inspect, repair, and export native Excalidraw diagrams.

License: MIT PyPI Version Python 3.12+ CI Status GitHub Stars Dharshan2208/excalidraw-mcp MCP server


Excalidraw MCP is a backend-oriented Model Context Protocol (MCP) server that empowers AI coding agents to create, inspect, edit, diagnose, and export native Excalidraw diagrams over standard stdio.

Operating directly on scene graphs and element trees in memory with FreeType font metrics and topological collision solvers, it eliminates browser automation overhead to achieve sub-millisecond diagram mutations. All diagrams serialize strictly to Excalidraw Schema v2 JSON, guaranteeing immediate compatibility with excalidraw.com, IDE plugins, and high-resolution export pipelines.


Visual Showcase

Excalidraw MCP System Architecture System architecture diagram generated programmatically by Excalidraw MCP itself. Editable source: docs/architecture.excalidraw.


Related MCP server: fcp-drawio

Key Features

  • Headless In-Memory Operations: Operates 100% in pure Python on scene graphs in server memory with zero browser runtime or Node.js dependencies.

  • Native Excalidraw Schema v2: Outputs fully valid, editable .excalidraw JSON documents compatible with excalidraw.com.

  • Obstacle-Aware Orthogonal Routing: Calculates Manhattan arrow paths around intervening shapes with 15 px clearance corridors and dynamic cardinal-face docking.

  • Parallel Multi-Edge Lanes: Displaces parallel connectors between the same shapes into distinct 24 px lanes to prevent overlapping lines.

  • Font-Aware Text Metrics: Uses FreeType and Pillow to measure exact typographic envelopes, preventing label clipping inside rectangles, rhombuses, and ellipses.

  • Automated Layout Repair (auto_fix_layout): Detects bounding box collisions, text clipping, and frame escapes, executing 5-phase de-collision and spacing with transactional regression rollback.

  • Atomic Batch Authoring (batch_mutate): Enables agents to create, move, style, connect, lock, group, and repair up to 500 operations in a single roundtrip with dynamic client_id resolution.

  • Halved Schema Context Footprint: Minimalist tool contracts and compact minified JSON responses strip outputSchema overhead, reducing turn context usage by up to 50.4%.

  • High-Resolution Headless Export: Headless Pillow rasterization generating PNG exports up to 8192 px, vector SVG exports, Obsidian Excalidraw plugin Markdown files (.excalidraw.md), and inline vision previews (preview) capped to optimal model envelopes (max_dimension=1568).

  • Interactive Live Canvas (live_server): Real-time Starlette/Uvicorn WebSocket visualizer streaming agent mutations live into an open browser tab.

  • Encrypted Web Sharing (export_to_excalidraw_url): Publishes scenes directly to excalidraw.com using 128-bit AES-GCM client-side encryption.

  • Bundled Agent Skills: Packages 6 prompt and pattern guides covering architecture design, flowcharts, 60-30-10 color palettes, and quality gates, installable via exca-mcp install-skills (including automatic discovery for Claude Code via exca-mcp install-skills --claude).


Quick Start

Run Excalidraw MCP instantly with uvx (zero install required):

uvx exca-mcp

Or install via pip:

pip install exca-mcp
python -m excalidraw_mcp

Installation

Method

Command

Description

uvx (Recommended)

uvx exca-mcp

Zero-install ephemeral execution.

pip

pip install exca-mcp

Standard Python package installation.

Docker

docker run -i --rm exca-mcp

Containerized execution via stdio.

Source

uv sync --locked && uv run exca-mcp

Local clone for development.


CLI Utilities

exca-mcp includes built-in subcommands for environment diagnostics, configuration generation, and agent skill distribution:

# Run environment & dependency diagnostics (Python, fonts, storage, skills)
exca-mcp doctor

# Print copy-pasteable client configuration JSON
exca-mcp print-config claude      # Claude Desktop / Claude Code
exca-mcp print-config cursor      # Cursor (.cursor/mcp.json)
exca-mcp print-config zed         # Zed (settings.json)
exca-mcp print-config windsurf    # Windsurf
exca-mcp print-config opencode    # OpenCode
exca-mcp print-config antigravity # Google Antigravity / Gemini CLI

# Install agent skills into your editor
exca-mcp install-skills --claude    # ~/.claude/skills/excalidraw/
exca-mcp install-skills --cursor    # .cursor/skills/
exca-mcp install-skills --windsurf  # .windsurf/skills/
exca-mcp install-skills --target <path>

MCP Client Configuration

Add Excalidraw MCP to your AI development environment:

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "excalidraw": {
      "command": "uvx",
      "args": ["exca-mcp"]
    }
  }
}

Cursor

Add to .cursor/mcp.json or Global MCP Settings:

{
  "mcpServers": {
    "excalidraw": {
      "command": "uvx",
      "args": ["exca-mcp"]
    }
  }
}

Zed

Add to ~/.config/zed/settings.json:

{
  "context_servers": {
    "excalidraw": {
      "command": {
        "path": "uvx",
        "args": ["exca-mcp"]
      }
    }
  }
}

Remote Daemon / Streamable HTTP (Docker & Kubernetes)

Excalidraw MCP natively supports the MCP streamable-http transport for remote deployments in containers, Kubernetes clusters, or standalone daemons:

# Local development daemon (binds to 127.0.0.1:8000/mcp)
exca-mcp --transport streamable-http --port 8000

# Container / Kubernetes daemon (binds to 0.0.0.0:8000/mcp)
exca-mcp --transport streamable-http --host 0.0.0.0 --port 8000

Minimal Dockerfile for remote deployments:

FROM python:3.12-slim
RUN pip install --no-cache-dir exca-mcp
EXPOSE 8000
CMD ["exca-mcp", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "8000"]

Security Note: When binding to non-loopback addresses (0.0.0.0), the server prints a warning to stderr because MCP does not provide built-in client authentication. Always protect network-exposed instances behind an authenticated reverse proxy (e.g., Envoy, Traefik, NGINX) or private cluster VPC.

For configuration in OpenCode, Claude Code CLI, Gemini/Antigravity CLI, or Docker environments, see docs/operations.md.


Toolset Overview (core vs full)

Excalidraw MCP provides two toolset profiles controlled by the EXCALIDRAW_TOOLSET environment variable:

Profile

Tools

Context Overhead

Primary Capabilities

core (default)

12

~3,133 tokens

Primitives (create_shape, create_connector, add_text, add_frame), mutations (update_element, delete, clear, undo), atomic batches (batch_mutate), inspection (inspect_scene), layout repair (auto_fix_layout), and vision previews (preview).

full

21

~5,628 tokens

Includes all core tools plus file storage (scene_storage), disk export (export_png, export_svg), generators (generate_diagram), element locking/grouping (manage_element_state), viewport framing (set_viewport), live browser sync (live_server), cloud sharing (export_to_excalidraw_url), and design rules (read_diagram_guide).

To enable the complete 21-tool profile:

export EXCALIDRAW_TOOLSET=full

See docs/tools.md for the complete reference of all 21 tools, safety annotations, parameter schemas, and MCP resources.


Minimal Usage Example

AI agents can construct, connect, repair, and preview diagrams using the default core toolset:

# 1. Create container boundary frame
f = add_frame(name="Application Tier", x=100, y=100, w=600, h=220)

# 2. Add styled components inside the frame
s1 = create_shape(type="rectangle", x=140, y=160, w=180, h=90, label="API Gateway", frame_id=f["frame_id"], backgroundColor="#e7f5ff")
s2 = create_shape(type="rectangle", x=460, y=160, w=180, h=90, label="Auth Service", frame_id=f["frame_id"], backgroundColor="#fff3bf")

# 3. Connect components with an elbowed directional arrow
create_connector(source_id=s1["rectangle_id"], target_id=s2["rectangle_id"], label="verify_token()", elbowed=True)

# 4. Diagnose layout defects and render an inline visual preview
auto_fix_layout(dry_run=False, aggressiveness="balanced")
preview(max_dimension=1568, format="png")

For comprehensive end-to-end multi-tier cloud and flowchart workflows, see docs/features.md.


Documentation Index

Guide

Description

docs/ARCHITECTURE.md

Technical architecture, subsystem request flow, state management, and geometry algorithms.

docs/features.md

Detailed capability breakdown and end-to-end workflow examples.

docs/tools.md

Complete MCP tools reference, parameter schemas, code examples, resources, and task prompts.

docs/auto-fix-layout.md

5-phase layout repair engine, parameters, visual comparisons, and rollback guarantees.

docs/operations.md

Environment variables reference, storage semantics, extended client configurations, and troubleshooting.

docs/security.md

Security model, write sandboxing, live server origin protection, and cloud sharing encryption.

docs/skills.md

Packaged agent skills catalog, design guides, and CLI installer (exca-mcp install-skills).

docs/graph-generation.md

Structured Sugiyama layered graph generation, ranking, and geometry rules.

docs/migration_v030.md

Migration guide mapping all 48 legacy v0.2.x tools to v0.3.0 equivalents.

CHANGELOG.md

Version release history and migration notes.

CONTRIBUTING.md

Developer guide, test suite execution, and pull request guidelines.

SECURITY.md

Vulnerability disclosure procedures and policy.


Development & Contribution

# Clone the repository
git clone https://github.com/Dharshan2208/excalidraw-mcp.git
cd excalidraw-mcp

# Synchronize dependencies with uv (including test & dev tools)
uv sync --locked

# Run the full test suite (551 unit & integration tests)
uv run --locked pytest tests/

# Run code quality gates (linting & typechecking)
uvx ruff check excalidraw_mcp tests
uv run --with mypy mypy excalidraw_mcp

# Verify byte-compilation
uv run --locked python -B -m compileall -q -f main.py excalidraw_mcp tests

# Validate package build
uv build
uvx twine check dist/*

See CONTRIBUTING.md for contribution guidelines.


License

This project is licensed under the MIT License.

Available Tools

12 tools
add_frameC

Create a frame container, optionally enclosing existing elements.

Inputs: h (required), w (required), x (required), y (required), +9 more.

add_textC

Add standalone text element to the scene.

Inputs: x (required), y (required), content (required), opacity, +4 more.

auto_fix_layoutC

Diagnose and automatically repair layout defects with rollback safety.

Inputs: name, dry_run, min_gap, verbose, +2 more.

batch_mutateC

Atomically execute a batch of canvas mutations in a single revision step.

Inputs: operations (required).

clearA
DestructiveIdempotent

Clear all elements and state from the active scene.

Inputs: no named parameters.

create_connectorC

Create a connector arrow between coordinates or bound shape elements.

Inputs: x, y, x2, y2, +18 more.

create_shapeC

Create a shape (rectangle, ellipse, diamond) with optional label and styling.

Inputs: w (required), x (required), y (required), type (required), +13 more.

deleteB
Destructive

Delete an element and detach surviving connectors.

Inputs: element_id (required).

inspect_sceneC
Read-only

Query scene metrics, spatial descriptions, elements, viewport, or server status.

Inputs: mode, type, limit, query, +8 more.

previewB
Read-only

Render an inline image preview of the active Excalidraw canvas.

Inputs: scale, format, padding, background, +1 more.

undoA
Destructive

Restore the scene before the most recent successful mutation.

Inputs: no named parameters.

update_elementB
Idempotent

Update element position, size, label, or visual styling atomically.

Inputs: element_id (required), x, y, label, +15 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools have clearly distinct canvas operations: create shape/connector/text/frame, update, delete, clear, preview, inspect, undo, and layout repair. The main overlap is that batch_mutate can perform many of the same mutations as the individual creation/update/delete tools, though its batch-atomic purpose is still reasonably distinct.

    Naming Consistency3/5

    The set mixes verb_noun names such as create_shape, add_frame, update_element, and inspect_scene with bare verbs such as preview, undo, clear, and delete. The names are readable and mostly intuitive, but the convention is not consistent across all tools.

    Tool Count5/5

    Twelve tools is a well-scoped size for an Excalidraw canvas server. Each tool maps to a meaningful operation, and the set avoids both trivial thinness and excessive fragmentation.

    Completeness4/5

    The surface covers core canvas lifecycle operations: creation, inspection, preview, update, deletion, clearing, batching, layout repair, and undo. Minor gaps remain, such as redo, duplicate, and group/ungroup operations, but the main workflows are covered.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers