tldraw-mcp
tldraw-mcp
Servidor MCP minimalista para editar archivos .tldr de tldraw mediante manipulación de JSON. Sin interfaz gráfica, no requiere navegador.
Estado
Esqueleto funcional. La validación de esquemas está conectada (los validadores de @tldraw/tlschema se ejecutan antes de cada escritura), la indexación fraccionaria utiliza @tldraw/utils, y las escrituras de archivos están protegidas por proper-lockfile. La salida se verificó de extremo a extremo contra el tiempo de ejecución real de tldraw mediante Store.loadStoreSnapshot() en la capa de pruebas de contrato.
Related MCP server: obsidian-codex-mcp
Herramientas
Ciclo de vida de archivos / páginas
Herramienta | Qué hace |
| Crea un |
| Añade una nueva página |
| Lista las páginas con id, nombre e índice de orden |
| Mueve formas; |
Formas
Herramienta | Qué hace |
| Crea un rectángulo (forma geométrica) |
| Crea una forma de texto |
| Agrupa formas cambiando su padre |
| Disuelve un grupo, reasignando sus hijos al padre del grupo |
| Flecha + enlaces entre dos formas en la misma página |
| Lista formas: solo id, tipo, x, y, etiqueta |
| Registro completo de una forma por id |
| Parche de fusión superficial (usa |
| Elimina por id; |
Descubrimiento y vía de escape (inspirado en el tldraw-mcp-app oficial)
Herramienta | Qué hace | Coste de tokens |
| Lista tipos de formas soportados + propiedades requeridas curadas. Pasa | bajo / medio |
| Ejecuta un filtro | variable |
Puntos de control (seguridad)
Herramienta | Qué hace | Coste de tokens |
| Copia el | bajo |
| Lista copias de seguridad, de la más nueva a la más antigua | bajo |
| Restaura una copia de seguridad (la más reciente si se omite | bajo |
El diseño de ahorro de tokens: las herramientas toman argumentos primitivos y devuelven ids o ok. El JSON completo solo entra en el contexto cuando llamas a get_shape deliberadamente.
Instalación
Opción 1 · npx (sin instalación, recomendado)
npx -y github:m9810223/tldraw-mcpLa primera ejecución clona, ejecuta npm install y luego activa el script prepare que construye dist/. Las ejecuciones posteriores se almacenan en caché.
Fija una rama / etiqueta / commit:
npx -y github:m9810223/tldraw-mcp#main
npx -y github:m9810223/tldraw-mcp#v0.1.0
npx -y github:m9810223/tldraw-mcp#abc1234Opción 2 · Instalación global
npm install -g github:m9810223/tldraw-mcp
tldraw-mcp # the bin is on PATHOpción 3 · Repositorio privado vía SSH
npx -y git+ssh://git@github.com/m9810223/tldraw-mcp.gitOpción 4 · Clon local (para desarrollo)
git clone https://github.com/m9810223/tldraw-mcp.git
cd tldraw-mcp
npm install
npm run build
node dist/index.js # stdio MCP — waits on stdinRequisitos
Node.js ≥ 20 (impuesto por
engines.node)jqen elPATH(solo requerido para la herramientaexec_jq)macOS:
brew install jqDebian/Ubuntu:
sudo apt-get install -y jq
Conectar a Claude Code
claude mcp add (recomendado). El separador -- es necesario para que -y se pase a npx en lugar de ser analizado como una bandera de claude mcp add:
claude mcp add tldraw -- npx -y github:m9810223/tldraw-mcpAñade -s user para global (todos los proyectos) o -s project para un .mcp.json incluido en el repositorio. El valor predeterminado es -s local (este proyecto, tu máquina).
…o editando .mcp.json (proyecto) / ~/.claude.json (global del usuario):
{
"mcpServers": {
"tldraw": {
"command": "npx",
"args": ["-y", "github:m9810223/tldraw-mcp"]
}
}
}Si instalaste globalmente con la Opción 2:
{
"mcpServers": {
"tldraw": { "command": "tldraw-mcp" }
}
}Reinicia Claude Code, luego /mcp debería listar el servidor tldraw con 17 herramientas.
Conectar a otros clientes MCP
La misma estructura JSON, diferente ubicación del archivo de configuración:
Cliente | Ruta de configuración |
Claude Desktop |
|
Cursor |
|
VS Code |
|
Inicialización de un archivo .tldr
Usa la herramienta create_empty_file, o guarda un lienzo vacío desde tldraw.com y apunta las herramientas a la ruta absoluta.
create_empty_file({ file: "/tmp/demo.tldr" })Comparación de diseño frente al tldraw-mcp-app oficial
El MCP oficial alojado en Cloudflare solo expone search + exec (ejecutar cualquier JS en un Editor de tldraw en vivo). Este esqueleto va en la dirección opuesta: ediciones de JSON tipadas sobre archivos .tldr, y toma prestado el patrón de descubrimiento (search_api) y la vía de escape (exec_jq) para que un LLM pueda recurrir a ellos cuando las herramientas tipadas no cubren una operación.
| Este esqueleto | |
Transporte | streamable-http + sse (Cloudflare) | stdio (funciona directamente en Claude Code) |
Tiempo de ejecución | Editor de tldraw real en iframe de widget | Node puro, edita JSON sin procesar |
Herramientas | 2 ( | 17: ciclo de vida de archivo/página + 9 operaciones de forma + search_api + exec_jq + ckpt |
Vista previa en vivo | Sí (iframe de widget) | No (abre el archivo en tldraw para verlo) |
Cobertura | API completa del Editor | Geo / texto / flecha + vía de escape jq |
Brechas conocidas
index(orden z) solo admite añadir por encima del máximo actual; no permite insertar entre elementosNo hay herramientas de alineación / distribución (usa
update_shapepara establecerx/ydirectamente, oexec_jq)No hay soporte para imágenes / video / activos
El fijado de versión de esquema es solo informativo; abrir un archivo en un tldraw más nuevo puede activar migraciones
La lista curada de
search_apise mantiene manualmente junto con la reflexión en vivo de@tldraw/tlschema
Arquitectura
src/
index.ts MCP server entry, tool registration (stdio transport)
tools.ts Tool handlers + zod input schemas
shapes.ts tldraw record factories (geo/text/arrow/group/binding)
store.ts Load/save .tldr + withFileLock; helpers (id gen, indexing, find, page-of-shape, bindings-for-shape)
template.ts Empty .tldr generator using @tldraw/tlschema serialize()
validate.ts validateShape / validateBinding using createShapeValidator + createBindingValidator
checkpoint.ts Timestamped backups under .tldraw-mcp-checkpoints/
jq.ts Shell-out to jq for the exec_jq escape hatch
test/
unit/ store + validate (13 tests)
integration/ tools end-to-end on tmp .tldr (18 tests)
contract/ loadStoreSnapshot against real @tldraw/store (4 tests)Manipulación de JSON puro: sin @tldraw/store, sin DOM, sin React.
Available Tools
18 toolsconnectA
Connect two shapes with an arrow. Arrow position is binding-driven (start/end stored as 0,0 fallback). Returns arrow id + binding ids.
Inputs: file (required), fromId (required), toId (required), text.
create_empty_fileA
Create a new empty .tldr file with one default page. Errors if file exists unless overwrite=true.
Inputs: file (required), overwrite.
create_groupA
Group existing shapes into a new group. Reparents the given shape ids under a new group shape.
Inputs: file (required), childIds (required).
create_pageB
Create a new page in the document. Returns the new page id.
Inputs: file (required), name (required).
create_rectC
Create a rectangle shape on the main page. Returns its id.
Inputs: file (required), x (required), y (required), w (required), +3 more.
create_textC
Create a text shape on the main page. Returns its id.
Inputs: file (required), x (required), y (required), text (required), +2 more.
delete_shapeC
Delete a shape by id.
Inputs: file (required), id (required), cascade.
exec_jqA
Escape hatch: run a jq filter against the .tldr JSON. Set write=true to persist (auto-checkpoints first).
Inputs: file (required), filter (required), write.
get_shapeB
Get the full record of a single shape by id.
Inputs: file (required), id (required).
list_checkpointsA
List checkpoint backups for a .tldr file, newest first.
Inputs: file (required).
list_pagesB
List all pages with id, name, and ordering index.
Inputs: file (required).
list_shapesA
List shapes (id, type, x, y, label only - props omitted to save tokens).
Inputs: file (required), type.
move_to_pageB
Move shapes to a different page by reparenting them. Note: arrows and bindings should move together for correctness.
Inputs: file (required), shapeIds (required), pageId (required), bindings.
restore_checkpointA
Restore a checkpoint over the .tldr file. Omits checkpoint to restore the most recent.
Inputs: file (required), checkpoint.
save_checkpointA
Copy the .tldr file to a timestamped backup. Returns the backup path.
Inputs: file (required), label.
search_apiA
List supported tldraw shape types and their required props. Use this to discover what can be created before falling back to exec_jq.
Inputs: query, type, verbose.
ungroupA
Dissolve a group: reparent its children to the group's parent and delete the group shape.
Inputs: file (required), groupId (required).
update_shapeA
Update a shape via shallow merge. Pass nested {"props": {...}} to update props.
Inputs: file (required), id (required), patch (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool has a clearly distinct purpose, from creating shapes and pages to managing checkpoints and connecting shapes. The exec_jq escape hatch is intentionally broad but its role as a fallback is well-documented, avoiding confusion.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., create_rect, list_pages, update_shape). No mixed conventions or ambiguous verbs.
With 18 tools, the set is well-scoped for a drawing application: it covers shape CRUD, grouping, pages, checkpoints, and an escape hatch. The count feels complete without being overwhelming.
The toolset covers core operations but misses explicit tools for creating non-rectangle shapes (e.g., ellipses, lines). However, search_api and exec_jq fill these gaps, so agents can still achieve full functionality.
Maintenance
Related MCP Connectors
Collaborative whiteboard MCP server — create objects, connectors, C4 diagrams, and manage boards
Remote MCP server for notes, tasks, kanban boards and docs - the Slates agentic workspace
Hosted MCP server for Obsidian Sync vaults: read, search, edit notes. Not affiliated with Obsidian.
Related MCP Servers
- AlicenseAqualityDmaintenanceA minimal MCP server for AI-driven canvas manipulation and visualization using tldraw. It enables AI clients to programmatically create, update, and manage shapes, flowcharts, and frames on a live interactive canvas.92MIT
- AlicenseAqualityCmaintenanceLocal-first MCP server for working with an Obsidian vault. No API key required1719MIT
- AlicenseNot gradedqualityBmaintenanceA Codex stdio MCP server that generates simple tldraw product workflow diagrams as .tldr files.89 npm25MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes an Obsidian vault (search, read, create, and update notes) via Streamable HTTP.-