Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

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

Implementation Reference

  • 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'] } },
  • 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()) });
  • 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; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yctimlin/mcp_excalidraw'

If you have feedback or need assistance with the MCP directory API, please join our Discord server