Skip to main content
Glama
yctimlin

Excalidraw MCP Server

by yctimlin

ungroup_elements

Ungroup elements in an Excalidraw diagram by specifying the group ID, enabling individual editing or reorganization of diagram components.

Instructions

Ungroup a group of elements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupIdYes

Implementation Reference

  • Handler for the ungroup_elements tool. Parses the groupId, checks if group exists in sceneState, removes it from local state, fetches each grouped element from canvas, filters out the groupId from their groupIds array preserving other groups, updates elements on canvas, counts successes, logs, and returns formatted result.
    case 'ungroup_elements': {
      const params = GroupIdSchema.parse(args);
      const { groupId } = params;
    
      if (!sceneState.groups.has(groupId)) {
        throw new Error(`Group ${groupId} not found`);
      }
    
      try {
        const elementIds = sceneState.groups.get(groupId);
        sceneState.groups.delete(groupId);
    
        // Update elements on canvas, removing only this specific groupId
        const updatePromises = (elementIds ?? []).map(async (id) => {
          // Fetch current element to get existing groupIds
          const element = await getElementFromCanvas(id);
          if (!element) {
            logger.warn(`Element ${id} not found on canvas, skipping ungroup`);
            return null;
          }
    
          // Remove only the specific groupId, preserve others
          const updatedGroupIds = (element.groupIds || []).filter(gid => gid !== groupId);
          return await updateElementOnCanvas({ id, groupIds: updatedGroupIds });
        });
    
        const results = await Promise.all(updatePromises);
        const successCount = results.filter(result => result !== null).length;
    
        if (successCount === 0) {
          logger.warn('Failed to ungroup any elements: HTTP server unavailable or elements not found');
        }
    
        logger.info('Ungrouping elements', { groupId, elementIds, successCount });
    
        const result = { groupId, ungrouped: true, elementIds, successCount };
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }]
        };
      } catch (error) {
        throw new Error(`Failed to ungroup elements: ${(error as Error).message}`);
      }
    }
  • src/index.ts:342-352 (registration)
    Registration of the ungroup_elements tool in the tools array used for MCP capabilities and listTools. Defines name, description, and inputSchema requiring a groupId string.
    {
      name: 'ungroup_elements',
      description: 'Ungroup a group of elements',
      inputSchema: {
        type: 'object',
        properties: {
          groupId: { type: 'string' }
        },
        required: ['groupId']
      }
    },
  • Zod schema used to validate input parameters for the ungroup_elements tool, requiring a groupId string.
    const GroupIdSchema = z.object({
      groupId: z.string()
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Ungroup' implies a mutation operation, but the description doesn't state whether this requires specific permissions, whether it's reversible, what happens to element properties after ungrouping, or error conditions. For a mutation tool with zero 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's front-loaded with the core action and resource, making it immediately scannable. Every word earns its place by conveying essential information without 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 tool's mutation nature, lack of annotations, no output schema, and 0% schema coverage, the description is incomplete. It doesn't address behavioral aspects like side effects, permissions, or return values, nor does it clarify parameter semantics. For a tool that modifies grouped elements, more context is needed for safe and effective 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 the undocumented parameter. It mentions 'groupId' implicitly through context but provides no details on what a group ID is, how to obtain it, format requirements, or validation rules. The description adds minimal value beyond what the parameter name suggests.

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 ('ungroup') and resource ('a group of elements'), making the purpose immediately understandable. It distinguishes from siblings like 'group_elements' by specifying the opposite operation. However, it doesn't specify what 'elements' refers to in this context (e.g., UI elements, graphic objects), which prevents a perfect score.

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., that elements must already be grouped), when not to use it, or what happens after ungrouping. With siblings like 'group_elements' and 'lock_elements', explicit usage context would be helpful but is absent.

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