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

직사각형(geo 도형) 생성

create_text

텍스트 도형 생성

create_group

도형을 재부모화하여 그룹화

ungroup

그룹을 해제하고 자식 도형을 그룹의 부모로 재부모화

connect

같은 페이지에 있는 두 도형 간의 화살표 + 바인딩 연결

list_shapes

도형 목록 표시 — id, type, x, y, label만 표시

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

Geo / 텍스트 / 화살표 + jq 탈출구

알려진 제한 사항

  • index (z-order)는 현재 최대값 위로 추가하는 것만 지원하며, 중간 삽입은 지원하지 않음

  • 정렬 / 배분 도구 없음 (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
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers