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
| Name | Required | Description | Default |
|---|---|---|---|
| groupId | Yes |
Implementation Reference
- src/index.ts:738-780 (handler)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'] } },
- src/index.ts:208-210 (schema)Zod schema used to validate input parameters for the ungroup_elements tool, requiring a groupId string.const GroupIdSchema = z.object({ groupId: z.string() });