unlock_elements
Modify Excalidraw diagram elements by unlocking them. Input element IDs to enable editing and updates within the Excalidraw MCP Server.
Instructions
Unlock elements to allow modification
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementIds | Yes |
Implementation Reference
- src/index.ts:834-858 (handler)Executes the unlock_elements tool by parsing input elementIds, updating each element's 'locked' property to false via the canvas API, awaiting all updates, counting successful updates, and returning a success summary or error.case 'unlock_elements': { const params = ElementIdsSchema.parse(args); const { elementIds } = params; try { // Unlock elements through HTTP API updates const updatePromises = elementIds.map(async (id) => { return await updateElementOnCanvas({ id, locked: false }); }); const results = await Promise.all(updatePromises); const successCount = results.filter(result => result).length; if (successCount === 0) { throw new Error('Failed to unlock any elements: HTTP server unavailable'); } const result = { unlocked: true, elementIds, successCount }; return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { throw new Error(`Failed to unlock elements: ${(error as Error).message}`); } }
- src/index.ts:403-416 (registration)Registers the unlock_elements tool in the tools array, including its name, description, and input schema requiring an array of elementIds.{ name: 'unlock_elements', description: 'Unlock elements to allow modification', inputSchema: { type: 'object', properties: { elementIds: { type: 'array', items: { type: 'string' } } }, required: ['elementIds'] } },
- src/index.ts:204-206 (schema)Zod schema used for input validation in the unlock_elements handler, defining elementIds as an array of strings.const ElementIdsSchema = z.object({ elementIds: z.array(z.string()) });
- src/index.ts:127-130 (helper)Helper function called by the handler to update an individual element on the canvas, setting locked: false, via syncToCanvas.async function updateElementOnCanvas(elementData: Partial<ServerElement> & { id: string }): Promise<ServerElement | null> { const result = await syncToCanvas('update', elementData); return result?.element || null; }