excalidraw-export-mcp
An MCP server that enables exporting Excalidraw .excalidraw files to PNG or SVG format, with support for batch export and metadata retrieval.
README
Excalidraw Export MCP Server
An MCP (Model Context Protocol) server for exporting Excalidraw diagrams to PNG or SVG format.
Features
- Export
.excalidrawfiles to PNG or SVG - Batch export multiple files at once
- Get diagram metadata (element count, types, bounds, etc.)
- Pixel-perfect rendering using headless Chromium browser
- Configurable export options (scale, dark mode, background)
Prerequisites
- Node.js 18 or later
- Playwright (Chromium is downloaded automatically on install)
Installation
npm install
npm run build
On first install, Playwright will download Chromium automatically.
Usage
As an MCP Server
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"excalidraw-export": {
"command": "node",
"args": ["/path/to/excalidraw-export-mcp/dist/index.js"]
}
}
}
Tools
export_excalidraw
Export a single Excalidraw diagram.
Parameters:
inputPath(required): Absolute path to the.excalidrawfileoutputPath: Output file path (defaults to input path with new extension)format:"png"or"svg"(default:"png")background: Include background color (default:true)darkMode: Export in dark mode (default:false)scale: Scale factor 1, 2, or 3 (default:2for high DPI)
export_excalidraw_batch
Export multiple diagrams at once.
Parameters:
inputPaths(required): Array of absolute paths to.excalidrawfilesoutputDir: Output directory (defaults to same directory as each input)format:"png"or"svg"(default:"png")background,darkMode,scale: Same as above
get_excalidraw_info
Get metadata about an Excalidraw file without exporting.
Parameters:
inputPath(required): Absolute path to the.excalidrawfile
Returns:
elementCount: Number of elements in the diagramelementTypes: Count of each element type (rectangle, arrow, text, etc.)hasBackground: Whether background is exportedbackgroundColor: Background colorversion: Excalidraw schema versionfileSize: File size in bytesbounds: Diagram dimensions (width, height)
Examples
Example 1: Export a Single Diagram to PNG
{
"tool": "export_excalidraw",
"arguments": {
"inputPath": "/Users/me/diagrams/architecture.excalidraw",
"format": "png",
"scale": 2
}
}
Result:
{
"success": true,
"outputPath": "/Users/me/diagrams/architecture.png",
"format": "png",
"message": "Successfully exported to /Users/me/diagrams/architecture.png"
}
Example 2: Export with Custom Output Path
{
"tool": "export_excalidraw",
"arguments": {
"inputPath": "/Users/me/docs/flowchart.excalidraw",
"outputPath": "/Users/me/images/flowchart-hires.png",
"scale": 3
}
}
Example 3: Export in Dark Mode
{
"tool": "export_excalidraw",
"arguments": {
"inputPath": "/Users/me/diagrams/network.excalidraw",
"darkMode": true,
"background": true
}
}
Example 4: Export to SVG
{
"tool": "export_excalidraw",
"arguments": {
"inputPath": "/Users/me/diagrams/logo.excalidraw",
"format": "svg"
}
}
Example 5: Batch Export Multiple Diagrams
{
"tool": "export_excalidraw_batch",
"arguments": {
"inputPaths": [
"/Users/me/docs/diagram1.excalidraw",
"/Users/me/docs/diagram2.excalidraw",
"/Users/me/docs/diagram3.excalidraw"
],
"outputDir": "/Users/me/exports",
"format": "png",
"scale": 2
}
}
Result:
{
"success": true,
"results": [
{
"inputPath": "/Users/me/docs/diagram1.excalidraw",
"outputPath": "/Users/me/exports/diagram1.png",
"success": true
},
{
"inputPath": "/Users/me/docs/diagram2.excalidraw",
"outputPath": "/Users/me/exports/diagram2.png",
"success": true
},
{
"inputPath": "/Users/me/docs/diagram3.excalidraw",
"outputPath": "/Users/me/exports/diagram3.png",
"success": true
}
],
"totalProcessed": 3,
"successful": 3,
"failed": 0
}
Example 6: Get Diagram Information
{
"tool": "get_excalidraw_info",
"arguments": {
"inputPath": "/Users/me/diagrams/architecture.excalidraw"
}
}
Result:
{
"elementCount": 15,
"elementTypes": {
"rectangle": 5,
"arrow": 6,
"text": 4
},
"hasBackground": true,
"backgroundColor": "#ffffff",
"version": 2,
"source": "https://excalidraw.com",
"fileSize": 12453,
"bounds": {
"width": 800,
"height": 600
}
}
Example 7: Export Without Background (Transparent)
{
"tool": "export_excalidraw",
"arguments": {
"inputPath": "/Users/me/diagrams/icon.excalidraw",
"format": "png",
"background": false
}
}
Claude Code Usage Examples
When using with Claude Code, you can ask:
Export a diagram:
"Export the architecture diagram at /path/to/architecture.excalidraw to PNG"
Export all diagrams in a folder:
"Export all .excalidraw files in the docs folder to PNG format"
Get diagram info before exporting:
"What's in the diagram at /path/to/diagram.excalidraw? How many elements does it have?"
Create high-resolution exports:
"Export diagram.excalidraw at 3x scale for printing"
Dark mode exports:
"Export the network diagram in dark mode"
Development
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run dev
# Run all tests
npm test
# Run unit tests only (faster, no browser)
npm run test:unit
# Run integration tests (requires Playwright/Chromium)
npm run test:integration
Test Suite
The project includes a comprehensive test suite:
Unit Tests (tests/get-info.test.ts)
- Element counting and categorization
- Bounds calculation
- AppState property extraction
- Edge cases (empty elements, missing properties)
Schema Validation Tests (tests/mcp-server.test.ts)
- Zod schema validation for all tool inputs
- Default value handling
- Required field validation
- Boundary conditions (scale min/max)
- Tool definition structure validation
Integration Tests (tests/export.test.ts)
- Full export pipeline with Playwright
- PNG file validation (magic bytes check)
- Page reload handling
- Canvas capture
- Batch processing
- Error recovery
To skip integration tests (if Chromium is not installed):
SKIP_INTEGRATION=true npm test
How It Works
This server uses Playwright to run a headless Chromium browser that:
- Navigates to excalidraw.com
- Loads your diagram data via localStorage
- Captures a screenshot of the rendered canvas
This approach ensures pixel-perfect rendering identical to the Excalidraw web app.
Troubleshooting
Chromium not installed
If you see "Executable doesn't exist" errors, run:
npx playwright install chromium
Timeout errors
For large diagrams, the export may take longer. The server includes automatic retries and page reload handling.
Memory issues with batch exports
For very large batches, consider breaking them into smaller chunks or increasing Node.js memory:
NODE_OPTIONS="--max-old-space-size=4096" node dist/index.js
Publishing to npm
Prerequisites
- Create an npm account at https://www.npmjs.com/
- Generate an access token with publish permissions
- Add the token as
NPM_TOKENsecret in GitHub repository settings
Automated Publishing (Recommended)
Publishing is automated via GitHub Actions. To publish a new version:
-
Update the version in
package.json:npm version patch # or minor, major -
Push the changes and create a GitHub release:
git push && git push --tags -
Create a release on GitHub from the tag - this triggers the publish workflow
Manual Publishing
To publish manually:
# Login to npm
npm login
# Build and test
npm run build
npm run test:unit
# Publish
npm publish --access public
Version Guidelines
- Patch (0.1.x): Bug fixes, documentation updates
- Minor (0.x.0): New features, non-breaking changes
- Major (x.0.0): Breaking changes
Using from npm
Once published, users can install directly:
npm install -g excalidraw-export-mcp
Or use with npx:
npx excalidraw-export-mcp
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。