Skip to content

feat: server-side PNG + .excalidraw snapshot rendering#16

Open
antonpk1 wants to merge 5 commits intomainfrom
antonp/server-side-snapshots
Open

feat: server-side PNG + .excalidraw snapshot rendering#16
antonpk1 wants to merge 5 commits intomainfrom
antonp/server-side-snapshots

Conversation

@antonpk1
Copy link
Copy Markdown
Collaborator

@antonpk1 antonpk1 commented Feb 12, 2026

Adds server-side diagram rendering for local stdio MCP builds, so the MCP is useful for clients that don't support MCP Apps (Claude Code, Cursor, Windsurf, etc.).

image

Pipeline

elements → .excalidraw JSON → SVG (excalirender/roughjs) → PNG (resvg WASM)

What it does

  • Every create_view call saves a PNG snapshot + .excalidraw file to /tmp/excalidraw-snapshots/
  • Paths returned in tool response so the agent can reference them
  • Gated behind enableSnapshots option — only active in local stdio/HTTP mode
  • Vercel is completely unaffected (dynamic import, deps never loaded)

Dependencies

  • excalirender (github:JonRC/excalirender) — pure-JS SVG rendering via roughjs
  • @resvg/resvg-wasm — WASM SVG→PNG conversion, no native bindings

Files

File Change
src/snapshot-renderer.ts New isolated module (~200 lines)
src/server.ts ServerOptions interface, dynamic import gated on flag
src/main.ts Passes { enableSnapshots: true }
README.md MCP Tools section, non-MCP-Apps notice

Add excalirender (roughjs SVG) + resvg (WASM PNG) pipeline for
server-side diagram rendering. Gated behind enableSnapshots option —
only active in local stdio/HTTP mode, Vercel is unaffected.

- New src/snapshot-renderer.ts: isolated module (~200 lines)
- Label shorthand expansion (shape + arrow labels)
- Font loading from excalirender's bundled TTFs
- Outputs PNG + .excalidraw to /tmp/excalidraw-snapshots/
- Dynamic import: deps never loaded when snapshots disabled
- Updated README with MCP Tools section and non-MCP-Apps notice
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
excalidraw-mcp Error Error Feb 12, 2026 6:05pm

Request Review

@antonpk1 antonpk1 marked this pull request as ready for review February 12, 2026 12:35
@antonpk1 antonpk1 requested a review from dwelle February 12, 2026 12:35
Comment thread package.json
},
"scripts": {
"postinstall": "node scripts/setup-bun.mjs || echo 'setup-bun.mjs failed or not available'",
"build": "tsc --noEmit && cross-env INPUT=src/mcp-app.html vite build && mv dist/src/mcp-app.html dist/mcp-app.html && rmdir dist/src && tsc -p tsconfig.server.json && bun build src/server.ts --outdir dist --target node && bun build src/main.ts --outfile dist/index.js --target node --banner \"#!/usr/bin/env node\"",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"build": "tsc --noEmit && cross-env INPUT=src/mcp-app.html vite build && mv dist/src/mcp-app.html dist/mcp-app.html && rmdir dist/src && tsc -p tsconfig.server.json && bun build src/server.ts --outdir dist --target node && bun build src/snapshot-renderer.ts --outdir dist --target node && cp node_modules/canvas/build/Release/*.dylib dist/ && bun build src/main.ts --outfile dist/index.js --target node --banner \"#!/usr/bin/env node\"",

I know this is still in progress, but I just tried it - without the renderer and dylib the dist the rendering doesn't work (it falls in to the catch clause that doesn't report anything)

@saksham-wisdom
Copy link
Copy Markdown

@antonpk1 Is there any update on this feature? PNG export would be a very useful functionality for adding the Excalidraw charts everywhere. The current flow asks you to replace your canvas every time, which is not the best UX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants