Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

group_elements

Combine multiple diagram elements into a single group using the Excalidraw MCP Server, simplifying organization and management of complex layouts.

Instructions

Group multiple elements together

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementIdsYes

Implementation Reference

  • src/index.ts:328-341 (registration)
    Registration of the 'group_elements' tool, defining its name, description, and input schema for MCP server capabilities and listing.
    {
      name: 'group_elements',
      description: 'Group multiple elements together',
      inputSchema: {
        type: 'object',
        properties: {
          elementIds: { 
            type: 'array',
            items: { type: 'string' }
          }
        },
        required: ['elementIds']
      }
    },
  • Zod schema used for input validation in the group_elements handler.
    const ElementIdsSchema = z.object({
      elementIds: z.array(z.string())
    });
  • Handler for 'group_elements' tool call. Generates a group ID, updates local scene state, fetches current elements from canvas, appends the group ID to their groupIds, updates canvas, and returns result with success count.
    case 'group_elements': {
      const params = ElementIdsSchema.parse(args);
      const { elementIds } = params;
    
      try {
        const groupId = generateId();
        sceneState.groups.set(groupId, elementIds);
    
        // Update elements on canvas with proper error handling
        // Fetch existing groups and append new groupId to preserve multi-group membership
        const updatePromises = elementIds.map(async (id) => {
          const element = await getElementFromCanvas(id);
          const existingGroups = element?.groupIds || [];
          const updatedGroupIds = [...existingGroups, groupId];
          return await updateElementOnCanvas({ id, groupIds: updatedGroupIds });
        });
    
        const results = await Promise.all(updatePromises);
        const successCount = results.filter(result => result).length;
    
        if (successCount === 0) {
          sceneState.groups.delete(groupId); // Rollback local state
          throw new Error('Failed to group any elements: HTTP server unavailable');
        }
    
        logger.info('Grouping elements', { elementIds, groupId, successCount });
    
        const result = { groupId, elementIds, successCount };
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }]
        };
      } catch (error) {
        throw new Error(`Failed to group elements: ${(error as Error).message}`);
      }
    }
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states 'Group multiple elements together' but doesn't explain what grouping entails (e.g., creates a parent-child relationship, affects visibility/editing), whether it's destructive to existing structures, permission requirements, or error conditions. This leaves critical behavioral traits unspecified.

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 wasted words, making it highly concise. It's front-loaded with the core action and target, though its brevity contributes to gaps in other dimensions.

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 complexity (mutating operation with no annotations, 0% schema coverage, and no output schema), the description is incomplete. It lacks details on behavior, parameter usage, output expectations, and how it interacts with sibling tools like 'ungroup_elements', failing to provide sufficient context for effective agent use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'multiple elements' which loosely relates to the 'elementIds' array parameter, but doesn't clarify what constitutes valid element IDs, format expectations, or minimum/maximum array size. This adds minimal semantic value beyond the schema's basic structure.

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 ('Group') and target ('multiple elements together'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'ungroup_elements' beyond the opposite action, missing explicit differentiation about when grouping versus ungrouping applies.

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 like 'align_elements' or 'distribute_elements', nor does it mention prerequisites (e.g., elements must exist). It implicitly suggests grouping multiple elements, but lacks explicit context or exclusions for usage.

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

Related 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/yctimlin/mcp_excalidraw'

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