tldraw-mcp
tldraw-mcp
JSON操作を介してtldrawの.tldrファイルを編集するための最小限のMCPサーバー。ヘッドレスで、ブラウザは不要です。
ステータス
動作するスケルトンです。スキーマバリデーションは組み込み済み(書き込みのたびに@tldraw/tlschemaバリデーターが実行されます)、フラクショナルインデックスには@tldraw/utilsを使用し、ファイル書き込みはproper-lockfileによって保護されています。出力は、コントラクトテストレイヤーのStore.loadStoreSnapshot()を通じて、実際のtldrawランタイムに対してエンドツーエンドで検証済みです。
Related MCP server: obsidian-codex-mcp
ツール
ファイル / ページライフサイクル
ツール | 説明 |
| デフォルトページを持つ新しい |
| 新しいページを追加 |
| ID、名前、順序インデックスを含むページリストを表示 |
| 図形を移動。 |
図形
ツール | 説明 |
| 長方形(ジオメトリ図形)を作成 |
| テキスト図形を作成 |
| 親子関係を設定して図形をグループ化 |
| グループを解除し、子要素をグループの親に再配置 |
| 同じページ内の2つの図形間に矢印とバインディングを作成 |
| 図形リストを表示(ID、タイプ、x、y、ラベルのみ) |
| IDによる図形の完全なレコードを取得 |
| シャローマージパッチ(プロパティ編集にはネストされた |
| IDで削除。 |
探索とエスケープハッチ(公式のtldraw-mcp-appに着想)
ツール | 説明 | トークンコスト |
| サポートされている図形タイプと必須プロパティのリストを表示。 | |
| ファイルに対して | 変動 |
チェックポイント(安全性)
ツール | 説明 | トークンコスト |
|
| 低 |
| バックアップを新しい順にリスト表示 | 低 |
| バックアップを復元( | 低 |
トークン節約設計:ツールはプリミティブな引数を取り、IDまたはokを返します。完全なJSONは、get_shapeを明示的に呼び出したときのみコンテキストに入ります。
インストール
オプション 1 · npx(インストール不要、推奨)
npx -y github:m9810223/tldraw-mcp初回実行時にクローン、npm installの実行、そしてdist/をビルドするprepareスクリプトがトリガーされます。以降の実行はキャッシュされます。
ブランチ / タグ / コミットを固定する場合:
npx -y github:m9810223/tldraw-mcp#main
npx -y github:m9810223/tldraw-mcp#v0.1.0
npx -y github:m9810223/tldraw-mcp#abc1234オプション 2 · グローバルインストール
npm install -g github:m9810223/tldraw-mcp
tldraw-mcp # the bin is on PATHオプション 3 · SSH経由のプライベートリポジトリ
npx -y git+ssh://git@github.com/m9810223/tldraw-mcp.gitオプション 4 · ローカルクローン(開発用)
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要件
Node.js ≥ 20 (
engines.nodeで強制)PATH上のjq(exec_jqツールにのみ必要)macOS:
brew install jqDebian/Ubuntu:
sudo apt-get install -y jq
Claude Codeへの接続
claude mcp add(推奨)。--セパレーターが必要です。これにより-yがclaude mcp addのフラグとしてではなく、npxに渡されるようになります:
claude mcp add tldraw -- npx -y github:m9810223/tldraw-mcpグローバル(全プロジェクト)には-s userを、リポジトリにチェックインされた.mcp.jsonには-s projectを追加します。デフォルトは-s local(このプロジェクト、あなたのマシン)です。
…または.mcp.json(プロジェクト)/ ~/.claude.json(ユーザーグローバル)を編集します:
{
"mcpServers": {
"tldraw": {
"command": "npx",
"args": ["-y", "github:m9810223/tldraw-mcp"]
}
}
}オプション2でグローバルインストールした場合:
{
"mcpServers": {
"tldraw": { "command": "tldraw-mcp" }
}
}Claude Codeを再起動すると、/mcpで17個のツールを持つtldrawサーバーがリストされるはずです。
他のMCPクライアントへの接続
JSONの形式は同じですが、設定ファイルの場所が異なります:
クライアント | 設定パス |
Claude Desktop |
|
Cursor |
|
VS Code |
|
.tldrファイルのブートストラップ
create_empty_fileツールを使用するか、tldraw.comから空のキャンバスを保存し、ツールでその絶対パスを指定してください。
create_empty_file({ file: "/tmp/demo.tldr" })公式tldraw-mcp-appとの設計比較
Cloudflareでホストされている公式MCPはsearch + exec(ライブtldrawエディターで任意のJSを実行)のみを公開しています。このスケルトンはその逆のアプローチ(.tldrファイルに対する型付きJSON編集)を取り、LLMが型付きツールで操作をカバーできない場合に備えて、探索パターン(search_api)とエスケープハッチ(exec_jq)を採用しています。
公式 | このスケルトン | |
トランスポート | streamable-http + sse (Cloudflare) | stdio (Claude Codeで直接動作) |
ランタイム | ウィジェットiframe内の実際のtldrawエディター | 純粋なNode、生のJSONを編集 |
ツール | 2 ( | 17: ファイル/ページライフサイクル + 9つの図形操作 + search_api + exec_jq + ckpt |
ライブプレビュー | あり (ウィジェットiframe) | なし (tldrawでファイルを開いて表示) |
カバレッジ | エディターAPI全体 | ジオメトリ / テキスト / 矢印 + jqエスケープハッチ |
既知のギャップ
index(Zオーダー)は現在の最大値の上に追加することのみサポートしており、間への挿入はできません整列 / 分布ツールはありません(
update_shapeでx/yを直接設定するか、exec_jqを使用してください)画像 / 動画 / アセットのサポートはありません
スキーマバージョンの固定は情報提供のみを目的としています。新しいtldrawでファイルを開くと移行がトリガーされる可能性があります
search_apiのキュレーションリストは、ライブの@tldraw/tlschemaリフレクションと並行して手動で管理されています
アーキテクチャ
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)純粋なJSON操作 — @tldraw/storeなし、DOMなし、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.-