Skip to main content
Glama
tldraw-mcp

tldraw-mcp

by m9810223

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

create_empty_file

Crea un .tldr nuevo con una página predeterminada

create_page

Añade una nueva página

list_pages

Lista las páginas con id, nombre e índice de orden

move_to_page

Mueve formas; bindings: 'error' | 'pull' | 'cut' controla el manejo de enlaces

Formas

Herramienta

Qué hace

create_rect

Crea un rectángulo (forma geométrica)

create_text

Crea una forma de texto

create_group

Agrupa formas cambiando su padre

ungroup

Disuelve un grupo, reasignando sus hijos al padre del grupo

connect

Flecha + enlaces entre dos formas en la misma página

list_shapes

Lista formas: solo id, tipo, x, y, etiqueta

get_shape

Registro completo de una forma por id

update_shape

Parche de fusión superficial (usa { "props": {...} } anidado para editar propiedades)

delete_shape

Elimina por id; cascade: true (predeterminado) también elimina flechas y enlaces adjuntos

Descubrimiento y vía de escape (inspirado en el tldraw-mcp-app oficial)

Herramienta

Qué hace

Coste de tokens

search_api

Lista tipos de formas soportados + propiedades requeridas curadas. Pasa {type, verbose:true} para volcar nombres de propiedades en vivo desde @tldraw/tlschema para cualquier tipo (incluidos los que no están en la lista curada)

bajo / medio

exec_jq

Ejecuta un filtro jq contra el archivo. write=true persiste (primero hace un punto de control automático)

variable

Puntos de control (seguridad)

Herramienta

Qué hace

Coste de tokens

save_checkpoint

Copia el .tldr a una copia de seguridad con marca de tiempo

bajo

list_checkpoints

Lista copias de seguridad, de la más nueva a la más antigua

bajo

restore_checkpoint

Restaura una copia de seguridad (la más reciente si se omite checkpoint)

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-mcp

La 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#abc1234

Opción 2 · Instalación global

npm install -g github:m9810223/tldraw-mcp
tldraw-mcp   # the bin is on PATH

Opción 3 · Repositorio privado vía SSH

npx -y git+ssh://git@github.com/m9810223/tldraw-mcp.git

Opció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 stdin

Requisitos

  • Node.js ≥ 20 (impuesto por engines.node)

  • jq en el PATH (solo requerido para la herramienta exec_jq)

    • macOS: brew install jq

    • Debian/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-mcp

Añ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

~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

Cursor

~/.cursor/mcp.json

VS Code

.vscode/mcp.json

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.

tldraw-mcp-app oficial

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 (search, exec) + puntos de control

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 elementos

  • No hay herramientas de alineación / distribución (usa update_shape para establecer x/y directamente, o exec_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_api se 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 tools
connectA

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

    A3.6/5.0

    Scored across 18 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers