recolor · diff
git:20261016.f908cbd to git:20261016.8dbae0f
11 added, 25 removed. Audit A to A.
---
name: recolor
description: "Change colors in an SVG file. Map old colors to new colors. Triggers on: recolor svg, change svg color, replace color in svg, swap colors."
---
# Recolor SVG
- Replace colors in an SVG file by mapping old colors to new ones.
-
- ## Prerequisites
+ Replace colors in an SVG by mapping old colors to new ones.
- Use the svg.new MCP tools if they are available in this session (`mcp__svgnew__*`, or `mcp__plugin_svg-vectorizer_svg-new__*` when this plugin provides them); they need no API key. Otherwise the `SVG_NEW_API_KEY` environment variable must be set. If neither is available, tell the user:
- > Connect svg.new with `claude mcp add --transport http --scope user svgnew https://svg.new/api/mcp` and `/mcp` → Authenticate, or generate an API key at https://svg.new/account and set `export SVG_NEW_API_KEY="svk_..."`.
+ ## Before you start
- Do not fall back to a local tracer (vtracer, potrace) unless the user asks for one.
+ Use the svg.new MCP tools from this plugin (named `mcp__plugin_svg-vectorizer_svg-new__*`, or `mcp__svgnew__*` if the user connected the server directly). They sign in with the user's svg.new account, so no API key is involved. If the tools are missing or say sign-in is needed, ask the user to run `/mcp`, pick the svg.new server and choose **Authenticate**.
- Large inputs go by reference: `svg_url` for the SVG (e.g. the download link a previous result gave), `image_url` or `upload_id` (from `create_upload`) for rasters, each up to 20 MB; large results come back as one-hour download links.
## Steps
- 1. Read the SVG file specified by the user or `$ARGUMENTS`
- 2. Determine which colors to replace — ask the user if not specified
- 3. Build a color map object: `{ "#old_hex": "#new_hex", ... }`
- 4. Call the API:
-
- ```bash
- curl -s -X POST "${SVG_NEW_API_URL:-https://svg.new}/api/agent/edit/recolor" \
- -H "Authorization: Bearer $SVG_NEW_API_KEY" \
- -H "Content-Type: application/json" \
- -d "{\"svg\": \"$SVG_CONTENT\", \"color_map\": $COLOR_MAP}"
- ```
-
- 5. Extract the `svg` field from the response
- 6. Write it back to the file (or a new file if the user prefers)
+ 1. Read the SVG named in the request or `$ARGUMENTS`.
+ 2. Work out which colors to replace. Ask the user if they didn't say.
+ 3. Build a color map such as `{ "#ff0000": "#0000ff" }`.
+ 4. Call `recolor_svg` with `color_map` and the SVG, either as `svg` (the file's text) or as `svg_url` (a public link, such as a download link from an earlier result).
+ 5. Write the result back to the file, or to a new file if the user prefers. If it came back as a download link, save it with `curl -sL -o <file> "<link>"`.
## Notes
- - This operation is free (no credits consumed)
- - Colors are matched case-insensitively
- - Supports hex (#RGB, #RRGGBB), named colors (red, blue), and rgb() values
- - Only fill colors are modified; strokes are preserved
+ - Free: no credits are used.
+ - Colors match case-insensitively. Hex (#RGB, #RRGGBB), named colors and rgb() values all work.
+ - Fill colors change; strokes are left alone.