Add agent drawing commands, session management, and MCP write tools

- Add CreateDrawingElement, UpdateDrawingElement, DeleteDrawingElement,
  ClearDrawingElements to WebSocket protocol and MCP bridge
- Add multi-session/tab support with SessionStore shared state
- Add bidirectional agent-GUI sync via broadcast + mpsc channels
- Update README with correct OpenCode MCP config format and new tools
- Fix dead code warning, clean up gitignore
This commit is contained in:
David Ibia
2026-02-09 15:38:34 +01:00
parent d248864ee2
commit b140d93163
11 changed files with 1016 additions and 68 deletions

View File

@@ -58,6 +58,43 @@ This builds two binaries:
- `target/release/agcanvas` — The desktop app
- `target/release/agcanvas-mcp` — The MCP server bridge
### Install to PATH
After building, symlink (or copy) the binaries so they're available system-wide:
**macOS / Linux:**
```bash
sudo ln -sf "$(pwd)/target/release/agcanvas" /usr/local/bin/agcanvas
sudo ln -sf "$(pwd)/target/release/agcanvas-mcp" /usr/local/bin/agcanvas-mcp
```
Or install to a user-local directory (no sudo):
```bash
mkdir -p ~/.local/bin
ln -sf "$(pwd)/target/release/agcanvas" ~/.local/bin/agcanvas
ln -sf "$(pwd)/target/release/agcanvas-mcp" ~/.local/bin/agcanvas-mcp
```
> Make sure `~/.local/bin` is in your `PATH`. Add `export PATH="$HOME/.local/bin:$PATH"` to your `~/.zshrc` or `~/.bashrc` if needed.
**Windows (PowerShell, run as Administrator):**
```powershell
New-Item -ItemType SymbolicLink -Path "$env:USERPROFILE\.local\bin\agcanvas.exe" -Target "$(Get-Location)\target\release\agcanvas.exe" -Force
New-Item -ItemType SymbolicLink -Path "$env:USERPROFILE\.local\bin\agcanvas-mcp.exe" -Target "$(Get-Location)\target\release\agcanvas-mcp.exe" -Force
```
> Make sure `%USERPROFILE%\.local\bin` is in your system `PATH`. Or use an existing PATH directory like `C:\Users\<you>\AppData\Local\Microsoft\WindowsApps`.
**Verify:**
```bash
agcanvas --help
agcanvas-mcp --help
```
### Requirements
- Rust 1.70+
@@ -118,14 +155,15 @@ Add to your project's `.mcp.json` (or `~/.claude/mcp.json` for global):
### Setup for OpenCode
Add to your `opencode.json`:
Add to your `opencode.json` (project-level) or `~/.config/opencode/opencode.json` (global):
```json
{
"mcpServers": {
"mcp": {
"agcanvas": {
"command": "agcanvas-mcp",
"args": ["--port", "9876"]
"type": "local",
"command": ["agcanvas-mcp", "--port", "9876"],
"enabled": true
}
}
}
@@ -135,9 +173,7 @@ Add to your `opencode.json`:
Same MCP config format — add the `agcanvas` entry to your Codex MCP configuration.
> **Note:** Make sure `agcanvas-mcp` is in your PATH, or use the full path to the binary (e.g., `/path/to/target/release/agcanvas-mcp`). agcanvas must be running for the MCP tools to work.
See [`examples/mcp-configs/`](examples/mcp-configs/) for ready-to-copy configuration files.
> **Note:** Make sure `agcanvas-mcp` is in your PATH (e.g., `~/.local/bin`), or use the full path to the binary. agcanvas must be running for the MCP tools to work.
### MCP Tools
@@ -150,6 +186,10 @@ See [`examples/mcp-configs/`](examples/mcp-configs/) for ready-to-copy configura
| `get_elements_at_point` | Find elements at an (x, y) coordinate |
| `get_drawing_elements` | Get all user-drawn shapes (rects, ellipses, lines, arrows, text) |
| `generate_code` | Generate code stubs (html, react, tailwind, svelte, vue) |
| `create_drawing_element` | Create a shape on the canvas (Rectangle, Ellipse, Line, Arrow, Text) |
| `update_drawing_element` | Update an existing drawing element's shape or style |
| `delete_drawing_element` | Delete a drawing element by ID |
| `clear_drawing_elements` | Clear all drawing elements from the canvas |
All tools accept an optional `session_id` parameter. If omitted, the active session is used.