Skip to main content
Glama

batch_create_elements

Create multiple diagram elements simultaneously in Excalidraw to save time when building complex drawings.

Instructions

Create multiple elements at once (max 100)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementsYes

Implementation Reference

  • Main MCP tool registration and handler for batch_create_elements. Validates input using schema, calls client.batchCreate(elements), and returns the created elements with count. This is the primary entry point that handles the tool's request-response logic.
    // --- Tool: batch_create_elements ---
    server.tool(
      'batch_create_elements',
      `Create multiple elements at once (max ${LIMITS.MAX_BATCH_SIZE})`,
      {
        elements: z.array(z.object(elementFields)).min(1).max(LIMITS.MAX_BATCH_SIZE),
      },
      async ({ elements }) => {
        try {
          const created = await client.batchCreate(
            elements as unknown as Record<string, unknown>[]
          );
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({ elements: created, count: created.length }, null, 2),
            }],
          };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
  • BatchCreateSchema definition that validates the input for batch_create_elements. Requires an 'elements' array with minimum 1 and maximum LIMITS.MAX_BATCH_SIZE elements. Each element must match CreateElementSchema.
    export const BatchCreateSchema = z
      .object({
        elements: z
          .array(CreateElementSchema)
          .min(1)
          .max(LIMITS.MAX_BATCH_SIZE),
      })
      .strict();
  • CanvasClient.batchCreate method implementation for connected mode. Makes a POST request to /api/elements/batch endpoint with the elements array, handles errors, and returns the created ServerElement array.
    async batchCreate(
      elements: Record<string, unknown>[]
    ): Promise<ServerElement[]> {
      const res = await fetch(`${this.baseUrl}/api/elements/batch`, {
        method: 'POST',
        headers: this.headers(),
        body: JSON.stringify({ elements }),
      });
    
      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 { elements?: ServerElement[] };
      return body.elements ?? [];
    }
  • CanvasClientAdapter.batchCreate method implementation for standalone mode. Iterates through elements array and calls createElement for each one, collecting and returning all created ServerElements.
    async batchCreate(
      elements: Record<string, unknown>[]
    ): Promise<ServerElement[]> {
      const results: ServerElement[] = [];
      for (const data of elements) {
        results.push(await this.createElement(data));
      }
      return results;
    }
  • LIMITS constant defining validation constraints including MAX_BATCH_SIZE: 100, which is used to enforce the maximum number of elements that can be created in a single batch_create_elements call.
    export const LIMITS = {
      MAX_ID_LENGTH: 64,
      MAX_COLOR_LENGTH: 32,
      MAX_TEXT_LENGTH: 10_000,
      MAX_FONT_FAMILY_LENGTH: 64,
      MAX_GROUP_ID_LENGTH: 64,
      MAX_MERMAID_LENGTH: 50_000,
      MAX_COORDINATE: 1_000_000,
      MIN_COORDINATE: -1_000_000,
      MAX_DIMENSION: 100_000,
      MAX_FONT_SIZE: 1000,
      MAX_STROKE_WIDTH: 100,
      MIN_OPACITY: 0,
      MAX_OPACITY: 100,
      MAX_ROUGHNESS: 3,
      MAX_BATCH_SIZE: 100,
      MAX_ELEMENT_IDS: 500,
      MAX_POINTS: 10_000,
      MAX_GROUP_IDS: 50,
      MAX_ELEMENTS_TOTAL: 10_000,
    } as const;
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only mentions the batch size limit (max 100), but fails to describe critical aspects: whether this is a write operation (implied by 'Create'), what happens on partial failures, authentication requirements, rate limits, or what the return value contains. For a batch creation tool with zero annotation coverage, this is inadequate.

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 extremely concise (7 words) and front-loaded with the core purpose. Every word earns its place: 'Create' (action), 'multiple elements' (resource/scope), 'at once' (batch nature), '(max 100)' (key constraint). No wasted words or redundancy.

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 (batch creation with a nested object array parameter), absence of annotations, and no output schema, the description is insufficient. It doesn't cover behavioral traits, error handling, return values, or detailed parameter semantics. For a tool that creates multiple graphical elements with many configurable properties, this leaves too much unexplained.

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 mentions 'elements' and the batch size constraint ('max 100'), which aligns with the 'elements' array parameter in the schema. However, with 0% schema description coverage and 1 parameter (a complex array of objects), the description doesn't explain what an 'element' consists of, the required properties, or the meaning of nested fields like 'type', 'x', 'y', etc. The schema does heavy lifting, but the description adds minimal value beyond the obvious.

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 ('Create multiple elements at once') and resource ('elements'), which is specific and distinguishes it from single-element creation tools like 'create_element'. However, it doesn't explicitly differentiate from other element-creation tools like 'create_from_mermaid' or 'create_view', which slightly limits sibling differentiation.

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

Usage Guidelines3/5

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

The description implies usage context through 'at once (max 100)', suggesting this tool is for batch operations rather than single creations. However, it doesn't provide explicit guidance on when to use this versus 'create_element' or other element-creation siblings, nor does it mention prerequisites or exclusions.

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