excalidraw-board_board
by liefzyj
README.md
# excalidraw-board
A local, bidirectional **Excalidraw** whiteboard [MCP App](https://modelcontextprotocol.io/) plugin for **Google Antigravity**'s side pane (`aux_pane`).
Unlike one-way diagram generators, `excalidraw-board` closes the full collaborative loop:
**AI draws on the canvas → you drag, edit, and annotate directly in the side pane → changes auto-save as plain `.excalidraw` files → AI reads back semantic diffs and exact structure.**
---
## Key Features
- **True Bidirectional Sync**:
- AI opens, draws, appends, or renames boards via MCP tools (`open_board`, `read_board`, `list_boards`).
- Manual edits in the side pane auto-save to disk (450 ms debounce), and a one-click **Ask AI** button prompts the agent to read your latest edits.
- **Project-Aware Dual-Layer Storage (Zero Metadata Pollution)**:
- **Project chats**: Saved cleanly to `<workspace_dir>/.excalidraw/<name>.excalidraw` (easy to version-control alongside code, with no sidecar metadata files).
- **Non-project chats**: Saved to a neutral folder `~/Documents/Excalidraw/<name>.excalidraw` (configurable via `globalBoardsDir`).
- **Private state isolation**: Revision numbers, diff checkpoints, and project registry live outside your repos under `${PLUGIN_DATA}` keyed by file-path hash.
- **Cross-Scope Write Guardrail**:
- Reading any `.excalidraw` file across projects or global storage works freely via `file_path`.
- Writing or renaming a board outside the current conversation's scope is blocked until the user explicitly chooses `edit_in_place` or `copy_to_workspace`.
- **Semantic Diff & Rolling Checkpoints (`smartDiff`)**:
- `read_board` returns a content-focused semantic diff (added/removed elements, text edits, arrow re-bindings, style changes) while filtering `< 8px` layout jitter.
- Keeps 10 rolling checkpoints per board (`since_revision`) and uses tiered raw JSON (`<= 25` elements included automatically; larger boards fetch geometry on demand via `include_raw` or `element_ids`).
- **Clean Split Toolbar & Draft Workflow**:
- Top bar features linked borderless dropdowns (`{Project ▾} / {File ▾}`), **Fit**, and **Ask AI**.
- Opening without a specific file lands on an empty `New` draft that never creates a file until you actually draw (auto-materializing as `untitled-YYMMDD-HHMM`, which the companion skill prompts the AI to rename on sight).
- Manual side-pane opens without a single host workspace present a clean **Select Project** picker before entering the canvas.
- **Fast Local Startup (Zero Remote JS/CSS Downloads)**:
- Lightweight single-file UI shell (`dist/src/app.html`, ~860 KB) bundles React, UI, and Excalidraw CSS locally—well under Antigravity's 2 MiB upstream proxy response limit.
- Trimmed Excalidraw core (keeps `en` + `zh-CN`, stubs unused locales and heavy Mermaid/Cytoscape bundles) is gzipped and served in `< 450 KB` chunks via the app-only `get_vendor_chunk` tool and decompressed in-browser.
---
## Architecture
```text
Antigravity Host (Side Pane / Remote Web)
│
├── MCP Tools (stdio) ──────────► server/index.mjs
│ open_board / read_board / ├── server/storage.mjs ──► <project>/.excalidraw/*.excalidraw
│ list_boards │ ──► ~/Documents/Excalidraw/*.excalidraw
│ │ ──► ${PLUGIN_DATA}/state/<sha256>.json
│ └── server/diff.mjs ──► Semantic diff & structure summary
│
└── MCP App UI (ui:// sandbox) ◄─ dist/src/app.html (~860 KB local shell)
└── app-only RPC bridge ──► get_vendor_chunk (dist/vendor/chunk-*.b64, gzipped Excalidraw)
save_board_state / get_board_state
```
---
## Installation (Google Antigravity)
### 1. Clone and Build
Requires **Node.js 20+** and **npm**.
```bash
git clone https://github.com/liefzyj/excalidraw-board.git
cd excalidraw-board
npm install
npm run build
npm run verify:bundle
```
`npm run build` compiles both:
- `dist/vendor/chunk-*.b64` + `manifest.json` (trimmed, gzipped local Excalidraw core)
- `dist/src/app.html` (self-contained UI shell)
### 2. Mount as an Antigravity Plugin
Copy the template files from [`plugin/`](./plugin/) into your Antigravity plugins directory:
```bash
mkdir -p ~/.gemini/config/plugins/excalidraw-board/skills/excalidraw-board
cp plugin/plugin.json ~/.gemini/config/plugins/excalidraw-board/plugin.json
cp plugin/mcp_config.example.json ~/.gemini/config/plugins/excalidraw-board/mcp_config.json
cp plugin/skills/excalidraw-board/SKILL.md ~/.gemini/config/plugins/excalidraw-board/skills/excalidraw-board/SKILL.md
```
Edit `~/.gemini/config/plugins/excalidraw-board/mcp_config.json` and replace `/ABSOLUTE/PATH/TO/excalidraw-board` with the actual cloned directory (and use the absolute path to `node`, e.g., `/opt/homebrew/bin/node`, if `node` is not in the default GUI `PATH`):
```json
{
"mcpServers": {
"board": {
"command": "/opt/homebrew/bin/node",
"args": [
"/path/to/excalidraw-board/server/index.mjs",
"--data_dir=${PLUGIN_DATA}"
]
}
}
}
```
Enable the `excalidraw-board` plugin in Antigravity (or restart the `excalidraw-board_board` MCP server from Settings).
---
## MCP Tools
| Tool | Purpose | Key Parameters |
|---|---|---|
| `open_board` | Open, create, rename, or update a board in the side pane | `workspace_dir`, `scope` (`"global"`), `board_id`, `title`, `elements`, `mode` (`"open" \| "replace" \| "append"`), `file_path`, `cross_scope_action` (`"edit_in_place" \| "copy_to_workspace"`) |
| `read_board` | Read latest persisted board state, semantic diff, and structure summary | `workspace_dir`, `board_id`, `file_path`, `include_raw`, `element_ids`, `since_revision`, `update_baseline` |
| `list_boards` | List saved `.excalidraw` boards in a project or global folder | `workspace_dir` |
App-only internal tools (`save_board_state`, `get_board_state`, `get_vendor_chunk`) are hidden from the model via `_meta.ui.visibility: ["app"]` and used exclusively by the sandboxed UI view.
---
## Runtime Configuration (`settings.json`)
The server hot-reloads `${PLUGIN_DATA}/settings.json` on every call (default path: `~/.gemini/antigravity/plugin_data/excalidraw-board/settings.json`)—no rebuild or MCP restart needed:
```json
{
"smartDiff": true,
"globalBoardsDir": "~/Documents/Excalidraw",
"promptScopeOnManualOpen": true,
"projectRoots": []
}
```
- `smartDiff` (`true` by default): Enables content-focused semantic diffs, rolling checkpoints, tiered raw JSON (`<= 25` auto-raw), and a 1-line model context hint. Set to `false` to fall back to full element dumps on every read.
- `globalBoardsDir`: Directory used for non-project boards (default `~/Documents/Excalidraw`).
- `promptScopeOnManualOpen` (`true` by default): Shows the **Select Project** overlay when opened manually from the side pane without a single detected host workspace root.
- `projectRoots`: Optional list of parent directories (e.g., `["~/Projects"]`) whose immediate subdirectories are automatically listed in the project switcher.
> **Language**: The UI and Excalidraw canvas default to English (`en`). Simplified Chinese (`zh-CN`) is also bundled in the local vendor build and can be switched anytime from Excalidraw's built-in canvas menu.
---
## Development & Updates
| Command | Description |
|---|---|
| `npm run build` | Full build: local Excalidraw vendor chunks + UI shell |
| `npm run build:ui` | Fast rebuild of the UI shell only (`dist/src/app.html`) |
| `npm run build:vendor` | Rebuild gzipped Excalidraw vendor chunks (`dist/vendor/`) |
| `npm run verify:bundle` | Assert shell `< 1.5 MiB`, chunks `<= 500 KB`, zero remote JS/CSS, and vendor integrity |
| `npm run check-updates` | Check outdated frontend dependencies |
| `npm run update-frameworks` | Update compatible minor versions, type-check, rebuild, and verify bundle limits |
After UI-only edits (`npm run build:ui`), simply close and reopen the side-pane Excalidraw tab. After server edits (`server/*.mjs`), restart the `excalidraw-board_board` MCP server in Antigravity.
---
## Repository Layout
```text
excalidraw-board/
├── server/
│ ├── index.mjs # Stdio MCP server & MCP App resource/tool handlers
│ ├── storage.mjs # Dual-layer .excalidraw storage, project registry & checkpoints
│ └── diff.mjs # Semantic content diff & lightweight structure summarizer
├── src/
│ ├── App.tsx # MCP App host bridge, auto-save, polling & toolbar shell
│ ├── components/
│ │ ├── BoardPicker.tsx # Linked {Project ▾} / {File ▾} toolbar switchers
│ │ ├── SheetDropdown.tsx # Reusable Excalidraw-sheet popover dropdown
│ │ └── ScopePickerOverlay.tsx # Pre-canvas Select Project overlay
│ ├── utils/
│ │ ├── boardNaming.ts # Draft naming & element normalization helpers
│ │ └── loadLocalExcalidraw.ts # Chunked gzip vendor loader over MCP RPC
│ ├── vendor/
│ │ └── excalidraw-entry.ts # Trimmed Excalidraw IIFE entry
│ └── global.css # Light/dark tokens & Excalidraw-sheet styling
├── scripts/
│ ├── build-vendor-chunks.mjs # Gzip & <450 KB base64 chunker
│ └── verify-bundle.mjs # Size & zero-CDN integrity guardrails
├── plugin/ # Ready-to-mount Antigravity plugin template & skill
├── vite.config.ts # Single-file UI shell build config
├── vite.vendor.config.ts # Trimmed Excalidraw vendor build config
└── LICENSE # MIT License
```
---
## License
[MIT](./LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues