Conversation
In order to give AI agents more flexible and powerful control over the tldraw canvas, this PR replaces the old server-side shape CRUD tools (create_shapes, update_shapes, delete_shapes) with an exec-based architecture where AI writes JavaScript that runs directly in the browser widget against a focused editor proxy. Reimplemented from [max/mcp-code-mode](https://github.com/tldraw/tldraw/tree/max/mcp-code-mode) with a clean commit history. Relates to #6832 **Key architectural changes:** - **Exec-based model**: AI writes JavaScript code that executes in the browser via a sandboxed `executeCode()` function, with access to the full Editor API through a focused editor proxy - **Focused editor proxy**: ES Proxy that transparently converts between AI-friendly focused shapes (simple string IDs, named colors, pixel font sizes) and tldraw's internal representation - **Search tool**: AI can query the Editor API spec (extracted at build time from TypeScript declarations) to discover methods, shape types, and helpers - **Server-widget callback bridge**: `PendingRequests` system enables async request-response between the Cloudflare Worker and browser widget - **Build-time API extraction**: TypeScript compiler API script reflects on tldraw packages to generate searchable API metadata and method classification maps ### Change type - [x] `improvement` ### Test plan 1. Deploy the MCP app and connect from Claude Desktop 2. Ask AI to create shapes — should use exec tool with focused editor proxy 3. Ask AI to search for Editor methods — should use search tool 4. Verify checkpoints persist across reconnections 5. Test in Cursor, VS Code, and ChatGPT hosts ### Release notes - Migrate MCP app from shape CRUD tools to exec-based architecture for more flexible AI canvas control ### Code changes | Section | LOC change | | -------------- | ---------------- | | Apps | +4504 / -2375 | | Documentation | +23 / -39 | | Config/tooling | +9 / -134 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )