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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool deletes an element, implying a destructive mutation, but doesn't clarify if deletion is permanent, requires specific permissions, affects related data, or has side effects (e.g., on grouped elements). This leaves significant gaps for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with no wasted words, front-loading the key action and resource. It efficiently communicates the core purpose without unnecessary elaboration, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's destructive nature, no annotations, no output schema, and low schema coverage, the description is insufficiently complete. It doesn't address critical aspects like error handling, confirmation requirements, or what happens post-deletion (e.g., if the element is grouped or locked), leaving the agent with incomplete operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantic context beyond the input schema, which has 0% description coverage. It specifies that the 'id' parameter refers to an 'Excalidraw element', but doesn't explain format, sourcing (e.g., from 'query_elements'), or constraints. With one parameter and low schema coverage, this provides baseline clarification but lacks depth.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and the resource ('an Excalidraw element by ID'), making the purpose immediately understandable. It distinguishes from siblings like 'update_element' or 'create_element' by specifying deletion, though it doesn't explicitly contrast with alternatives like 'batch_create_elements' or 'query_elements'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing element ID), exclusions (e.g., not for batch operations), or direct comparisons to siblings like 'update_element' or 'batch_create_elements', leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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