Skip to main content
Glama
Abdullah007bajwa

Excalidraw MCP Server

delete_element

Remove specific elements from Excalidraw diagrams by ID to clean up or edit visual content.

Instructions

Delete an Excalidraw element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • The switch case handler in the CallToolRequestSchema that executes the delete_element tool: parses the ID using Zod schema, verifies existence in the elements Map, deletes the element, and returns a JSON response indicating success.
    case 'delete_element': {
      const params = ElementIdSchema.parse(args);
      const { id } = params;
      
      if (!elements.has(id)) throw new Error(`Element with ID ${id} not found`);
      
      elements.delete(id);
      
      return {
        content: [{ type: 'text', text: JSON.stringify({ id, deleted: true }, null, 2) }]
      };
    }
  • src/index.js:145-154 (registration)
    Registration of the delete_element tool in the MCP server capabilities, including its description and input schema.
    delete_element: {
      description: 'Delete an Excalidraw element',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string' }
        },
        required: ['id']
      }
    },
  • Zod schema (ElementIdSchema) used to validate and parse the input arguments (id) for the delete_element handler.
    const ElementIdSchema = z.object({
      id: z.string()
    });

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/Abdullah007bajwa/mcp_excalidraw'

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