# sprite-split

> Cuts a sheet into frames and writes the atlas a game engine imports.

Source: https://tools.vukem.dev/docs/mcp/tools/sprite-split/

## Behaviour

What the tool needs and what it does. The server converts nothing itself: it calls the API for you.

| Property | Value |
| --- | --- |
| Ability | `sprite:sheet` |
| Runs | `POST /api/v1/tools/sprite-split`, then downloads the result |
| CLI | `vukem-tools sprite split` |
| Reads | The files named in the arguments, on the machine the server runs on |
| Writes | `output` |

## Input

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | string | yes | Path of the file to read. |
| `output` | string | yes | Where to write the result: a file path, or a directory for a tool that yields several files. The result is downloaded at once because it expires in minutes. |
| `options` | object | no | How to find the frames, and which metadata to write. |
| `idempotency_key` | string | no | Up to 128 characters. Repeat a call safely: the same key returns the same conversion. |

An argument that is not in the tool's schema is refused with `invalid_input`.

### Options

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `options.aseprite` | boolean | no | Add Aseprite's per-frame duration and frameTags to the JSON formats |
| `options.background` | string | no | Hex colour auto mode treats as empty, e.g. #ff00ff. Empty means transparency. max length 9 |
| `options.background_tolerance` | integer | no | How far a pixel may be from the background colour and still count as background. min 0; max 255 |
| `options.cell_h` | integer | no | Cell height in pixels. min 0; max 8192 |
| `options.cell_w` | integer | no | Cell width in pixels. Give this and cell_h, or cols and rows. min 0; max 8192 |
| `options.cols` | integer | no | Column count, as an alternative to the cell size. min 0; max 2048 |
| `options.frame_ms` | integer | no | Per-frame duration in milliseconds for the Aseprite extensions. 0 means 100. min 0; max 60000 |
| `options.margin` | integer | no | Gutter between the sheet's edge and the first cell. min 0; max 256 |
| `options.metadata` | array of string | no | Metadata formats to write, at most four. GET /api/v1/tools/sprite-split/formats lists them. at most 4 items |
| `options.min_frame` | integer | no | Drop a detected frame smaller than this many pixels, as noise. Auto mode only. min 0; max 1000000 |
| `options.mode` | string | no | Grid or auto. Default grid. max length 8 |
| `options.prefix` | string | no | Frame name prefix; the nth frame is prefix plus a zero-padded index. Default frame. max length 64 |
| `options.rows` | integer | no | Row count. min 0; max 2048 |
| `options.spacing` | integer | no | Gutter between two neighbouring cells. min 0; max 256 |
| `options.trim` | boolean | no | Shrink each frame to its opaque box, recording the offset so an importer can re-inflate it. Refused with the css metadata format, which has nowhere to put the offset |

## Output

A call that works returns `isError: false`, the result as JSON text in `content`, and the same result as an object in `structuredContent`.

| Member | Type | Always present | Notes |
| --- | --- | --- | --- |
| `tool` | string | yes | The tool that ran. |
| `conversion_id` | string | yes | The conversion on the server. |
| `status` | string | yes | `finished`. |
| `outputs` | array of object | yes | One entry for each file written: `path`, `name`, `mime` (when known) and `size_bytes`. |
| `bytes_in` | integer | no | Bytes uploaded. |
| `bytes_out` | integer | no | Bytes written. |
| `note` | string | no | What the conversion says about itself, when it has something to say. |
| `expires_at` | string | no | When the server deletes its copy of the result. |

## Errors

A failed call is not a protocol error: it returns `isError: true` and a `code` the agent can branch on. The ones this tool is likely to meet:

- `invalid_input`: an argument is missing, unknown or out of range, or a file is not readable or is empty. Checked before anything is uploaded.
- `missing_key` and `unauthorized`: `VUKEM_TOOLS_API_KEY` is not set, or the server refused it.
- `missing_ability`: the key lacks `sprite:sheet`.
- `file_too_large`, `conversion_failed`, `timeout` and `result_expired`: the server could not finish or the result was gone before it was downloaded.
- `rate_limited`, `network_error` and `io_error`: a limit, the server could not be reached, or a file could not be read or written.

The full table, with `retry` and `conversion_type`, is in [What a result looks like](/docs/mcp/overview#what-a-result-looks-like).

## Safety

The agent chooses the paths, and the process can read and write anything your user can. The result is written to a temporary file next to `output` and then renamed, so a failed download leaves no partial file. See [What keeps an agent safe](/docs/mcp/overview#what-keeps-an-agent-safe).

## Example

**Ask the agent**

> Split a sprite sheet: read `in.png` and write `out`.

**The call** (`tools/call`)

```json
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"sprite-split","arguments":{"input":"in.png","output":"out","options":{"aseprite":true,"cell_h":32,"cell_w":32,"frame_ms":80,"margin":0,"metadata":["json-hash","libgdx"],"mode":"grid","prefix":"walk","spacing":0,"trim":true}}}}
```

**The result** (`result`)

```json
{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"{\"tool\":\"sprite-split\",\"conversion_id\":\"01JQ8Z5X0K7M3N9P2R4T6V8W0Y\",\"status\":\"finished\",\"outputs\":[{\"path\":\"out/frame-1.png\",\"name\":\"frame-1.png\",\"size_bytes\":1234}],\"bytes_in\":1500,\"bytes_out\":1234,\"expires_at\":\"2026-01-02T15:09:05Z\"}"}],"structuredContent":{"tool":"sprite-split","conversion_id":"01JQ8Z5X0K7M3N9P2R4T6V8W0Y","status":"finished","outputs":[{"path":"out/frame-1.png","name":"frame-1.png","size_bytes":1234}],"bytes_in":1500,"bytes_out":1234,"expires_at":"2026-01-02T15:09:05Z"},"isError":false}}
```

The values are illustrative: the names and the output path come from your call, the sizes and the id from the run. The member names are exact.

## Next steps

- [Connect a client](/docs/mcp/connect)
- [The MCP tools](/docs/mcp/tools)
- [The API operation behind it](/docs/api/tools.sprite-split)
