exca-mcp
v0.5.0A local MCP server for creating and editing Excalidraw documents
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. Run Excalidraw MCP instantly with uvx (zero install required): exca-mcp includes built-in subcommands for environment diagnostics, configuration generation, and agent skill distribution:
Summary extracted from the README.
Excalidraw MCP Server
A headless, in-memory Model Context Protocol server enabling AI agents to programmatically generate, inspect, repair, and export native Excalidraw diagrams.
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
System architecture diagram generated programmatically by Excalidraw MCP itself. Editable source: docs/architecture.excalidraw.
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
.excalidrawJSON 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 dynamicclient_idresolution. - Halved Schema Context Footprint: Minimalist tool contracts and compact minified JSON responses strip
outputSchemaoverhead, 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 viaexca-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 tostderrbecause 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.