Skip to main content
Glama

quantize_palette

Destructive

Derive and install a reduced color palette from artwork for indexed pixel art, capped by max_colors, so a sprite can be mapped to a limited palette.

Instructions

Derive a palette from the art, reduced to at most max_colors entries.

The step between a picture and pixel art. `extract_palette` lists the colours a
sprite already uses but cannot reduce them to a budget, and `set_color_mode` maps art
onto a palette but cannot decide what the palette should be. This asks the editor's
own quantizer for the best `max_colors` colours for this art and installs them, which
is what to do before `set_color_mode("indexed", palette_source="keep")`.

One entry is spent on transparency, at index 0, which is what an indexed sprite needs
there: an opaque colour at the transparent index is in the palette and can never be
drawn.

**`max_colors` is a ceiling and nothing more, and it has a cliff in it.** The
reduction merges whole levels of colour space at a time, so it can stop well short of
what was asked for: measured, four distinct colours with `max_colors=4` came back as
one mid-grey that was the average of all four, while `max_colors=5` on the same art
returned all four exactly. The result therefore reports how many colours the art has,
how many of them the new palette holds exactly, and how many entries can draw at all,
and says in `warnings` when the palette cannot hold the art. Raising `max_colors` by
a little is usually what fixes it.

Refuses an indexed sprite. There a pixel is an offset into the palette rather than a
colour, so replacing the palette changes what every pixel means without touching a
pixel; the error says how to do it in that case.

Past a million pixels the art is not scanned, the palette is still derived, and the
result says the comparison was skipped rather than implying the art is blank.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYes
max_colorsNoDefault: 256.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.10.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only mark it destructive/non-readOnly; the description adds substantial beyond that: it installs the palette, spends index 0 on transparency, refuses indexed sprites with a remediation hint, skips pixel comparison past a million pixels, and surfaces 'warnings' when the palette cannot hold the art. This is rich mutation-behavior disclosure that the annotations alone do not provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and sibling differentiation, then grouped into scannable paragraphs on atomicity, parameter cliffs, refusal, and degradation. Dense and informative, though the transparency-index aside and stylistic phrasing make it longer than strictly necessary.

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

Completeness5/5

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

With no output schema, the description covers what an agent needs: the mutation performed, refusal conditions, scale limits, and what the result reports (color count, exact-match count, drawable entries, warnings). Nothing essential to calling or interpreting it is missing.

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

Parameters5/5

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

Schema coverage is only 50% ('max_colors' merely says 'Default: 256'), yet the description explains max_colors as a ceiling with a non-obvious quantization cliff, including a concrete measured example (four colors collapsing to one mid-grey at 4, preserved at 5). This meaningfully compensates for the schema gap; 'filename' is self-evident from context.

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?

States a specific verb+resource ('Derive a palette from the art, reduced to at most max_colors entries') and explicitly distinguishes itself from 'extract_palette' (lists colors, cannot reduce) and 'set_color_mode' (maps onto a palette, cannot decide it). An agent can identify the tool's unique role without opening any schema.

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?

Gives explicit when-to-use ('what to do before set_color_mode("indexed", palette_source="keep")'), when-not-to-use (refuses an indexed sprite), failure remedy ('raising max_colors by a little is usually what fixes it'), and the large-image degradation case. Rival tools are named and routed away from.

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

Deploy Server

Other Tools