Skip to main content
Glama

update_element

Modify existing diagram elements in Excalidraw by updating properties like position, size, colors, or text content using element IDs.

Instructions

Update an existing Excalidraw element by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes
typeNo
xNo
yNo
widthNo
heightNo
pointsNo
backgroundColorNo
strokeColorNo
strokeWidthNo
roughnessNo
opacityNo
textNo
fontSizeNo
fontFamilyNo
groupIdsNo
lockedNo
angleNo

Implementation Reference

  • Main tool registration and handler for update_element. This is the MCP server tool definition that processes incoming requests, validates inputs, filters undefined values, calls the client.updateElement method, and returns the updated element as JSON.
    // --- Tool: update_element ---
    server.tool(
      'update_element',
      'Update an existing Excalidraw element by ID',
      { id: IdZ, ...partialElementFields },
      async ({ id, ...data }) => {
        try {
          const clean = Object.fromEntries(
            Object.entries(data).filter(([_, v]) => v !== undefined)
          );
          const element = await client.updateElement(id, clean);
          return { content: [{ type: 'text', text: JSON.stringify(element, null, 2) }] };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
  • Schema definition for UpdateElementSchema that validates the tool input. It combines a required id field with all element fields from CreateElementSchema made partial (optional).
    export const UpdateElementSchema = z
      .object({
        id: z.string().max(LIMITS.MAX_ID_LENGTH),
      })
      .merge(CreateElementSchema.partial())
      .strict();
  • Reusable tool function that encapsulates the update logic. Parses args with UpdateElementSchema, extracts id and data, calls client.updateElement, and returns a success response with the updated element.
    export async function updateElementTool(
      args: unknown,
      client: CanvasClient
    ) {
      const { id, ...data } = UpdateElementSchema.parse(args);
      const element = await client.updateElement(id, data as Record<string, unknown>);
      return { success: true, element };
    }
  • CanvasClient.updateElement method that makes a PUT request to the canvas API endpoint (/api/elements/:id) to update an existing element. Handles error responses and returns the updated element.
    async updateElement(
      id: string,
      data: Record<string, unknown>
    ): Promise<ServerElement> {
      const res = await fetch(
        `${this.baseUrl}/api/elements/${this.safePath(id)}`,
        {
          method: 'PUT',
          headers: this.headers(),
          body: JSON.stringify(data),
        }
      );
    
      if (!res.ok) {
        const body = await res.json().catch(() => ({})) as ApiResponse;
        throw new Error(body.error ?? `Canvas error: ${res.status}`);
      }
    
      const body = await res.json() as { element?: ServerElement };
      return body.element!;
    }
  • CanvasClientAdapter.updateElement method for standalone mode. Retrieves existing element from in-memory store, merges with new data while preserving id, createdAt, and incrementing version, then stores the updated element.
    async updateElement(
      id: string,
      data: Record<string, unknown>
    ): Promise<ServerElement> {
      const existing = await this.store.get(id);
      if (!existing) throw new Error(`Element ${id} not found`);
    
      const updated: ServerElement = {
        ...existing,
        ...stripUndefined(data),
        id: existing.id,
        createdAt: existing.createdAt,
        updatedAt: new Date().toISOString(),
        version: existing.version + 1,
      };
    
      await this.store.set(id, updated);
      logger.debug({ id }, 'Element updated');
      return updated;
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 'Update' implies a mutation, but doesn't describe what happens if the ID doesn't exist, whether changes are reversible, permission requirements, or response format. For a mutation tool with 18 parameters and no annotation coverage, this is a significant gap in transparency.

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, efficient sentence with zero waste—it directly states the tool's core function without unnecessary words. It's appropriately sized and front-loaded, making it easy 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 complexity (18 parameters, mutation operation, no annotations, no output schema), the description is incomplete. It doesn't explain what fields can be updated, how partial updates work, error conditions, or return values, making it inadequate for safe and effective use by an AI agent.

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

Parameters1/5

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

The schema description coverage is 0%, meaning none of the 18 parameters are documented in the schema. The description adds no information about parameters beyond implying an 'id' is required, failing to compensate for the coverage gap. This leaves most parameters (e.g., 'type', 'x', 'backgroundColor') semantically unexplained.

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 verb ('Update') and resource ('an existing Excalidraw element by ID'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from siblings like 'create_element' or 'batch_create_elements', which would require mentioning that this modifies existing elements rather than creating new ones.

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, or comparisons to siblings like 'create_element' for new elements or 'delete_element' for removal, leaving the agent without contextual usage cues.

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