Skip to main content
Glama
excalidraw-mcp-server

excalidraw-mcp-server

excalidraw-mcp-server

An MCP server that draws Excalidraw diagrams for any MCP client: an ADK-Go harness, Claude Code or opencode. The user watches and edits each diagram in their browser.

The drawing tools are yctimlin/mcp_excalidraw's, vendored in upstream/ and edited where that's simpler than working around it; upstream/VENDORED.md lists what changed and how to take in yctimlin's updates. This repo adds what a multi-user harness needs: MCP over HTTP, one diagram per artifact, and a viewer page. Your harness stores the diagrams and decides who can see them, as described in the harness spec.

This is an independent project, not affiliated with or endorsed by Excalidraw or yctimlin.

To try the whole stack on your machine, run make setup testbed, described in dev/testbed.

How it works

ADK agent, Claude Code ──tools/call + user's token──▶ this server ──same token──▶ harness ──▶ S3, OpenSearch
Frontend ──iframe /view/{id}/ (harness) ──grant from the frontend──▶ harness ──proxies the viewer from──▶ this server
  1. The model calls new_diagram, which returns an id and a viewUrl to your app's /a/{id} page. It passes the id as diagram to every other tool.

  2. Each tool call reads the diagram from the harness with the caller's token, runs yctimlin's tool on it, and writes it back if it changed. Nothing stays on the server between calls.

  3. Your frontend embeds the harness's viewer: an Excalidraw editor. The viewer asks the frontend for a one-minute grant, so it opens as the signed-in user, and the harness checks access on every request.

  4. The harness pushes an event after each save, and the page fetches the new version. Editing is off while the model works.

  5. If the user edits between the model's calls, its next result starts with a note listing what they added, changed and deleted.

  6. After each write, and with the screenshot, the result starts with a layout check when something overlaps or runs past its section: boxes, paragraphs and arrow labels, measured with yctimlin's renderer and the real fonts, named by element ID with the size to fix to. It only warns; nothing is moved, since an overlap can be meant. Models can't measure text, and miss small overlaps in a large screenshot, so this is what catches overflowing paragraphs.

  7. When it has finished, the model calls get_canvas_screenshot once to see the diagram, and fixes what looks wrong.

yctimlin keeps one canvas per process, in memory. The server runs that canvas inside its own process and gives it one diagram at a time: it fills the canvas, runs the tool and reads the canvas back, one call at a time per process. Reads and writes to the harness happen outside that, so a slow harness doesn't hold up other calls. Add replicas to scale; they share nothing.

Path

Purpose

server/engine.ts

Runs yctimlin's tools in this process, one diagram at a time

server/tools.ts

The diagram argument, new_diagram, and the save/retry loop around each of yctimlin's tools

server/edits.ts

The note about the user's edits

server/layout.ts

The layout check: boxes or text that overlap or run past their section

server/skill.ts

The drawing guide as a skill

upstream/

yctimlin, vendored: the tools, the canvas, the renderer, and the drawing guide (src/core/design-guide.ts)

server/artifacts.ts

The client for the harness's artifact API, which passes the caller's token through

server/bearer.ts

Requires a token on tool calls, and publishes the sign-in discovery document

server/main.ts

HTTP: /mcp, the viewer's files, /healthz

src/

The viewer page; built, never run on the server

dev/testbed

A whole stack on one machine, including the reference implementation of the harness spec

Related MCP server: sketchboard-excalidraw-mcp

Tools

yctimlin's, each with a diagram argument (see upstream/src/core/mcp-tools.ts): batch_create_elements, create_element, get_element, update_element, delete_element, query_elements, duplicate_elements, group_elements, ungroup_elements, align_elements, distribute_elements, lock_elements, unlock_elements, describe_scene, get_canvas_screenshot, snapshot_scene, restore_snapshot, clear_canvas. Plus read_diagram_guide, which needs no diagram, and this server's new_diagram.

Removed from the vendored copy, because they don't fit a shared server:

Tool

Why

export_to_excalidraw_url

Uploads the diagram to excalidraw.com, sharing it without the owner

export_scene, import_scene, export_to_image

Read and write this server's disk

create_from_mermaid, set_viewport

Need yctimlin's own browser page open

get_resource

Returns only built-in defaults

get_canvas_screenshot always renders on the server; its option to render in a browser is removed. The write tools answer with a short list of what they wrote, by id, type and label, instead of repeating every element as JSON, which the model would resend with every later call. Bound arrows need no x or y, and take via points to bend around shapes in the way.

Configuration

Variable

Default

Meaning

ARTIFACTS_URL

The harness's base URL, which stores the diagrams. Required

PUBLIC_URL

http://localhost:$PORT

This server's public URL, for the sign-in discovery document

OIDC_ISSUER_URL

Your identity provider. Clients that can sign in by themselves, such as Claude Code, find it through /.well-known/oauth-protected-resource

PORT, HOST

3001, 127.0.0.1

Listen address. The image sets HOST=0.0.0.0

EXCALIDRAW_DIR

upstream/

Where yctimlin's built code is. The image sets it

The server checks no tokens itself: the harness does, when the tools pass them on. initialize and tools/list need no token, so clients can discover the server. GET /healthz reports readiness.

Build the image with make image. It holds the built yctimlin with its fonts, and this repo's server and viewer.

Connect Claude Code or opencode

claude mcp add --transport http excalidraw https://excalidraw-mcp.example.com/mcp
// ~/.config/opencode/opencode.json
"mcp": {
  "excalidraw": { "type": "remote", "url": "https://excalidraw-mcp.example.com/mcp", "enabled": true }
}

Both sign in through your identity provider on the first tool call. Against the testbed, pass a token instead, as dev/testbed shows.

How the model learns to draw

One drawing guide: upstream/src/core/design-guide.ts. It's yctimlin's design guide, with the drawing sections of its agent skill (coordinates, layout anti-patterns, the quality checklist, arrow routing) and a short part on how to use this server's tools. It reaches the model three ways:

Way

Who sees it

The excalidraw-diagrams skill, at GET /skills/excalidraw-diagrams/SKILL.md

Clients with skills: ADK's skilltoolset (see the harness spec), and Claude Code if you save it to ~/.claude/skills/excalidraw-diagrams/SKILL.md

read_diagram_guide, which returns the same text

Every client; for those without skills

Tool descriptions, which carry the rules that matter most: spacing, zones, zone titles, arrow binding and routing, and what to check in the screenshot

Every client, on every request

The server's MCP instructions say the same in brief. Claude Code passes them to the model; ADK drops them (see the harness spec), which is why the rules are in the tool descriptions too.

Changing yctimlin

Edit upstream/, then make yctimlin test. To take in yctimlin's own updates, see upstream/VENDORED.md.

The server itself loads these parts of yctimlin's built code, so keep them when changing it:

  • dist/server.js: exports its Express app without listening when imported.

  • dist/types.js: the elements, snapshots and files maps that hold the canvas.

  • dist/core/config.js: reads EXPRESS_SERVER_URL when it loads, after the canvas has started. The server checks this at startup.

  • dist/core/canvas-state.js: sceneState, reset before each call.

  • dist/core/render/excalidraw-node/index.js: prepareScene(elements), the renderer's step that measures text, which the layout check uses.

  • dist/core/mcp-tools.js, dist/core/mcp-dispatch.js and dist/core/design-guide.js: the tools, callExcalidrawTool(name, args) and the guide.

  • @modelcontextprotocol/server in its dependencies: McpServer, fromJsonSchema and createMcpHandler.

  • frontend/src/utils/scene.ts: prepareServerScene, which the viewer uses to turn stored elements into Excalidraw's.

Known limits

  • Animation is per tool call: when a call finishes, the viewer reveals its new shapes one at a time (each with its label, each arrow once both its ends show) over at most 3 seconds, with the camera framing them, then pulls back to the whole diagram. Strokes don't draw themselves in, as they did in the official widget. Viewers who ask their system for reduced motion get it without the animation.

  • One call at a time per process: calls queue for the canvas. Each takes milliseconds, plus a few hundred for a screenshot.

  • Same element, two editors: a user's save and a model write landing together merge by element. If both change the same element, the version saved last wins.

  • Very large pending edits: when a page closes, edits still waiting on the 1 second save delay are only sent if they're under about 60 KB, a browser limit.

  • Without a frontend signal: a page opened from Claude Code turns editing off at the model's first write, not when the model starts, and turns it back on 20 seconds after the last write.

  • No images: pasted images aren't saved, and image, embeddable and iframe elements are removed when the user saves.

  • No MCP Apps or stdio: use yctimlin directly for a single local user.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers