Skip to main content
Glama

ungroup_elements

Remove elements from a group in Excalidraw diagrams by specifying the group ID to edit individual components separately.

Instructions

Remove elements from a group by group ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupIdYes

Implementation Reference

  • Core handler function ungroupElementsTool that removes elements from a group by filtering all elements, finding those with the specified groupId, and updating each element to remove that groupId from their groupIds array.
    export async function ungroupElementsTool(
      args: unknown,
      client: CanvasClient
    ) {
      const { groupId } = GroupIdSchema.parse(args);
      const allElements = await client.getAllElements();
    
      const grouped = allElements.filter(
        (el) => el.groupIds && el.groupIds.includes(groupId)
      );
    
      if (grouped.length === 0) {
        throw new Error(`No elements found with groupId ${groupId}`);
      }
    
      let ungroupedCount = 0;
      for (const element of grouped) {
        const updatedGroupIds = (element.groupIds ?? []).filter(
          (gid) => gid !== groupId
        );
        await client.updateElement(element.id, { groupIds: updatedGroupIds });
        ungroupedCount++;
      }
    
      return { success: true, groupId, ungroupedCount };
    }
  • MCP tool registration for 'ungroup_elements' with inline schema definition (groupId as string with max length limit) and the handler logic that calls getAllElements, filters by groupId, and updates each element to remove the group.
    // --- Tool: ungroup_elements ---
    server.tool(
      'ungroup_elements',
      'Remove elements from a group by group ID',
      { groupId: z.string().max(LIMITS.MAX_GROUP_ID_LENGTH) },
      async ({ groupId }) => {
        try {
          const all = await client.getAllElements();
          const inGroup = all.filter(e => e.groupIds?.includes(groupId));
          if (inGroup.length === 0) {
            throw new Error(`No elements found with groupId ${groupId}`);
          }
    
          for (const el of inGroup) {
            const newGroups = (el.groupIds ?? []).filter(g => g !== groupId);
            await client.updateElement(el.id, { groupIds: newGroups });
          }
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({ groupId, ungroupedCount: inGroup.length }, null, 2),
            }],
          };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${(err as Error).message}` }], isError: true };
        }
      }
    );
  • GroupIdSchema validation schema that defines the input structure with a groupId field as a string with maximum length constraint, used by the ungroup-elements tool handler.
    export const GroupIdSchema = z
      .object({
        groupId: z.string().max(LIMITS.MAX_GROUP_ID_LENGTH),
      })
      .strict();
  • Export statement that makes ungroupElementsTool available from the tools index module.
    export { ungroupElementsTool } from './ungroup-elements.js';
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. 'Remove elements from a group' implies a mutation operation, but it doesn't specify whether this is destructive (e.g., deletes elements or just ungroups them), what permissions are required, or what happens to the ungrouped elements. This leaves significant gaps for a tool that likely modifies data.

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, clear sentence with zero waste. It's front-loaded with the core action and resource, making it highly efficient and easy to parse.

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 (a mutation tool with no annotations and no output schema), the description is incomplete. It lacks details on behavioral traits (e.g., whether removal is reversible), parameter context, and expected outcomes, making it inadequate for safe and effective use by an agent.

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?

Schema description coverage is 0%, so the description must compensate. It mentions 'by group ID', which aligns with the single parameter 'groupId', adding meaning beyond the schema's type constraints. However, it doesn't explain what a group ID is, its format, or where to find it, leaving some ambiguity.

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 ('Remove elements from a group') and the resource ('by group ID'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'delete_element' or 'ungroup_elements' (if that were a sibling), though the context suggests it's distinct from deletion operations.

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 a group to exist), exclusions, or compare to siblings like 'delete_element' or 'group_elements', leaving the agent to infer usage context.

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