Skip to content

feat(mcp): add update_view tool for editing existing diagrams#52

Open
breadoncee wants to merge 2 commits intoexcalidraw:mainfrom
breadoncee:feat/update-view
Open

feat(mcp): add update_view tool for editing existing diagrams#52
breadoncee wants to merge 2 commits intoexcalidraw:mainfrom
breadoncee:feat/update-view

Conversation

@breadoncee
Copy link
Copy Markdown

@breadoncee breadoncee commented Mar 21, 2026

updae_view_excalidraw.mp4

Summary

  • Adds update_view tool that edits existing diagrams by applying changes on top of a saved checkpoint, so the model only needs to send new/changed elements instead of the full diagram
  • Widget-side support: reads checkpointId from tool input and restores base state during both streaming and final render
  • Improved input validation in create_view (Buffer.byteLength for size check, array type guard) and updated cheat sheet to document update_view, container cascade deletes, and editing workflow

Test plan

  • Create a diagram with create_view, note the returned checkpointId
  • Use update_view with that checkpointId to add new elements — verify base elements persist
  • Override an existing element by sending it with the same id but different properties
  • Delete elements via {"type":"delete","ids":"..."} and verify container cascade removes bound text
  • Verify streaming renders progressively (base state loads, then new elements animate in)
  • Confirm a new checkpointId is returned after update_view for chaining edits
  • Test error cases: invalid checkpointId, invalid JSON, non-array input

Closes #29

…draw#29)

Adds a new `update_view` tool that takes a `checkpointId` and `elements`,
allowing the model to edit a previously created diagram without recreating
it from scratch. The server loads the base state from the checkpoint,
applies deletes, merges new elements, and saves a new checkpoint.

The widget now also handles the top-level `checkpointId` field during
streaming so the base diagram is visible while new elements stream in.
- Fix byte size check: use Buffer.byteLength instead of string length
  (multi-byte chars could bypass limit) — fixed in both create_view and
  update_view
- Add Array.isArray validation after JSON.parse in both tools
- Dedup elements by ID: new elements with same ID as base automatically
  override the base version (no delete+add needed)
- Document override semantics and containerId cascade delete in cheat sheet
- Add sync comments linking widget-side and server-side merge logic
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 21, 2026

@breadoncee is attempting to deploy a commit to the Excalidraw Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add an update_view to edit diagram created using create_view

1 participant