Skip to main content
Glama

Group Layers

photopea_group_layers

Group multiple layers into a layer folder by specifying layer names. Use with get_layers to find names, and ungroup_layers to reverse. Organize your layers panel efficiently.

Instructions

Group multiple layers into a layer group (folder). Layers are specified by name — use get_layers to find layer names. Grouped layers can be ungrouped later with ungroup_layers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
layersYesArray of layer names to include in the group (use get_layers to find names)
groupNameNoDisplay name for the group folder in the layers panel

Implementation Reference

  • Registration of photopea_group_layers tool on the MCP server with title, description, input schema (layers, groupName), and annotations.
    server.registerTool("photopea_group_layers", {
      title: "Group Layers",
      description: "Group multiple layers into a layer group (folder). Layers are specified by name — use get_layers to find layer names. Grouped layers can be ungrouped later with ungroup_layers.",
      inputSchema: {
        layers: z.array(z.string()).describe("Array of layer names to include in the group (use get_layers to find names)"),
        groupName: z.string().optional().describe("Display name for the group folder in the layers panel"),
      },
      annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
    }, async (params) => {
      const script = buildGroupLayers(params);
      bridge.sendActivity({ type: "activity", id: "", tool: "group_layers", summary: `Group ${params.layers.length} layers` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to group layers" }] };
      return { content: [{ type: "text" as const, text: `Layers grouped${params.groupName ? `: ${params.groupName}` : ""}` }] };
    });
  • Handler function for photopea_group_layers: calls buildGroupLayers, sends activity, executes script, returns success/error.
    }, async (params) => {
      const script = buildGroupLayers(params);
      bridge.sendActivity({ type: "activity", id: "", tool: "group_layers", summary: `Group ${params.layers.length} layers` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to group layers" }] };
      return { content: [{ type: "text" as const, text: `Layers grouped${params.groupName ? `: ${params.groupName}` : ""}` }] };
    });
  • buildGroupLayers function that generates the Photopea JavaScript to create a layer group and move specified layers into it.
    export function buildGroupLayers(params: GroupLayersParams): string {
      const { layers, groupName } = params;
      const lines: string[] = [];
    
      lines.push(`var _group = app.activeDocument.layerSets.add();`);
      if (groupName !== undefined) {
        lines.push(`_group.name = '${escapeString(groupName)}';`);
      }
    
      // Move each named layer into the group
      for (const layerName of layers) {
        const safe = escapeString(layerName);
        lines.push(
          `app.activeDocument.layers.getByName('${safe}').move(_group, ElementPlacement.PLACEATEND);`
        );
      }
    
      lines.push(`app.echoToOE('ok');`);
      return lines.join("\n");
    }
  • TypeScript interface GroupLayersParams defining the shape parameters: layers (string[]) and optional groupName.
    export interface GroupLayersParams {
      layers: string[];
      groupName?: string;
    }
Behavior4/5

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

Annotations already indicate non-read-only and non-destructive behavior. The description adds that layers are specified by name and that grouping is reversible. This provides context beyond annotations without contradicting them.

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?

Two short sentences that efficiently convey the purpose, method, and related tool. No unnecessary words, front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the main purpose and required preparation, but could mention error handling or behavior if layers are missing or already grouped. However, for a simple grouping operation, it is mostly complete.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds context: layers must exist and names come from 'get_layers', and the groupName is a display name. It also mentions undo capability, which is not in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (group multiple layers into a layer group) and the resource (layers), with a specific verb 'Group' and resource 'layers'. It distinguishes itself from the sibling 'ungroup_layers' by mentioning that grouped layers can be ungrouped later.

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

Usage Guidelines4/5

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

The description advises using 'get_layers' to find layer names, and mentions that grouping can be undone with 'ungroup_layers'. However, it does not explicitly state when not to use this tool or provide alternatives, but given the sibling set, it is clear this is the only grouping tool.

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/attalla1/photopea-mcp-server'

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