Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

delete_element

Remove a specific element from an Excalidraw diagram by its unique ID using the structured API of the Excalidraw MCP Server.

Instructions

Delete an Excalidraw element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • Main handler logic for the 'delete_element' tool: validates input using ElementIdSchema, calls deleteElementOnCanvas helper, checks success, logs, and returns formatted response.
    case 'delete_element': { const params = ElementIdSchema.parse(args); const { id } = params; // Delete element directly on HTTP server (no local storage) const canvasResult = await deleteElementOnCanvas(id); if (!canvasResult || !(canvasResult as ApiResponse).success) { throw new Error('Failed to delete element: HTTP server unavailable or element not found'); } const result = { id, deleted: true, syncedToCanvas: true }; logger.info('Element deleted via MCP and synced to canvas', result); return { content: [{ type: 'text', text: `Element deleted successfully!\n\n${JSON.stringify(result, null, 2)}\n\n✅ Synced to canvas` }] }; }
  • Tool definition including name, description, and inputSchema for 'delete_element' used in tool registration and capabilities.
    { name: 'delete_element', description: 'Delete an Excalidraw element', inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
  • Helper function that performs the actual deletion by syncing to the canvas HTTP API using syncToCanvas.
    async function deleteElementOnCanvas(elementId: string): Promise<any> { const result = await syncToCanvas('delete', { id: elementId }); return result; }
  • Zod schema for validating the 'id' input parameter used in the delete_element handler.
    const ElementIdSchema = z.object({ id: z.string() });
  • src/index.ts:490-504 (registration)
    Server initialization where all tools, including 'delete_element', are registered via the tools array and capabilities.
    const server = new Server( { name: "mcp-excalidraw-server", version: "1.0.2", description: "Advanced MCP server for Excalidraw with real-time canvas" }, { capabilities: { tools: Object.fromEntries(tools.map(tool => [tool.name, { description: tool.description, inputSchema: tool.inputSchema }])) } } );

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