Skip to main content
Glama

unlock_elements

Modify locked elements in Excalidraw diagrams by unlocking them for editing.

Instructions

Unlock elements to allow modification

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementIdsYes

Implementation Reference

  • Main unlock_elements tool handler: parses args using ElementIdsSchema, iterates through element IDs, calls client.updateElement(id, { locked: false }) for each, and returns success count.
    export async function unlockElementsTool(
      args: unknown,
      client: CanvasClient
    ) {
      const { elementIds } = ElementIdsSchema.parse(args);
      let unlockedCount = 0;
    
      for (const id of elementIds) {
        await client.updateElement(id, { locked: false });
        unlockedCount++;
      }
    
      return { success: true, unlockedCount };
    }
  • Tool registration in MCP main server: registers 'unlock_elements' tool with description, schema { elementIds: IdsZ }, and inline async handler that updates elements and returns formatted response.
    // --- Tool: unlock_elements ---
    server.tool(
      'unlock_elements',
      'Unlock elements to allow modification',
      { elementIds: IdsZ },
      async ({ elementIds }) => {
        try {
          let count = 0;
          for (const eid of elementIds) {
            await client.updateElement(eid, { locked: false });
            count++;
          }
          return { content: [{ type: 'text', text: JSON.stringify({ unlockedCount: count }, null, 2) }] };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
  • ElementIdsSchema: input validation schema for unlock_elements tool, defines an object with elementIds array (string[], min 1, max MAX_ELEMENT_IDS).
    export const ElementIdsSchema = z
      .object({
        elementIds: z
          .array(z.string().max(LIMITS.MAX_ID_LENGTH))
          .min(1)
          .max(LIMITS.MAX_ELEMENT_IDS),
      })
      .strict();
  • Sandbox server registration: unlock_elements registered with noop handler for capability scanning.
    server.tool('unlock_elements', 'Unlock elements to allow modification', { elementIds: IdsZ }, noop);
  • Export of unlockElementsTool from tools module for use in the MCP server.
    export { unlockElementsTool } from './unlock-elements.js';

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/debu-sinha/excalidraw-mcp-server'

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