excalidraw-mcp-drawing
excalidraw-mcp-drawing
How to produce clean, attached, movable diagrams through the excalidraw-mcp server, and how to save them so arrows survive a round-trip.
Before you draw — the 4 hard rules
-
Ensure a connection first. Before any drawing tool, confirm you're connected to a room. If any tool returns
Not connected. Call connect() first., or the user hasn't provided a collab URL in this conversation, stop and ask the user for the Excalidraw collab URL (format:https://excalidraw.com/#room=<id>,<key>). Do not guess URLs, do not reuse URLs from other conversations, do not proceed without one. Once you have it, callconnectand continue. -
Always call
get_scenefirst when adding to a non-empty canvas. Existing elements have IDs and positions you need to avoid overlapping. Skipping this is the #1 cause of collisions. -
Pre-assign
idon every shape that an arrow will point to, in the samedraw_elementscall. Arrows reference shapes by ID viastartBinding.elementId/endBinding.elementId— auto-generated UUIDs won't be known at the time you author the arrow. -
Plan the full layout before the first tool call. Sketch positions (x, y, width, height) for all shapes and the routing of all arrows on paper or in your head. Partial drawing followed by "I'll figure arrows out later" produces overlaps and re-work.
Arrow binding — the subtle part
For an arrow to truly attach (move with the shape when the shape is dragged), three things must all be true: