Skip to main content
Glama

delete_element

Remove an element from an Excalidraw diagram by specifying its unique ID to clean up or edit your visual workspace.

Instructions

Delete an Excalidraw element by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • Main tool handler function deleteElementTool that parses input args using ElementIdSchema, calls client.deleteElement(id), and returns success/error response
    import type { CanvasClient } from '../canvas-client.js'; import { ElementIdSchema } from '../schemas/element.js'; export async function deleteElementTool( args: unknown, client: CanvasClient ) { const { id } = ElementIdSchema.parse(args); const deleted = await client.deleteElement(id); if (!deleted) throw new Error(`Element ${id} not found`); return { success: true, message: `Element ${id} deleted` }; }
  • Tool registration for 'delete_element' with server.tool(), including description, schema validation, and async handler that calls client.deleteElement
    // --- Tool: delete_element --- server.tool( 'delete_element', 'Delete an Excalidraw element by ID', { id: IdZ }, async ({ id }) => { try { const deleted = await client.deleteElement(id); if (!deleted) throw new Error(`Element ${id} not found`); return { content: [{ type: 'text', text: `Element ${id} deleted` }] }; } catch (err) { return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true }; } }
  • ElementIdSchema definition using Zod to validate the id parameter (string with max length constraint)
    export const ElementIdSchema = z .object({ id: z.string().max(LIMITS.MAX_ID_LENGTH), }) .strict();
  • Canvas client deleteElement method that performs HTTP DELETE request to /api/elements/{id} endpoint
    async deleteElement(id: string): Promise<boolean> { const res = await fetch( `${this.baseUrl}/api/elements/${this.safePath(id)}`, { method: 'DELETE', headers: this.headers() } ); if (res.status === 404) return false; if (!res.ok) throw new Error(`Canvas error: ${res.status}`); return true; }
  • Canvas client adapter deleteElement method that performs store.delete operation with logging
    async deleteElement(id: string): Promise<boolean> { const deleted = await this.store.delete(id); if (deleted) logger.debug({ id }, 'Element deleted'); return deleted; }

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