apps/mcp-app/README.md
This is the tldraw MCP app. It exposes an interactive tldraw canvas to AI agents via the Model Context Protocol app specification, so you can work in tldraw with agents in any MCP client that supports the MCP app spec.
The app has two parts: a server and a widget.
The server runs in Cloudflare Workers via src/worker.ts, using a Durable Object (TldrawMCP) backed by SQLite for persistent checkpoint storage.
It exposes:
search — query the extracted Editor API spec in a sandboxed dynamic workerexec — execute JavaScript against the live editor in the widget via a pending-request callback bridge_exec_callback — app-only tool the widget calls to resolve a pending exec requestsave_checkpoint / read_checkpoint — app-only tools used by the widget for checkpoint persistenceThe widget is a React app (src/widget/mcp-app.tsx) that renders a full tldraw canvas inside the MCP host's iframe.
When the AI calls exec, the server creates a pending request and the widget picks it up, runs the code through a focused editor proxy (src/widget/focused/) that translates between an AI-friendly shape format (simple string IDs, flat _type shapes) and tldraw's internal TLShape/TLShapeId types, then calls _exec_callback to resolve the pending request with the result. Canvas state is checkpointed to the Durable Object's SQLite database and to the browser's local storage.
The widget build depends on generated files (editor-api.json, method-map.json) that are extracted from the editor's TypeScript declarations. Before you can develop or build the mcp-app, you need to build the core packages first:
# from the repo root
yarn build
This produces the .tsbuild/ output that yarn extract-api reads from. The build and dev scripts run extract-api automatically, so you don't need to call it separately.
Run all commands from apps/mcp-app.
| Command | What it does |
|---|---|
yarn build | Build the widget HTML |
yarn dev | Build widget + start local Cloudflare worker (HTTP MCP on localhost:8787) |
yarn dev:tunnel | Build widget + start a Cloudflare tunnel + local worker with WORKER_ORIGIN set to the tunnel URL |
yarn deploy | Build widget + deploy the Cloudflare worker to production |
yarn dev:tunnel requires the cloudflared CLI to be installed on your machine.
The worker defaults to production-safe behavior in wrangler.toml, including setting MCP_IS_DEV="false". Local HTTP dev scripts override that with MCP_IS_DEV=true so local Claude/ChatGPT connectors suppress ui.domain while production deployments keep it enabled.
Add these two servers in ~/.cursor/mcp.json:
{
"mcpServers": {
"tldraw": {
"transport": "http",
"url": "https://tldraw-mcp-app.tldraw.workers.dev/mcp"
},
"tldraw-local": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://127.0.0.1:8787/mcp"]
}
}
}
For local Claude Desktop development, use claude_desktop_config.json with the local HTTP server:
{
"mcpServers": {
"tldraw-local": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://127.0.0.1:8787/mcp"]
}
}
}
If you'd like to try the remote MCP server in Claude Desktop, use the in-app connector flow rather than adding the production URL to claude_desktop_config.json.
tldrawhttps://tldraw-mcp-app.tldraw.workers.dev/mcp as the server URLThe Add custom connector option is not available on the free plan, so you may need Max or another paid plan.
If you need Notion access in Claude Desktop, use the Notion MCP connector for that separately.
ChatGPT requires an HTTPS origin, so you need a Cloudflare tunnel. You must be an admin of your OpenAI org/workspace to do local dev.
yarn dev:tunnel in apps/mcp-apphttps://...trycloudflare.com tunnel URLdev:tunnel automatically wires WORKER_ORIGIN to the tunnel URL and sets MCP_IS_DEV=true for the local worker.
apps/mcp-appdev or dev:tunnel)yarn build or rerunning any of the dev scripts.Reconnecting the server after changes is the most reliable way to pick up new code, especially when the widget HTML changes.
Find us on Twitter/X at @tldraw.
Have questions, comments or feedback? Join our discord. For the latest news and release notes, visit tldraw.dev.