@ikijs/mcp 0.37.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,22 +2,24 @@
2
2
 
3
3
  > Part of [Iki](https://github.com/zeikar/iki), the open Live2D alternative that AI can build — free and MIT-licensed, with an open `.iki` format and a [Claude Code / Codex plugin](https://github.com/zeikar/iki/tree/main/plugin) that draws and rigs characters.
4
4
 
5
- A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model tools to AI agents (Claude, LLMs, and any MCP-compatible client): read/validate a model, and auto-rig one from role-named PNG layers.
5
+ A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model tools to AI agents (Claude, LLMs, and any MCP-compatible client): read/validate a model, and auto-rig one from role-named PNG layers, composed from generated parts or cut in place out of one finished picture.
6
6
 
7
7
  ## Tools
8
8
 
9
- | Tool | Description |
10
- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
11
- | `validate_iki` | Validate a raw `.iki` model — accepts an object or a JSON string — fail-fast, one error at a time. |
12
- | `describe_iki` | Return a summary of a valid model (inline or by `modelPath`): canvas, parameters, parts, deformers, expressions, motions. |
13
- | `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
14
- | `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
15
- | `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
16
- | `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
17
- | `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
18
- | `measure_turn_reference` | Measure how far a head turns between a front and a turned image at the same scale, as three ratios. |
19
- | `render_poses` | Render a rigged `.iki` into the character loop's pose PNGs through the installed Chrome, Edge or Chromium, and its turn and turn-and-nod sweeps. |
20
- | `probe_rig` | Measure a rigged `.iki` without rendering: where points of a part land in a pose, and the opaque runs of a layer PNG. |
9
+ | Tool | Description |
10
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | `validate_iki` | Validate a raw `.iki` model — accepts an object or a JSON string — fail-fast, one error at a time. |
12
+ | `describe_iki` | Return a summary of a valid model (inline or by `modelPath`): canvas, parameters, parts, deformers, expressions, motions. |
13
+ | `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
14
+ | `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
15
+ | `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
16
+ | `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
17
+ | `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
18
+ | `measure_turn_reference` | Measure how far a head turns between a front and a turned image at the same scale, as three ratios. |
19
+ | `render_poses` | Render a rigged `.iki` into the character loop's pose PNGs through the installed Chrome, Edge or Chromium, and its turn and turn-and-nod sweeps. |
20
+ | `probe_rig` | Measure a rigged `.iki` without rendering: where points of a part land in a pose, and the opaque runs of a layer PNG. |
21
+ | `view_illustration_grid` | Write a zoomed, gridded view of one finished picture on the layer canvas, optionally with landmarks drawn, for reading coordinates off it. |
22
+ | `cut_layers_from_illustration` | Cut one finished front-facing picture into in-place role layers from agent-placed landmarks, with numeric checks; optionally a generated lip set on the drawn mouth. |
21
23
 
22
24
  The `model` input for `validate_iki` and `describe_iki` accepts either a plain JSON object or a JSON string — the server normalises both. `describe_iki` also takes `modelPath` instead (exactly one of the two; resolved against the working directory, under it), so a written rig never crosses the context, and returns the patch writer's view of it: per part the rest `box` in model px, the `bustBox` in bust-render px and its `warps` with their stops; per `warp2d` deformer `stopsX` and `stopsY`; and `faceWidth` (the `face` part's width, the unit of a patch's `by`) and `bustScale`.
23
25
 
@@ -110,6 +112,17 @@ Measures a rigged `.iki` through the engine's own `landParts`, so the numbers ar
110
112
  - **Frame** — canvas px, origin top-left, x right, y down: the frame of the layer PNGs and of `describe_iki`'s boxes. Landed values are rounded to a thousandth of a pixel.
111
113
  - **Result** — the text is the results as JSON, one entry per query: `{ op: "paint", y0, rows }` or `{ op, part, points }` with a point `[x, y]` or `null`. A query's refusal comes back as `INVALID: queries[i].<field> …`; a refused call writes nothing.
112
114
 
115
+ ### `cut_layers_from_illustration`
116
+
117
+ Cuts one finished, front-facing character picture (PNG, JPEG or WebP) into the role layers `auto_rig_from_layers` takes, in place: every visible pixel is copied from the picture, and what a layer hides when the rig moves it (the forehead under the bangs, the hair behind the face, the neck behind the chin, the skin under each feature, the cheek and the back hair under a side lock, a side lock's root under the bangs) is filled from the paint around it. There is no ML: the parts are found from landmarks an agent reads off `view_illustration_grid`, and hair is told from skin by which set of the agent's colour samples a pixel is nearer.
118
+
119
+ - **Frame** — the picture scaled to the 1100 px wide layer canvas (height by its aspect), the canvas `view_illustration_grid` shows: canvas px, origin top-left, x right, y down; a coordinate names a pixel. `L` is the character's left, the viewer's right; `mouth.cornerL` is the exception, the viewer's left end of the mouth line. A transparent picture is used as is; an opaque one has its flat backdrop keyed from the border's colour, and a border that is not one flat colour is refused.
120
+ - **`landmarks`** — `samples` (`hair: { base, shadow?, highlight? }`, `skin: { base, shadow? }`, lists of `[x, y]`), `eyes` (`L`, `R`: `{ box, iris: { cx, cy, rx, ry } }`), `brows?` (`L?`, `R?`: `{ line, halfWidth?, tailHalfWidth? }`, the line tail first), `nose?` (`{ box }`), `mouth` (`{ box, cornerL, cornerR }`), `frontHair` and `skull` (polygons), `sideHair?` (`L?`, `R?`: a polygon each, round a lock hanging from under the bangs in front of the ear and the cheek's edge, traced from up inside `frontHair`, which keeps the paint both take; its root is carried up to 12 px under the bangs, skin is filled under it only where it crosses the face's own paint and inside `skull`, the head's skin without the ears, and the back hair down to `shellLower`), `shellLower` (the back hair's lower edge behind the face, x ascending), `skinSeeds`, `bodySeeds`, `backgroundSeeds?`, `paintSeeds?`, `neckTopY`, `bodyOnly?` (polygons) and `customParts?` (`{ id, tie, polygon }` or `{ id, tie, side, line, below, ribbonBox? }`). Boxes are `[x0, y0, x1, y1]`, both corners inside. The tool's input schema describes each key; the tool itself checks them and refuses the first fault as `INVALID: landmarks.<path> …`.
121
+ - **`outputDir`** — an existing directory under the working directory. It gets `hair_back`, `body`, `face`, `nose`, `mouth`, `eye_L`/`eye_R`, `iris_L`/`iris_R`, `lash_lower_L`/`lash_lower_R`, `lash_L`/`lash_R`, `brow_L`/`brow_R`, `hair_side_L`/`hair_side_R` (one per `sideHair` polygon holding hair) and `hair_front` (a feature not found writes no layer), each custom part as `custom/<id>.png` (for `auto_rig_from_layers`' `customParts`, never a role layer), and `preview-labels.png` and `preview-landmarks.png`. A role an earlier run left that this one does not write is removed.
122
+ - **`mouthKeyed` + `mouthInterior`** — optional, together: the composer's lip-set inputs (`mouth_keyed.png`, `mouth_interior.png`). The composer's own key and split cut them into `mouth_inner`, `lip_lower`, `lip_upper`, and `mouth_teeth` / `mouth_tongue` when the interior has light paint, written instead of `mouth`, scaled uniformly so the set's own corners are as far apart as the drawn ones and centred on their midpoint (not turned). The drawn mouth still leaves the face. One without the other is refused, and so are corners too close for the set's outline to close (the message names the least distance that cuts) and a set placed past the canvas's edge.
123
+ - **Checks** — each `{ id, level, pass, value, limit, hint }`, the hint naming the landmark to move: `stack` (fail; the layers stacked against the picture, the share of pixels off by more than 24 levels outside the mouth's box, limit 0.003, the box counted apart), `seeds` (fail; a seed or sample on the backdrop or the wrong class), `opening.L|R` (fail when the eye box clips the eye, the box it suggests leaving 2 to 4 px to spare; warn when it is loose, or when the paint it cuts runs on past it as a stroke the tool cannot tell from a lash wing; a stroke crossing into the box apart from the eye is left out of the eye), `iris.L|R` (warn; the ellipse against the disc found by the iris's own colour, overlap limit 0.7), `eye.L|R` (warn; an eye with under 0.06 white is cut as drawn closed), `brow.L|R` (warn; a band with no brow), `browBand.L|R` (warn; the share of the brow's ink left outside its band, limit 0.05, saying which way to move the line or how far to widen it), `mouth` (fail; nothing drawn in the mouth box and no lip set), `fills.<region>` (warn; the share of a fill made up over 40 px from its paint, limit 0.25, or no limit for the fills made up by construction), `frontHairWidth` (warn; `hair_front` wider than the face clamps the turn; the side locks are not counted), `sideHair.L|R` (warn, per polygon given; one problem each: a polygon holding no hair, a lock whose top row has no `hair_front` right above it, naming the columns and how far up the front hair ends, or a lock reaching into its declared eye box on the eye's rows past the box's 4 px of spare and its own 4 px outline, and a polygon whose hair the front hair or the other side's polygon took, each saying which way to move the polygon) and `pockets` (warn; the gaps between strands keyed as backdrop on their own and the backdrop-coloured regions the border's flood cannot reach, each named at a point `backgroundSeeds` accepts, counted together; a region near the backdrop's colour where `backgroundSeeds` accepts no point is said to be pale paint that needs nothing, and not counted). `passed` is false while a fail-level check fails.
124
+ - **Result** — `{ ok: true, outputDir, canvas, layers, customParts, previews, checks, measure, passed }`, `measure` being `measure_layers`' warnings on the written directory that a cut can act on (what the rig refuses, a lash whose top row is off its sclera's, a missing optional role, the side locks' root and lean checks naming the landmark to move) and, with a lip set, its opening's facts; the checks whose only remedy is re-laying-out or regenerating a generated part (art edges, eye aspect, iris size and place, an eyewhite to mirror, a speck nose, the lip set's own art, a `hair_side.png` drawing two locks, a side lock over its eye's corner, which the cut checks against the declared eye box) are left out. The text is the written files one per line, one `CHECK <id>: pass|WARN|FAIL <value> (limit <limit>) <hint>` line per check, the `MEASURE:` lines, and last `CUT pass` or `CUT FAIL: <failed check ids>`. A refusal writes nothing; a write that fails once writing has begun comes back as `write: … the cut stopped part-way …`: the files written before it replace an earlier cut's of the same name and the rest of the earlier cut's files are still there (a role this cut does not write is removed only after every file is written), so the directory is a mix of the two until the cut is run again.
125
+
113
126
  ## Usage
114
127
 
115
128
  Run directly with npx (no install needed):
@@ -141,7 +154,7 @@ codex mcp add iki -- npx -y @ikijs/mcp
141
154
 
142
155
  ## Scope note
143
156
 
144
- Current tools cover read/validate, auto-rigging a model from PNG layers (`auto_rig_from_layers`), composing/measuring the role layers a generated character needs (`compose_layers_from_parts`, `measure_layers`), measuring a rendered head turn against a reference one (`measure_turn_reference`), rendering a rigged model's poses (`render_poses`), and measuring where its parts land (`probe_rig`). PSD input and granular model-mutation primitives (add part, bind parameter, export) are deferred to future slices.
157
+ Current tools cover read/validate, auto-rigging a model from PNG layers (`auto_rig_from_layers`), composing/measuring the role layers a generated character needs (`compose_layers_from_parts`, `measure_layers`), measuring a rendered head turn against a reference one (`measure_turn_reference`), rendering a rigged model's poses (`render_poses`), measuring where its parts land (`probe_rig`), and cutting one finished picture into in-place role layers from agent-placed landmarks (`view_illustration_grid`, `cut_layers_from_illustration`). PSD input and granular model-mutation primitives (add part, bind parameter, export) are deferred to future slices.
145
158
 
146
159
  ## License
147
160