Skip to main content
Glama

generate_mask

Idempotent

Generates a deterministic grayscale mask from a reference image, defining gradient, luminosity, or color ranges to selectively apply subsequent image operations.

Instructions

Generate a deterministic grayscale mask as a new PNG revision, with exactly the dimensions of reference_revision_id. kind is "linear_gradient" (angle_degrees, start, end), "radial_gradient" (center_x, center_y, radius, feather), "luminosity_range" (min, max, feather) or "color_range" (hue_center, hue_width, feather); the gradients use only the reference's dimensions, the other two compute weights from its pixels. White = the masked operation applies fully, black = not at all. Reference the returned revision_id from any tone/filter operation as "mask": {"revision_id": "rev_...", "invert": false, "feather_px": 0}, or visualise it with render_preview overlay="mask". Idempotent: the same params over the same reference produce byte-identical PNG bytes and return the existing revision.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endNolinear_gradient: 軸上で重みが 0.0 に達する位置(0..1、`start` 以上)。既定 1.0。
maxNoluminosity_range: 完全に選択される輝度域の上限(0..255、`min` 以上)。既定 255。
minNoluminosity_range: 完全に選択される輝度域の下限(0..255)。既定 0。
kindYes`"linear_gradient"` | `"radial_gradient"` | `"luminosity_range"` | `"color_range"`。
startNolinear_gradient: 軸上で重みが 1.0 のままでいる終端位置(0..1)。既定 0.0。
radiusNoradial_gradient: 重みが 1.0 の内円の半径(対角線の半分に対する比 0..1)。既定 0.5。
featherNo減衰帯の幅。radial_gradient では対角線の半分に対する比(0..1、既定 0.25)、 luminosity_range では輝度単位(0..255、既定 16)、 color_range では色相の度数(0..180、既定 15)。linear_gradient では使わない (`start`/`end` の間隔がフェザそのもの)。
center_xNoradial_gradient: 中心の X(画像幅に対する相対値 0..1)。既定 0.5。
center_yNoradial_gradient: 中心の Y(画像高に対する相対値 0..1)。既定 0.5。
hue_widthNocolor_range: 中心からの**片側**幅(度、1..180)。既定 30。
hue_centerNocolor_range: 中心色相(度、0..360)。必須。
angle_degreesNolinear_gradient: グラデーション軸の角度(度)。0 = 上が白で下へ向かって黒、 90 = 左が白で右へ向かって黒(正の角度で時計回り)。既定 0。
reference_revision_idYes寸法(と、輝度/色域マスクでは画素)の供給元になる画像 revision ID。

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindYes生成した種別(`linear_gradient` 等)。
nextYes次の一手(op への参照の仕方)。
widthYes
heightYes
reusedYes同じマスクが既に生成済みで既存 revision を返した場合 true(冪等ヒット)。
revisionYes
generatorYes既定値まで解決したパラメータの正規化 JSON(origin の generator と同一文字列)。
mean_weightYesマスクの平均重み(0..1)。1 に近いほど広く、0 に近いほど狭い被覆。
reference_revision_idYes参照した画像 revision(寸法・画素の供給元)。

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.5.2

TDQS

A4.6/5.0
Behavior5/5

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

The description goes beyond annotations by detailing the deterministic and idempotent behavior (same params produce byte-identical PNG and return existing revision). It also clarifies what the mask represents (white = full application, black = none) and that gradients use dimensions while ranges use pixels. The idempotentHint annotation is confirmed and expanded with specifics.

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 moderately long but every sentence serves a purpose: it defines the function, parameter kinds, output semantics, usage example, and idempotency. The front-loaded summary of kinds is efficient, and the JSON usage example is compact yet informative. No fluff or repetition.

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?

Given the tool's complexity (13 parameters, 4 kinds) and presence of output schema, the description covers key aspects: output semantics, idempotency, and usage integration. It omits explicit return value format (though output schema exists) and some edge cases, but the examples and schema descriptions cover most. The description is sufficient for an agent to call it correctly.

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 coverage is 100% with detailed descriptions for each parameter including default values and units. The description adds clarity by grouping parameters by kind and explaining the common semantics (like feather behavior) but does not add substantial new information beyond the schema. The description's parameter list matches the schema and provides complementary context (e.g., which parameters apply to which kind), but this is largely redundant.

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 tool's function: generating a deterministic grayscale mask as a new PNG revision with exact dimensions from a reference. It enumerates four distinct mask kinds with their parametersholistic details, and explains the white/black semantics. This distinguishes it from siblings like render_preview or apply_transform by focusing on mask generation.

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 explains how to use the result: referencing the returned revision_id in tone/filter operations with a concrete JSON example, and how to visualize it with render_preview overlay. It does not explicitly mention when not to use it, but the detailed operation contracts and idempotency note provide clear context for typical use cases. The alternatives are implied by sibling tools, and the usage examples are sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.