# Agent Instructions
## Commands
| Command | Description |
|---------|-------------|
| `bun run dev` | Run MCP server (stdio) |
| `bun run build` | Build MCP server |
| `bun run check` | TypeScript check |
### Widget
```bash
cd widget
bun run dev # Starts vite (port 3000) + WS server (port 4000)
```
## Architecture
```
src/
├── index.ts # MCP server entry point (tools)
├── bridge.ts # WebSocket client to widget
└── schema.ts # Zod schemas for tldraw types
widget/
├── src/App.tsx # tldraw canvas + WS handler
└── src/ws-server.ts # WebSocket relay server
```
## Protocol
MCP server ↔ Widget communication via WebSocket JSON messages:
```ts
// Commands (MCP → Widget)
{ type: "create", shape: {...}, requestId: "1" }
{ type: "update", id: "...", props: {...}, requestId: "2" }
{ type: "delete", ids: [...], requestId: "3" }
{ type: "connect", from: "...", to: "...", requestId: "4" }
{ type: "snapshot", requestId: "5" }
{ type: "clear", requestId: "6" }
// Responses (Widget → MCP)
{ id: "shape:xxx", requestId: "1" }
{ shapes: [...], bounds: {...}, requestId: "5" }
```