Skip to main content
Glama
tldraw-mcp

tldraw-mcp

by m9810223

tldraw-mcp

JSON操作を介してtldrawの.tldrファイルを編集するための最小限のMCPサーバー。ヘッドレスで、ブラウザは不要です。

ステータス

動作するスケルトンです。スキーマバリデーションは組み込み済み(書き込みのたびに@tldraw/tlschemaバリデーターが実行されます)、フラクショナルインデックスには@tldraw/utilsを使用し、ファイル書き込みはproper-lockfileによって保護されています。出力は、コントラクトテストレイヤーのStore.loadStoreSnapshot()を通じて、実際のtldrawランタイムに対してエンドツーエンドで検証済みです。

Related MCP server: obsidian-codex-mcp

ツール

ファイル / ページライフサイクル

ツール

説明

create_empty_file

デフォルトページを持つ新しい.tldrを作成

create_page

新しいページを追加

list_pages

ID、名前、順序インデックスを含むページリストを表示

move_to_page

図形を移動。bindings: 'error' | 'pull' | 'cut'でバインディングの処理を制御

図形

ツール

説明

create_rect

長方形(ジオメトリ図形)を作成

create_text

テキスト図形を作成

create_group

親子関係を設定して図形をグループ化

ungroup

グループを解除し、子要素をグループの親に再配置

connect

同じページ内の2つの図形間に矢印とバインディングを作成

list_shapes

図形リストを表示(ID、タイプ、x、y、ラベルのみ)

get_shape

IDによる図形の完全なレコードを取得

update_shape

シャローマージパッチ(プロパティ編集にはネストされた{ "props": {...} }を使用)

delete_shape

IDで削除。cascade: true(デフォルト)で関連する矢印とバインディングも削除

探索とエスケープハッチ(公式のtldraw-mcp-appに着想)

ツール

説明

トークンコスト

search_api

サポートされている図形タイプと必須プロパティのリストを表示。{type, verbose:true}を渡すと、@tldraw/tlschemaからライブプロパティ名をダンプ(リスト外のタイプも含む)

exec_jq

ファイルに対してjqフィルターを実行。write=trueで永続化(先に自動チェックポイント作成)

変動

チェックポイント(安全性)

ツール

説明

トークンコスト

save_checkpoint

.tldrをタイムスタンプ付きバックアップにコピー

低

list_checkpoints

バックアップを新しい順にリスト表示

低

restore_checkpoint

バックアップを復元(checkpointが省略された場合は最新のもの)

低

トークン節約設計:ツールはプリミティブな引数を取り、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 jq

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

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

Cursor

~/.cursor/mcp.json

VS Code

.vscode/mcp.json

.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)を採用しています。

公式 tldraw-mcp-app

このスケルトン

トランスポート

streamable-http + sse (Cloudflare)

stdio (Claude Codeで直接動作)

ランタイム

ウィジェットiframe内の実際のtldrawエディター

純粋なNode、生のJSONを編集

ツール

2 (search, exec) + チェックポイント

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