Skip to main content
Glama
README.md
# Excalidraw MCP Server

[![npm version](https://img.shields.io/npm/v/@scofieldfree/excalidraw-mcp.svg)](https://www.npmjs.com/package/@scofieldfree/excalidraw-mcp)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

An MCP (Model Context Protocol) server that empowers AI agents (like **Claude**, **Cursor**, **Windsurf**) to create, edit, and manage **Excalidraw** diagrams directly within your conversation.

> **Why Excalidraw?** Its hand-drawn aesthetic and JSON-based format are perfect for rapid, programmable diagramming. This server bridges standard MCP clients with a local Excalidraw instance, enabling AI-powered visual thinking.

<p align="center">
  <img src="/images/excalidraw-mcp-architechture.png" alt="Excalidraw MCP Demo" width="700">
</p>

## ✨ Features

| Feature                  | Description                                                        |
| ------------------------ | ------------------------------------------------------------------ |
| šŸŽØ **Real-time Preview** | Changes appear instantly in a local browser window via WebSocket   |
| šŸ“ **Smart Layout**      | Automatically calculates text width and binds labels to containers |
| šŸ”„ **Multi-Session**     | Switch between different diagrams seamlessly                       |
| 🧜 **Mermaid Support**   | Convert Mermaid syntax to Excalidraw diagrams instantly            |
| šŸ“¦ **Export Options**    | Export to PNG, SVG, or JSON formats                                |
| šŸ—ļø **Templates**         | Built-in architecture diagram templates                            |

---

## šŸš€ Quick Start

You don't need to clone this repo. Just configure your MCP client:

### Claude Code (cc)

```bash
claude mcp add excalidraw -- npx -y @scofieldfree/excalidraw-mcp
```

### Codex CLI

```bash
codex mcp add excalidraw -- npx -y @scofieldfree/excalidraw-mcp
```

### Cursor / Windsurf

Go to **Settings > MCP** → **Add New MCP Server**:

| Field   | Value                                 |
| ------- | ------------------------------------- |
| Name    | `excalidraw`                          |
| Type    | `command`                             |
| Command | `npx -y @scofieldfree/excalidraw-mcp` |

### Cline (VS Code Extension)

Open Cline settings and add to MCP Servers:

```json
{
  "mcpServers": {
    "excalidraw": {
      "command": "npx",
      "args": ["-y", "@scofieldfree/excalidraw-mcp"]
    }
  }
}
```

### GitHub Copilot

Use the Copilot CLI to interactively add:

```bash
/mcp add
```

Alternatively, create or edit `~/.copilot/mcp-config.json`:

```json
{
  "mcpServers": {
    "excalidraw": {
      "type": "local",
      "command": "npx",
      "tools": ["*"],
      "args": ["-y", "@scofieldfree/excalidraw-mcp"]
    }
  }
}
```

### Kiro

Follow the [MCP Servers documentation](https://kiro.dev/docs/mcp). Add to `.kiro/settings/mcp.json`:

```json
{
  "mcpServers": {
    "excalidraw": {
      "command": "npx",
      "args": ["-y", "@scofieldfree/excalidraw-mcp"]
    }
  }
}
```

### opencode

```bash
opencode mcp add excalidraw -- npx -y @scofieldfree/excalidraw-mcp
```

### VS Code

**One-click install:**

[<img src="https://img.shields.io/badge/Install_Server-VS_Code-blue?logo=visualstudiocode" alt="Install in VS Code">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22excalidraw%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40scofieldfree%2Fexcalidraw-mcp%22%5D%7D)
[<img src="https://img.shields.io/badge/Install_Server-VS_Code_Insiders-green?logo=visualstudiocode" alt="Install in VS Code Insiders">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%7B%22name%22%3A%22excalidraw%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40scofieldfree%2Fexcalidraw-mcp%22%5D%7D)

**Or install via CLI:**

```bash
# For VS Code
code --add-mcp '{"name":"excalidraw","command":"npx","args":["-y","@scofieldfree/excalidraw-mcp"]}'

# For VS Code Insiders
code-insiders --add-mcp '{"name":"excalidraw","command":"npx","args":["-y","@scofieldfree/excalidraw-mcp"]}'
```

### Claude Desktop

Add to your `claude_desktop_config.json`:

- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "excalidraw": {
      "command": "npx",
      "args": ["-y", "@scofieldfree/excalidraw-mcp"]
    }
  }
}
```

---

## šŸ› ļø Available Tools

| Tool                        | Description                                      |
| --------------------------- | ------------------------------------------------ |
| `start_session`             | Start browser preview and open Excalidraw editor |
| `add_elements`              | Add shapes, text, arrows to the canvas           |
| `update_element`            | Modify existing element properties               |
| `delete_element`            | Remove elements from canvas                      |
| `get_scene`                 | Retrieve current diagram state                   |
| `create_from_mermaid`       | Convert Mermaid syntax to Excalidraw             |
| `add_template_architecture` | Add a pre-built architecture diagram template    |
| `create_diagram`            | Create a new diagram or clear existing           |
| `export_diagram`            | Export diagram to PNG, SVG, or JSON              |
| `list_sessions`             | List all active diagram sessions                 |
| `delete_diagram`            | Delete a diagram session                         |

---

## šŸ’¬ Usage Examples

### Example 1: Create a Simple Diagram

**You say:**

> "Draw a flowchart with three boxes: Input → Process → Output"

**AI uses:**

```
start_session → add_elements (3 rectangles + 2 arrows)
```

### Example 2: Convert Mermaid to Excalidraw

**You say:**

> "Convert this Mermaid diagram to Excalidraw:
> `graph LR: A[User] --> B[API Gateway] --> C[Service] --> D[(Database)]`"

**AI uses:**

```
start_session → create_from_mermaid
```

### Example 3: Architecture Diagram

**You say:**

> "Create an architecture diagram for a microservices system"

**AI uses:**

```
start_session → add_template_architecture (or) add_elements with custom layout
```

---

## šŸ—ļø Architecture

```
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│                     AI Agent (Claude/Cursor)                │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                          │ MCP Protocol (JSON-RPC over stdio)
                          ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│                   Excalidraw MCP Server                     │
│  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  │
│  │ Tool Router │──│ State Store │──│ WebSocket Broadcast │  │
│  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                                 │ WebSocket
                                                 ā–¼
                          ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                          │     Browser (Excalidraw Editor)   │
                          ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
```

---

## šŸ”§ Development

### Prerequisites

- Node.js >= 18
- pnpm >= 9

### Setup

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

# Install dependencies
pnpm install

# Start development server
pnpm dev
```

### Scripts

| Command          | Description                           |
| ---------------- | ------------------------------------- |
| `pnpm dev`       | Start dev server (backend + frontend) |
| `pnpm build`     | Build for production                  |
| `pnpm typecheck` | Run TypeScript type checking          |
| `pnpm lint`      | Run ESLint                            |
| `pnpm release`   | Create a new release version          |

---

## šŸ“¦ Project Structure

```
excalidraw-mcp/
ā”œā”€ā”€ packages/
│   └── mcp-server/          # Core MCP server + Excalidraw frontend
│       ā”œā”€ā”€ src/
│       │   ā”œā”€ā”€ index.ts     # Entry point
│       │   ā”œā”€ā”€ state.ts     # Session state management
│       │   ā”œā”€ā”€ http-server.ts
│       │   └── tools/       # MCP tool implementations
│       └── web/             # Excalidraw React frontend
ā”œā”€ā”€ docs/                    # Documentation
└── package.json             # Workspace configuration
```

---

## šŸ› Troubleshooting

### Port Already in Use

The server automatically finds an available port starting from 3100. If you need a specific port, set the `PORT` environment variable.

### Browser Doesn't Open

Ensure you have a default browser configured. The server uses the `open` package to launch the browser.

### WebSocket Connection Failed

Check if any firewall or antivirus is blocking WebSocket connections on localhost.

---

## šŸ¤ Contributing

Contributions are welcome! Please read our [Contributing Guide](docs/CONTRIBUTING.md) for details.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

## šŸ“œ License

MIT Ā© [Scofieldfree](https://github.com/Scofieldfree)

---

## šŸ”— Links

- [npm Package](https://www.npmjs.com/package/@scofieldfree/excalidraw-mcp)
- [GitHub Repository](https://github.com/Scofieldfree/excalidraw-mcp)
- [Excalidraw](https://excalidraw.com/)
- [Model Context Protocol](https://modelcontextprotocol.io/)

TDQS

A4/5.0

Scored across 11 tools

Disambiguation4/5

Most tools have distinct purposes (adding, deleting, exporting, querying). However, 'add_elements' and 'create_from_mermaid' both add elements, though via different inputs, and 'add_template_architecture' is a specialized add. Descriptions help distinguish them, so minor ambiguity exists.

Naming Consistency4/5

Tool names largely follow a verb_noun pattern (e.g., 'add_elements', 'delete_diagram'). 'create_from_mermaid' breaks this pattern by including a preposition, causing slight inconsistency. Otherwise consistent.

Tool Count5/5

With 11 tools covering diagram creation, manipulation, querying, export, and session management, the count is well-scoped for the domain. Each tool serves a clear purpose without redundancy.

Completeness4/5

Core operations (create, read, update, delete elements and sessions, export) are covered. Minor gaps like undo/redo or advanced layout operations are absent but not critical for typical use.

Maintenance

ActivityInactive
ResponsivenessNo issues