Skip to main content
Glama
tldraw-mcp

tldraw-mcp

by m9810223

tldraw-mcp

Minimaler MCP-Server zum Bearbeiten von tldraw .tldr-Dateien mittels JSON-Manipulation. Headless, kein Browser erforderlich.

Status

Funktionsfähiges Grundgerüst. Schema-Validierung ist eingebunden (@tldraw/tlschema-Validatoren laufen vor jedem Schreibvorgang), fraktionale Indizierung nutzt @tldraw/utils, Dateischreibvorgänge werden durch proper-lockfile abgesichert. Die Ausgabe wurde durchgängig gegen die echte tldraw-Laufzeitumgebung mittels Store.loadStoreSnapshot() in der Vertragstestschicht verifiziert.

Related MCP server: obsidian-codex-mcp

Tools

Datei- / Seitenlebenszyklus

Tool

Was es tut

create_empty_file

Erstellt eine neue .tldr-Datei mit einer Standardseite

create_page

Fügt eine neue Seite hinzu

list_pages

Listet Seiten mit ID, Name und Sortierindex auf

move_to_page

Verschiebt Formen; `bindings: 'error'

'pull'

'cut'` steuert die Bindungsbehandlung

Formen

Tool

Was es tut

create_rect

Erstellt ein Rechteck (Geo-Form)

create_text

Erstellt eine Textform

create_group

Gruppiert Formen durch Neuzuweisung der Elternschaft

ungroup

Löst eine Gruppe auf und weist die Kinder dem Elternteil der Gruppe zu

connect

Pfeil + Bindungen zwischen zwei Formen auf derselben Seite

list_shapes

Listet Formen auf — nur ID, Typ, x, y, Label

get_shape

Vollständiger Datensatz einer Form nach ID

update_shape

Shallow-Merge-Patch (verwenden Sie verschachtelte { "props": {...} } für Eigenschaftsänderungen)

delete_shape

Löschen nach ID; cascade: true (Standard) entfernt auch angehängte Pfeile + Bindungen

Erkundung & Notausgang (inspiriert von der offiziellen tldraw-mcp-app)

Tool

Was es tut

Token-Kosten

search_api

Listet unterstützte Formtypen + kuratierte erforderliche Eigenschaften auf. Übergeben Sie {type, verbose:true}, um Live-Eigenschaftsnamen von @tldraw/tlschema für jeden Typ auszugeben (einschließlich solcher, die nicht in der kuratierten Liste enthalten sind)

niedrig / mittel

exec_jq

Führt einen jq-Filter auf die Datei aus. write=true speichert die Änderungen (vorheriger automatischer Checkpoint)

variiert

Checkpoints (Sicherheit)

Tool

Was es tut

Token-Kosten

save_checkpoint

Kopiert .tldr in ein Backup mit Zeitstempel

niedrig

list_checkpoints

Listet Backups auf, das neueste zuerst

niedrig

restore_checkpoint

Stellt ein Backup wieder her (das aktuellste, wenn checkpoint weggelassen wird)

niedrig

Das Token-sparende Design: Tools akzeptieren primitive Argumente und geben IDs oder ok zurück. Das vollständige JSON gelangt nur in den Kontext, wenn Sie gezielt get_shape aufrufen.

Installation

Option 1 · npx (keine Installation, empfohlen)

npx -y github:m9810223/tldraw-mcp

Der erste Durchlauf klont das Repository, führt npm install aus und löst dann das prepare-Skript aus, das dist/ erstellt. Nachfolgende Durchläufe werden zwischengespeichert.

Einen Branch / Tag / Commit fixieren:

npx -y github:m9810223/tldraw-mcp#main
npx -y github:m9810223/tldraw-mcp#v0.1.0
npx -y github:m9810223/tldraw-mcp#abc1234

Option 2 · Globale Installation

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

Option 3 · Privates Repository über SSH

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

Option 4 · Lokaler Klon (für die Entwicklung)

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

Anforderungen

  • Node.js ≥ 20 (erzwungen durch engines.node)

  • jq im PATH (nur für das exec_jq-Tool erforderlich)

    • macOS: brew install jq

    • Debian/Ubuntu: sudo apt-get install -y jq

Anbindung an Claude Code

claude mcp add (empfohlen). Das ---Trennzeichen ist erforderlich, damit -y an npx übergeben wird, anstatt als Flag für claude mcp add interpretiert zu werden:

claude mcp add tldraw -- npx -y github:m9810223/tldraw-mcp

Fügen Sie -s user für global (alle Projekte) oder -s project für eine .mcp.json hinzu, die im Repository eingecheckt ist. Standard ist -s local (dieses Projekt, Ihr lokaler Rechner).

…oder durch Bearbeiten von .mcp.json (Projekt) / ~/.claude.json (benutzerweit):

{
  "mcpServers": {
    "tldraw": {
      "command": "npx",
      "args": ["-y", "github:m9810223/tldraw-mcp"]
    }
  }
}

Falls Sie mit Option 2 global installiert haben:

{
  "mcpServers": {
    "tldraw": { "command": "tldraw-mcp" }
  }
}

Starten Sie Claude Code neu, dann sollte /mcp den tldraw-Server mit 17 Tools auflisten.

Anbindung an andere MCP-Clients

Gleiches JSON-Format, anderer Speicherort der Konfigurationsdatei:

Client

Konfigurationspfad

Claude Desktop

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

Cursor

~/.cursor/mcp.json

VS Code

.vscode/mcp.json

Bootstrapping einer .tldr-Datei

Verwenden Sie das create_empty_file-Tool oder speichern Sie eine leere Arbeitsfläche von tldraw.com und geben Sie den absoluten Pfad für die Tools an.

create_empty_file({ file: "/tmp/demo.tldr" })

Designvergleich zur offiziellen tldraw-mcp-app

Die von Cloudflare gehostete offizielle MCP bietet nur search + exec (Ausführen von beliebigem JS in einem Live-tldraw-Editor). Dieses Grundgerüst geht den umgekehrten Weg — typisierte JSON-Bearbeitungen über .tldr-Dateien — und übernimmt das Erkennungsmuster (search_api) sowie den Notausgang (exec_jq), damit ein LLM ausweichen kann, wenn typisierte Tools eine Operation nicht abdecken.

Offizielle tldraw-mcp-app

Dieses Grundgerüst

Transport

streamable-http + sse (Cloudflare)

stdio (funktioniert direkt in Claude Code)

Laufzeit

Echter tldraw-Editor im Widget-Iframe

Reines Node, bearbeitet rohes JSON

Tools

2 (search, exec) + Checkpoints

17: Datei/Seiten-Lebenszyklus + 9 Form-Operationen + search_api + exec_jq + ckpt

Live-Vorschau

Ja (Widget-Iframe)

Nein (Datei in tldraw öffnen zur Ansicht)

Abdeckung

Gesamte Editor-API

Geo / Text / Pfeil + jq-Notausgang

Bekannte Lücken

  • index (Z-Reihenfolge) unterstützt nur das Anhängen über dem aktuellen Maximum — kein Einfügen dazwischen

  • Keine Ausrichtungs- / Verteilungstools (verwenden Sie update_shape, um x/y direkt zu setzen, oder exec_jq)

  • Keine Unterstützung für Bilder / Videos / Assets

  • Die Schema-Versionsfixierung dient nur zur Information — das Öffnen einer Datei in einem neueren tldraw kann Migrationen auslösen

  • Die kuratierte Liste von search_api wird manuell parallel zur Live-Reflektion von @tldraw/tlschema gepflegt

Architektur

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)

Reine JSON-Manipulation — kein @tldraw/store, kein DOM, kein 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