tldraw-mcp
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 | ||
| Erstellt eine neue | ||
| Fügt eine neue Seite hinzu | ||
| Listet Seiten mit ID, Name und Sortierindex auf | ||
| Verschiebt Formen; `bindings: 'error' | 'pull' | 'cut'` steuert die Bindungsbehandlung |
Formen
Tool | Was es tut |
| Erstellt ein Rechteck (Geo-Form) |
| Erstellt eine Textform |
| Gruppiert Formen durch Neuzuweisung der Elternschaft |
| Löst eine Gruppe auf und weist die Kinder dem Elternteil der Gruppe zu |
| Pfeil + Bindungen zwischen zwei Formen auf derselben Seite |
| Listet Formen auf — nur ID, Typ, x, y, Label |
| Vollständiger Datensatz einer Form nach ID |
| Shallow-Merge-Patch (verwenden Sie verschachtelte |
| Löschen nach ID; |
Erkundung & Notausgang (inspiriert von der offiziellen tldraw-mcp-app)
Tool | Was es tut | Token-Kosten |
| Listet unterstützte Formtypen + kuratierte erforderliche Eigenschaften auf. Übergeben Sie | niedrig / mittel |
| Führt einen | variiert |
Checkpoints (Sicherheit)
Tool | Was es tut | Token-Kosten |
| Kopiert | niedrig |
| Listet Backups auf, das neueste zuerst | niedrig |
| Stellt ein Backup wieder her (das aktuellste, wenn | 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-mcpDer 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#abc1234Option 2 · Globale Installation
npm install -g github:m9810223/tldraw-mcp
tldraw-mcp # the bin is on PATHOption 3 · Privates Repository über SSH
npx -y git+ssh://git@github.com/m9810223/tldraw-mcp.gitOption 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 stdinAnforderungen
Node.js ≥ 20 (erzwungen durch
engines.node)jqimPATH(nur für dasexec_jq-Tool erforderlich)macOS:
brew install jqDebian/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-mcpFü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 |
|
Cursor |
|
VS Code |
|
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 | 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 ( | 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 dazwischenKeine Ausrichtungs- / Verteilungstools (verwenden Sie
update_shape, umx/ydirekt zu setzen, oderexec_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_apiwird manuell parallel zur Live-Reflektion von@tldraw/tlschemagepflegt
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 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 required1720MIT
- AlicenseNot gradedqualityBmaintenanceA Codex stdio MCP server that generates simple tldraw product workflow diagrams as .tldr files.112 npm25MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes an Obsidian vault (search, read, create, and update notes) via Streamable HTTP.-