Skip to main content
Glama
Abdullah007bajwa

Excalidraw MCP Server

update_element

Modify existing elements in Excalidraw diagrams by updating properties like position, size, colors, text, and styling attributes to refine visual content.

Instructions

Update an existing Excalidraw element

Input Schema

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

Implementation Reference

  • Switch case handler that executes the 'update_element' tool: validates input using Zod schemas, retrieves the existing element, applies updates (handling fontFamily and opacity specially), increments version, stores the updated element, and returns confirmation.
    case 'update_element': {
      const rawParams = ElementSchema.partial().extend({ id: ElementIdSchema.shape.id }).passthrough().parse(args);
      const { id, ...updates } = rawParams;
    
      if (!id) throw new Error('Element ID is required');
    
      const existingElement = elements.get(id);
      if (!existingElement) throw new Error(`Element with ID ${id} not found`);
    
      if (typeof updates.fontFamily === 'string') {
        const fontMap = { "virgil": 1, "helvetica": 2, "cascadia": 3 };
        updates.fontFamily = fontMap[updates.fontFamily.toLowerCase()] ?? existingElement.fontFamily;
      }
    
      if (updates.opacity !== undefined) {
        updates.opacity = Math.max(0, Math.min(100, updates.opacity * 100));
      }
    
      const potentialNewElement = {
        ...existingElement,
        ...updates,
        version: (existingElement.version || 0) + 1,
        versionNonce: Math.floor(Math.random() * 2 ** 31),
        updated: Date.now()
      };
    
      Object.keys(potentialNewElement).forEach(key => {
        if (key === 'createdAt' || key === 'updatedAt') delete potentialNewElement[key];
      });
    
      elements.set(id, potentialNewElement);
      logger.info(`Element ${id} updated.`);
      logger.debug('Stored element data after update:', potentialNewElement);
    
      return {
        content: [{ type: 'text', text: JSON.stringify({ id: potentialNewElement.id, updated: true, version: potentialNewElement.version }, null, 2) }]
      };
    }
  • JSON schema for 'update_element' tool input parameters, registered in the MCP server's capabilities.tools, defining properties like id (required), type, position, styling, etc.
    update_element: {
      description: 'Update an existing Excalidraw element',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string' },
          type: { 
            type: 'string', 
            enum: Object.values(EXCALIDRAW_ELEMENT_TYPES) 
          },
          x: { type: 'number' },
          y: { type: 'number' },
          width: { type: 'number' },
          height: { type: 'number' },
          backgroundColor: { type: 'string' },
          strokeColor: { type: 'string' },
          strokeWidth: { type: 'number' },
          roughness: { type: 'number' },
          opacity: { type: 'number' },
          text: { type: 'string' },
          fontSize: { type: 'number' },
          fontFamily: { type: 'string' }
        },
        required: ['id']
      }
    },
  • Zod schema for Excalidraw element properties, used in the handler for partial parsing and validation of update parameters.
    const ElementSchema = z.object({
      type: z.enum(Object.values(EXCALIDRAW_ELEMENT_TYPES)),
      x: z.number(),
      y: z.number(),
      width: z.number().optional(),
      height: z.number().optional(),
      points: z.array(z.object({ x: z.number(), y: z.number() })).optional(),
      backgroundColor: z.string().optional(),
      strokeColor: z.string().optional(),
      strokeWidth: z.number().optional(),
      roughness: z.number().optional(),
      opacity: z.number().optional(),
      text: z.string().optional(),
      fontSize: z.number().optional(),
      fontFamily: z.number().optional(),
      locked: z.boolean().optional() // ADDED: Make sure locked status is saved
    });
  • src/index.js:684-708 (registration)
    Tool registration in the ListToolsRequestHandler response, duplicating the schema for tool listing.
    name: 'update_element',
    description: 'Update an existing Excalidraw element',
    inputSchema: {
      type: 'object',
      properties: {
        id: { type: 'string' },
        type: { 
          type: 'string', 
          enum: Object.values(EXCALIDRAW_ELEMENT_TYPES) 
        },
        x: { type: 'number' },
        y: { type: 'number' },
        width: { type: 'number' },
        height: { type: 'number' },
        backgroundColor: { type: 'string' },
        strokeColor: { type: 'string' },
        strokeWidth: { type: 'number' },
        roughness: { type: 'number' },
        opacity: { type: 'number' },
        text: { type: 'string' },
        fontSize: { type: 'number' },
        fontFamily: { type: 'string' }
      },
      required: ['id']
    }
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. 'Update' implies mutation, but it doesn't specify permissions required, whether changes are reversible, error handling, or rate limits. This is a significant gap for a mutation tool with zero annotation coverage.

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's appropriately sized and front-loaded, making it easy to parse without unnecessary elaboration.

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 (14 parameters, mutation operation, no annotations, no output schema), the description is incomplete. It lacks parameter details, behavioral context, and usage guidelines, making it inadequate for effective tool selection and invocation.

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?

Schema description coverage is 0%, and the description provides no parameter information. It doesn't explain what parameters like 'id', 'type', or 'roughness' mean, their formats, or how they affect the update. With 14 parameters, this leaves the agent guessing.

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 ('Update') and target ('an existing Excalidraw element'), providing a specific verb+resource. However, it doesn't differentiate from sibling tools like 'create_element' or 'lock_elements' beyond the basic operation type, missing explicit sibling distinction.

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?

No guidance is provided 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 'lock_elements' for protection.

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

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