Skip to main content
Glama

Add Fill Layer

photopea_add_fill_layer

Add a non-destructive solid color fill layer covering the entire canvas. This adjustment-style layer can be toggled, recolored, or deleted without affecting other layers. Adjust its opacity or blend mode using set_layer_properties.

Instructions

Add a non-destructive solid color fill layer that covers the entire canvas. Unlike fill_selection, this creates a separate adjustment-style layer that can be toggled, recolored, or deleted without affecting other layers. Use set_layer_properties to change its opacity or blend mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesFill layer type (currently only 'solid' is supported)
colorYesFill color as hex string (e.g. #ff0000)
nameNoDisplay name for the fill layer in the layers panel

Implementation Reference

  • Registration of the photopea_add_fill_layer tool on the MCP server, including inputSchema definition and handler that calls buildAddFillLayer.
    server.registerTool("photopea_add_fill_layer", {
      title: "Add Fill Layer",
      description: "Add a non-destructive solid color fill layer that covers the entire canvas. Unlike fill_selection, this creates a separate adjustment-style layer that can be toggled, recolored, or deleted without affecting other layers. Use set_layer_properties to change its opacity or blend mode.",
      inputSchema: {
        type: z.enum(["solid"]).describe("Fill layer type (currently only 'solid' is supported)"),
        color: z.string().regex(/^#[0-9a-fA-F]{6}$/).describe("Fill color as hex string (e.g. #ff0000)"),
        name: z.string().optional().describe("Display name for the fill layer in the layers panel"),
      },
      annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
    }, async (params) => {
      const script = buildAddFillLayer(params);
      bridge.sendActivity({ type: "activity", id: "", tool: "add_fill_layer", summary: `Add ${params.type} fill layer` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to add fill layer" }] };
      return { content: [{ type: "text" as const, text: `Fill layer (${params.type}) added` }] };
    });
  • Input schema for photopea_add_fill_layer: type (enum 'solid'), color (hex regex), and optional name.
    inputSchema: {
      type: z.enum(["solid"]).describe("Fill layer type (currently only 'solid' is supported)"),
      color: z.string().regex(/^#[0-9a-fA-F]{6}$/).describe("Fill color as hex string (e.g. #ff0000)"),
      name: z.string().optional().describe("Display name for the fill layer in the layers panel"),
    },
  • Handler function for photopea_add_fill_layer: builds script from params, sends activity, executes via bridge, returns success/error response.
    }, async (params) => {
      const script = buildAddFillLayer(params);
      bridge.sendActivity({ type: "activity", id: "", tool: "add_fill_layer", summary: `Add ${params.type} fill layer` });
      const result = await bridge.executeScript(script);
      if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to add fill layer" }] };
      return { content: [{ type: "text" as const, text: `Fill layer (${params.type}) added` }] };
    });
  • buildAddFillLayer helper function that constructs the Photopea JavaScript to create a new art layer and fill the selection with a solid color.
    export function buildAddFillLayer(params: AddFillLayerParams): string {
      const { type, color, name } = params;
      const lines: string[] = [];
    
      if (type === "solid" && color) {
        const { r, g, b } = hexToRgb(color);
        lines.push(solidColorLines("_fillColor", r, g, b));
        lines.push(`var _layer = app.activeDocument.artLayers.add();`);
        if (name !== undefined) {
          lines.push(`_layer.name = '${escapeString(name)}';`);
        }
        lines.push(`app.activeDocument.selection.selectAll();`);
        lines.push(`app.activeDocument.selection.fill(_fillColor);`);
        lines.push(`app.activeDocument.selection.deselect();`);
      } else {
        lines.push(`var _layer = app.activeDocument.artLayers.add();`);
        if (name !== undefined) {
          lines.push(`_layer.name = '${escapeString(name)}';`);
        }
      }
    
      lines.push(`app.echoToOE('ok');`);
      return lines.join("\n");
    }
  • AddFillLayerParams type definition used by both schema and buildAddFillLayer.
    export interface AddFillLayerParams {
      type: "solid";
      color?: string;
      name?: string;
    }
Behavior5/5

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

Annotations provide no safety details (destructiveHint=false), but the description clarifies the tool is non-destructive and creates an adjustment-style layer that can be toggled, recolored, or deleted without affecting others. This goes beyond annotations, fully disclosing behavioral traits.

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?

Three sentences: first defines the primary action, second differentiates from a sibling, third suggests next steps. No redundant words, front-loaded with key purpose.

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 tool's purpose, alternatives, and follow-up actions. It lacks explicit mention of prerequisites like an open document, but given the simplicity and context from sibling tools, it is largely complete. Minor gap regarding error handling or unsupported types.

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 100%, and the description does not add new information about parameters beyond what the schema already provides (e.g., hex color pattern, enum for type). The description focuses on overall behavior rather than parameter details, earning a baseline score.

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 verb 'add' and the resource 'non-destructive solid color fill layer' that covers the entire canvas. It distinguishes from the sibling tool 'fill_selection' by explaining the different behavior, making it easy for an agent to select correctly.

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

Usage Guidelines5/5

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

The description explicitly contrasts with 'photopea_fill_selection' and advises when to use this tool (for a non-destructive layer versus a direct fill). It also directs to 'set_layer_properties' for further adjustments, providing clear guidance on usage and alternatives.

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