Replace color
replace_colorReplace every occurrence of a specified color with another color across an entire SVG document or within selected elements.
Instructions
Replace one colour with another across the document (or within scope_ids subtrees).
When to use: swapping every occurrence of one colour for another. For a multi-colour theme swap
use apply_palette; to recolour specific objects only use set_fill / set_stroke.
Key params: both colours are validated; matching is case- and hex-shorthand-insensitive and
covers inline-style colour properties (fill, stroke, stop-color, ...) and the same-named
presentation attributes. scope_ids, if given, confines the replacement to those elements'
subtrees (each id must exist).
Return shape: EditResult — operation_id, snapshot_id, changed (false if the colour was
not found anywhere in scope), before/after preview; lands on the working copy only (reversible).
Example: replace_color(doc_id, "#ff0000", "#3366cc")
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: medium.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"doc_id": "<doc_id>",
"from_color": "<from_color>",
"to_color": "<to_color>"
},
"name": "replace_color"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| to_color | Yes | ||
| scope_ids | No | ||
| from_color | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |