mcp

v0.39.1
@ikijs/mcp Checked 10 hours ago Published 6 days ago

MCP server that lets AI agents build 2D puppet characters: compose AI-drawn part images, or cut one finished illustration into layers, check their geometry and…

A stdio MCP 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. The model input for validate_iki and describe_iki accepts either a plain JSON object or a JSON string — the server normalises both.

Summary extracted from the README.

@ikijs/mcp

Part of Iki, the open Live2D alternative that rigs itself — free and MIT-licensed, with an open .iki format and a Claude Code / Codex plugin that draws and rigs characters.

A stdio MCP 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.

Tools

Tool Description
validate_iki Validate a raw .iki model — accepts an object or a JSON string — fail-fast, one error at a time.
describe_iki Return a summary of a valid model (inline or by modelPath): canvas, parameters, parts, deformers, expressions, motions, and its generator when it records one.
list_standard_parameters List the recommended standard parameter ids (e.g. ParamAngleX, ParamMouthOpenY) with descriptions.
describe_rig_plan List the fields of auto_rig_from_layers's rigPlan with their defaults, ranges, recommended spans, steps and poses.
auto_rig_from_layers Auto-rig role-named PNG layers into a renderable .iki written to disk; returns the output path.
compose_layers_from_parts Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline.
measure_layers Re-run that same geometry report over an already-composed layers directory.
measure_turn_reference Measure how far a head turns between a front and a turned image at the same scale, as three ratios.
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.
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.
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.
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.

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.

auto_rig_from_layers

Turns a set of role-named, full-canvas transparent PNG layers into a renderable, validated .iki model with the textures atlased and embedded as a base64 data:image/png URI. Under quantizeColors a nose layer is the exception: the palette rims a soft-shaded nose's feather, so the nose is atlased alone on a second, lossless page. The written model declares the head motions Nod, Shake and Tilt and up to six default expressions (smile, laugh, angry, sad, surprised, shy; shy needs a blush, angry and sad need brows), each with a description a host picks by; with a blush_L/blush_R layer it also declares ParamCheek, which fades the blush from faint at rest to as drawn.

  • layers — array of { path, fileName? }. path is a PNG file path (resolved against the server's working directory); the role is derived from fileName ?? basename(path). Required roles: face, eye_L, eye_R, and mouth or the lip set mouth_inner, lip_lower, lip_upper (a mouth that folds open instead of crossfading; a partial lip set, or one mixed with mouth/mouth_open, is refused). mouth_tongue / mouth_teeth are optional with the lip set only: drawn under its lips and clipped to mouth_inner, the teeth riding the upper line and the tongue the opening's bottom; without the set they are refused. Optional roles include iris_L/iris_R, brow_L/brow_R, hair_front/hair_back, lash_L/lash_R, lash_lower_L/lash_lower_R, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, etc. A side lock — the front lock hanging beside the ear, its root hidden under the bangs, drawn over the face, brows and lashes and under hair_front — needs hair_front (a lock without it is refused) and follows the face plate on the turn. An arm — the whole arm drawn hanging, its shoulder at the top — needs the body (it hangs from the body's shoulder) and becomes an elbow cap, an upper arm and a forearm sharing its crop, on ParamArmL/R (the shoulder) and ParamElbowL/R. A pose forearm — the forearm raised, standing up from its elbow — needs its arm: it hangs from the arm's elbow and is swapped in for the hanging forearm by ParamArmPoseL/R, rocked by ParamArmPoseAngleL/R, and drawn above the face and the hair. All layers must share the same canvas size (taken from the first layer).
  • outputPath — optional .iki output path (resolved against the working directory; the parent directory must already exist, and the path must end in .iki). Defaults to auto-rigged-model.iki.
  • turnTargets — optional head-turn cues to fit the rig to, in the units measure_turn_reference reports off a front/turned reference pair: eyeShift (plus noseShift and mouthShift) is how far that feature slides across the head at full turn, as a fraction of the head's half-width — a magnitude, since the rig turns both ways and the sign is the turn's own business; farEyeRatio is the far/near eye width at full turn over that same ratio at rest; silhouetteRatio the head's half-width turned over at rest. An omitted field leaves that part of the turn at the profile the rig defaults to. An eyeShift you pass is fitted by the turn's amount and clamped when it runs past the room the art leaves the far eye — the face plate's edge, or the bangs' side strand over the far iris — since that room is a fact about these layers, not about the reference. Any other target you do pass that it cannot reach is refused, because that number is a measurement rather than a preference. A layer set without a nose still turns its head, on the profile, but fits no target: turnTargets is then inert and the result carries no turn. A pair with a custom part crossing the eye row reads a wider head than the rig fits to: measure a pair drawn without them.
  • rigPlan — optional per-character tuning from the profile the rig defaults to, in three groups: turn (amount: the whole head turn, ignored when turnTargets.eyeShift is given; featureLead: how far the features lead the face plate; eyeForeshorten: how much the far eye narrows on the turn, ignored when turnTargets.farEyeRatio is given; noseLead: how far the nose leads the plate on the turn, never the nod, ignored when turnTargets.noseShift is given — the last two have provisional recommended spans; farEar: how far the far ear's outer edge follows the face on the turn, 0 holding it under the face), hair (follow: the front hair's share of the face's turn; outlineFollow: its outer edge's share where it draws the head's outline; sway: the hair sway amplitude) and eyes (blink: how far the upper lid comes down over the eye's height). Call describe_rig_plan for each field's default, range, recommended span, step and poses. A value out of range, or a group or key not in the catalog, is refused as INVALID: rigPlan.<path> …. The old style input was removed in 0.30.0 and is refused with the map from each old knob to its rigPlan path.
  • patches — optional displacements added to existing keyform stops of the freshly generated rig, each { target, at, region, by, falloff?, why? } (RigPatch in @ikijs/editor). target is a feature grid (eyeWarp_L/_R, browWarp_L/_R, noseWarp, mouthWarp; at names ParamAngleX and ParamAngleY, each −30, 0 or 30, never both 0) or a mesh part with warps (face, hair_front, …; at names one parameter at one of its warp stops). region is a rectangle in fractions of a role's rest layer box (top-left origin, y down); by and falloff are in face widths on screen axes (+dx right, +dy down). They are replayed on every rig of these inputs, so they hold through a layout or rigPlan retune, and they never touch the rest stop or a stop where the rig shuts a part on purpose; bodyWarp and the matrix deformers are not targets. Aim them with describe_iki.
  • customParts — optional parts the auto-rigger has no role for (a twin tail, a hairpin), each { id, path, anchor, tie, after, deformer?, rigid?, occlusion? } (CustomPart in @ikijs/editor, with path in place of layer). rigid: true marks art that does not bend (a hairpin, a ribbon): a bake that bends it by more than 0.0025 face widths at a stop is refused. occlusion: { by, parameter, stops: [{ value, amount }] } hides the part where the roles in by (a non-empty list, no role repeated, each a role of the set; one with a clipped or meshless part, iris_L, a brow drawn on the face (it is clipped to it) or forearm_pose_L, is refused) cover it, by an amount linear between the stops (ascending value, inside the parameter's range; amount 0 to 1) on a declared parameter that is not a physics output; the cover is where a role's drawn alpha is at least 0.5, a hard edge. Use the stops as a short switch starting a degree or more off rest, so the rest pose never sits on it and the idle turns the head through it (amount 1 about one degree after 0), the hiding's progress coming from the part's baked motion; a long band turns the covered art translucent. The result's part then carries occlusion (by as the part ids written) and its CUSTOM <id>: line ends , hidden by <id>,<id>… on <parameter> at <value>:<amount> <value>:<amount>…; other parts' lines are unchanged. occlusion needs 0.35.0: an older server refuses the key as INVALID: customParts[i]…. path is a PNG the size of the role layers, drawn alone and whole on a transparent ground; the tool takes its box from the layer's alpha. anchor is the role the part is fixed against, tie is [x, y] canvas px where it meets the anchor (inside both layers' boxes), after is a role of the set: the part is drawn right after that role's last part. deformer accepts only headDeformer, the default. The part goes into the model as an unrigged mesh on headDeformer. A custom layer is never role-parsed or measured, so its name is free and it does not widen the head the turn is fitted to (headHalfWidth, headEdges and turn are those of the role layers alone), but it counts toward the layer and pixel limits. All custom parts share one extra atlas page, the last, rendered with the call's quantizeColors on a palette of its own, so the role pages keep their bytes; atlasBytes includes it. A rig with customParts: [] is the rig without the field. An empty or wrong-size layer, or an entry the rig refuses, comes back as INVALID: customParts[i]… and nothing is written. Needs 0.34.0: an older server drops the field and returns no customParts.
  • bakes — optional lattices that move the custom parts when a parameter does, which an unrigged custom part otherwise does not: { targets, meshes? } (RigBakes in @ikijs/editor; it needs customParts and names no other part). A target { id?, param, parts, box?, grid: { cols, rows }, stops, mirror?, why? } is (cols + 1) x (rows + 1) control points laid evenly over box (canvas px; absent, the union of the parts' rest boxes grown by 2 px), listed row-major from the top-left, with a [dx, dy] per point at each stop. Every position and displacement is in canvas px, origin top-left, y down. A stop is the part's TOTAL landed displacement from rest when param alone is at that value and every other parameter is at its default, so the head's own carry is inside it and a neighbour's displacement as probe_rig measures it is written as it is. Stop keys are values of param inside its range, never its default. The landing is exact at rest, at each stop and at one end key the rig writes at the range end on a side whose outermost stop is inside the range (it holds that stop's displacement); a side with no stop is not moved. Between two keys the part's offsets are blended linearly, so under the head's roll the path bows off the line (about 1 px midway over 15°): put a stop where the path matters. Each vertex takes the bilinear value of the lattice at its rest position, and a vertex outside box takes the nearest edge's value. mirror: true fills a missing stop from the one at the mirrored value, when that value is inside the parameter's range (the lattice reflected about the box's vertical centre line, dx negated). Targets that name the same part and parameter sum. meshes re-meshes a custom part first ({ rows, cols } or { cellPx }). The written model is landed through the engine at every stop and at the range end each side holds its outermost stop to, and compared with the displacement the generator was asked for; a stop off by 0.1 px or more is INVALID: BAKE ERROR <part> <param>=<value>: …, and a part the bake moves at rest by as much is INVALID: BAKE ERROR <part> at rest: …; both mean the rig and the engine disagree (a bug in the packages, not in the input), and nothing is written, and an input the rig refuses is INVALID: bakes… with its path (bakes.targets[2].stops["30"][7]), nothing written either. Needs 0.34.0.
  • The custom gate — whenever customParts is passed the written model is also measured, per custom part, over a pose set: the engine's fold poses, each of the part's own stops alone, and for every pair of parameters it is baked on every combination of their stops (the stops of a part's occlusion on its key parameter count as its stops here). Lengths are in face widths (the face part's width), so no limit is tied to one canvas; the values are the experiment's over a 402 px face. Lines: FOLDS (the part's least triangle area ratio, ≥ 0.1, the engine's collapse); TIE (at the tie and a ring around it (5 px on a 402 px face, scaled with the face width), the part's displacement less the anchor's, the largest over the poses where ParamAngleX is at its default, ≤ 0.005); SLIDE (the same length over the poses that turn the head, ≤ 0.1; and the distance from where the part lands its tie to the nearest painted point of the anchor as the anchor lands it, ≤ 0.015); EXPOSED (the canvas pixels within 0.15 face widths of the tie that the part and its anchor both paint: of the two, the one drawn below has art the other hides at rest; at a pose each such pixel is landed through the lower part and counted as showing when no painted point of the upper one lands there; the largest count over the poses where the head does not turn, ≤ 0.0009 face widths², with the largest over the poses that turn it printed beside it, reported and not limited, since a tie allowed to slide uncovers what lies under it; draw order is the model's one order per part, so only the pair is read, and cover from any other part does not count unless the part declares an occlusion, below; rest counts 0); RIGID (rigid parts only: the least-squares rigid residual of the landed vertices against rest, over the pose set and the midpoint of each neighbouring pair of the part's stops, ≤ 0.0025); HIDDEN (only for a part that declares occlusion: the occluders, which of them give cover, the key parameter, the amount at rest, where the amount leaves its rest value and where it first reaches 1 on each side of the parameter's default, and how many of the part's poses TIE and SLIDE left out; reported, no limit, printed after EXPOSED); and TIP (per baked parameter, at the parameter's ends: where the part's free end lands, where it lands with the part's warps removed, the distance between and the travel end to end; reported, no limit). What an occlusion excuses. The gate excuses a reading only where it can establish that the player hides what the reading measures, and keeps the check everywhere else. Cover is an occluder's layer paint as that occluder lands at the pose, and only from an occluder the player draws at full alpha in every pose: colour alpha 1, no transform opacity under 1 and no opacity binding, so mouth_open, a blush and a pose forearm give none. A pose is left out only when the part is fully hidden across the stretches to the neighbouring sampled values of the key parameter on both sides (the amount is 1 at the pose, at both neighbours and at every occlusion stop between them; the sampled values are the ones the part's pose set takes, the default, its bake stops and its occlusion's stops included): a reading between two samples is bounded by the readings at its ends, so a stretch where the part is drawn keeps both poses it bounds in. For a left-out pose, TIE and SLIDE leave it out when every ring point lies on the part's mesh and under cover (it is then not counted among SLIDE's turning poses; a line whose every pose is left out says so); EXPOSED does not count a hidden-art pixel whose landed spot is under cover, and counts every other pixel as before. An amount under 1 is judged in full, and so is a part whose tie is not under cover. FOLDS, RIGID and TIP read every pose, and the occlusion's stops are sampled like bake stops, so a bake key at one changes no verdict. Each line gives the worst value in px and face widths and its pose, then pass or FAIL: <reason>; the text ends with CUSTOM GATE pass or CUSTOM GATE FAIL: <part LINE, …>, always the text's last line. FOLDS, TIE, SLIDE, EXPOSED and RIGID each fail the gate, TIP never does; a tie no ring point of which lies on both the part and its anchor fails TIE with that reason. The model is written either way, and the folds and physics reports for the rest of the model stay report-only. HIDDEN needs 0.35.0. Needs 0.34.0: from then on customParts always carries gate, so a result without customParts is from an older server and was never gated. A gate that throws still writes the file and returns the path, with gate.ok false, gate.failed ["gate error: <message>"] and the text ending CUSTOM GATE FAIL: gate error: <message>.
  • Result — on success the result text is the written file path, then one RIGPLAN: turn.amount=1 … line (every plan field's effective value, each annotated with (requested …, clamped at …) where the art's room cut it or (fitted by turnTargets.…) where a cue fitted it), then one PATCH <i> <target> at <Param=v …>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px line per patch op ((vertices) in place of the columns and rows for a mesh part), then the rig's fold report lines and its PHYSICS lines (as render_poses prints them), then, with side locks and a nose (which turn needs), the HAIRSIDE lines, then one CUSTOM <id>: box x,y WxH px, mesh N vertices M triangles, order O, atlas page P line per custom part, then, with bakes, one BAKE <part> <param>: N vertices, stops …, error E px line per part and parameter (E: the engine's landing against the asked displacement, under 0.1 px; carried as customParts.bakes), then, with customParts, the custom gate's CUSTOM <id> <LINE>: … lines and CUSTOM GATE pass or CUSTOM GATE FAIL: … last (carried as customParts.gate: ok, limits, parts with each measure, failed), and structuredContent carries { ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics, rigPlan, customParts? }. rigPlan is { requested, effective, clamped, overriddenBy } — the plan as passed, every field's value the rig built with, the plan-owned fields the room cut ({ field, bound }) and the fields a turnTargets cue fitted instead (path to cue); it is always present on a rigged model, and a result without it comes from a server before 0.30.0. patches is what each op moved (index, target, at, moved, of, cols/rows for a grid, maxPx) and is present whenever patches was passed, [] included. customParts is { parts, bakes?, gate }, each part { id, box, mesh: { vertices, triangles }, order, page } (box the layer's alpha box in canvas px, page the last atlas page), present whenever customParts was passed, [] included; bakes ({ part, param, vertices, stops, errorPx } per baked part and parameter) is present only when bakes was passed. atlasBytes is the embedded atlas's data-URI length, summed over every page: the nose's own, when it has one, and the custom parts' page. headHalfWidth is the head measured here rather than asked for: the layers' own opaque union at the eye row, under the same alpha >= 128 rule and ±10-row band measure_turn_reference spans a render with, so the rig's own rest render measures that span back; it is absent when that union has no span there at all (translucent art painted below alpha 128 — still a valid layer set, just with nothing to measure). headHalfWidthApplied is false when the measured value is absent, or no wider than the face plate (a hairless set, or one widest at the plate itself) — the generator will not take such a head, so the plate stands in for it and the rig is still produced either way. headEdges is a companion to a measured, applied headHalfWidth (absent otherwise): every role with an opaque pixel in that same eye-row band, per side, each with its own rest x there — passed straight to the generator's own options.headEdges so it can tell which part's own deformation actually carries the union's outermost pixel through the turn. strandEdges is each side's iris and the hair_front run it would slide under on the turn, measured whenever the layers include hair_front, iris_L and iris_R: the iris's opaque span and the run's outer and face-side ends as pixel edges on the row holding the iris's centre (a run that reaches the other iris's centre, a fringe spanning the face, has runFace: null; a run narrower than half the iris's painted width on that row is hair detail the iris may cross, and is skipped as if clear) — passed straight to the generator's own options.strandEdges, which keeps the far iris from sliding under the bangs any further than it is painted. turn is what the solve settled on — { radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped, strandOverlap? }, where achieved is what the rig does reach and clamped names every target the rig cut down: the turn (eyeShift, passed or the profile's own) where the face plate's edge or the strand cut it short, and a profile noseShift / mouthShift past its room. strandOverlap gives, per side whose far iris the bangs still cover at some far stop, the covered width — how much of the iris's painted row the run covers where that is largest (deg, px, and hh in head half-widths), how much it covers at rest (restPx), and whether the bound held (held: true means the iris is kept no deeper under the run than it is painted; false means the art left no room to — always so for a fringe spanning the face — and px is what stays covered); it is absent when nothing is covered. noseCore is the nose's dense core in canvas px — its pixels at alpha >= 128, not grown, the box handed to the generator as the nose layer's denseCore and its turn landmark — absent without a nose layer, when it has no pixel at that threshold (painted wholly translucent), or when that core is a speck of the nose's crop (under a quarter of its width or height, such as a lone nostril mark), and in both of the last two cases the crop stands in for it. hairSide (inside turn, present only with a side lock) is { left?, right? } by screen side — left the lock at −x (hair_side_R), right at +x — each { role, cover?, tail?, unavailable? }, report-only, measured as the far lock at its side's far stops (−15 and −30 on the left, 15 and 30 on the right), px, every x landed through the rendered rig: cover is { deg, px, y, rest }, the least over the lock's rows on the face plate that cover the head's edge at rest (a root under the bangs, or the rows an ear shows beside the lock, lie inside it by design and do not count) and over the far stops of the lock's outer edge minus the head's edge (the plate's painted edge, with any ear replaced by the head's edge beneath it, so an ear does not count as cheek the lock covers), positive still covering it and negative the turn baring cheek the lock hides at rest, rest that row's cover at rest (≥ 0, read off the geometry; px may exceed it), y the row where it is least in model space (the canvas centre the origin, +y up — the line also gives it as model px from the top, the row of the layer PNG); tail is { deg, eyeToLock, lashToLock?, eyeToPlate } for the far eye's outer corner on the eye's centre row at the stop where eyeToLock is least — the corner against the lock's face-side edge, positive a gap and negative under the lock (intended), lashToLock the same for the lash box with a lash_* layer, and eyeToPlate the corner's signed distance from that head edge (positive: inside it; negative: past it). A metric that cannot be read is omitted; a lock measured without rowRuns (never the case through this tool) carries unavailable (a reason) and nothing else. The result text prints them as HAIRSIDE cover <role>: … / HAIRSIDE tail <role>: … lines, one per metric present, the lock named by its role (hair_side_R hangs on the screen left), the pose as the setting that reproduces it (ParamAngleX=-30) and every edge distance signed to one decimal in model px (+0.0 for zero); a lock with neither prints HAIRSIDE <role>: no cover or tail row, one carrying unavailable prints HAIRSIDE <role>: unavailable — <why>; a set with no side lock prints none. turn is absent without a nose layer. folds is the written model's fold report, the engine's checkFolds over its own pose set ({ poses, thresholds, targets, offenders }, described under render_poses); it never refuses a rig — a model that folds is still written and returned — and each fold names its pose by its parameter settings, which a host reproduces by setting those parameters on a player (IkiPlayer.setParameter). physics is the written model's physics report, the engine's checkPhysics over its rigs ({ thresholds, targets, offenders }, described under render_poses) — the hair springs a hair_front layer brings (two for the front hair and, with hair_back, one for the back), or none — and never refuses a rig either. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (a patches op the rig refuses — INVALID: patches[i]…, naming the stops, targets or roles there are; unknown/missing role, an arm without a body, empty layer, mismatched sizes, bad path, an atlas page over 4096 px on a side, or an atlas over 12 MiB; art the rig cannot build on, such as a body's hips with no room under its pivots for a row line or for the body's motion, or an arm too short to hang an elbow under its shoulder; a turnTargets field that is unknown or that this layer set cannot reach — any passed field other than an eyeShift past the art's room; a rigPlan field out of range or unknown, or the removed style input; the message names the field and the attainable range) returns { ok: false, error } with a INVALID: … text — not a protocol error. An argument the tool's input schema refuses — a turnTargets or rigPlan that is not an object, or one of their named fields that is not a number — never reaches the tool: the MCP SDK answers with an isError result whose text is MCP error -32602: Input validation error: …, and no structuredContent.
  • The model's generator (0.39.0 on) — the written model records what made it: { tool: "@ikijs/mcp@<version>", rigger: "@ikijs/editor@<version>" } (the installed @ikijs/editor's version), plus plugin when the server was launched with the IKI_PLUGIN environment variable set to a label such as iki@0.59.4, as the Iki plugin's .mcp.json does. It is not a tool input: a caller cannot set it. A value of IKI_PLUGIN that is no label (empty counts as unset; blank, over 128 characters or with a control character does not) refuses the rig as INVALID: the IKI_PLUGIN environment variable is no label for a model: …. describe_iki returns a model's generator in its summary. The library function autoRigFromLayers writes a generator only when it is passed one (toolGenerator() builds the tool's), so the same layers give the same bytes across releases.

The decode/atlas pipeline runs in Node via sharp (a native dependency confined to this package); it mirrors the browser editor app's import flow and reuses the pure @ikijs/editor model + atlas math, so both paths produce the same rig. The fold and physics checks run the workspace @ikijs/engine, inlined into this package's Node build (as it already is into the render_poses page script), while @ikijs/format stays an external dependency.

compose_layers_from_parts

Composes a directory of AI-generated part PNGs into canvas-aligned, role-named layer PNGs ready for auto_rig_from_layers, on a canvas 1100 px wide and canvasHeight tall (1100 by default) with a built-in default layout tuned for the character-generation skill's standard front-facing framing. It ports the composer that shipped as a script (compose.cjs) in the Claude Code plugin.

  • partsDir — directory of the source part PNGs (resolved against the server's working directory). Required sources: face.png, eyewhite.png (split into the sclera, the upper lash and the lower lid — lash_lower_L/lash_lower_R, the dark line and lashes of the eye's lower part, which draw over the iris and are placed on the sclera's frame by the eye_* layout, so they have no layout key of their own; an eyewhite with no dark lower lid writes none and lists them in skipped. A light mark drawn detached above the eye white, such as a double-eyelid crease, is dropped from the sclera — the iris's clip — while dark strokes there stay lash ink. So is the lid's skin drawn attached above the white, a warm light band over the lash, in the columns that have a lash there — a band over a lash-free column, such as the tear duct, stays, as the white's own warm shading would — while the eye's frame stays the drawing's), iris.png, brow.png, hair_front.png, and a mouth by one of two routes: mouth.png (a closed drawing, with an optional mouth_open.png it cross-fades to), or the lip set — mouth_keyed.png (the open mouth, its inside painted ONE flat #00FF00) + mouth_interior.png (the cavity, teeth and tongue alone), which the composer keys and splits into mouth_inner / lip_lower / lip_upper on one frame, so auto_rig_from_layers folds the mouth open like the eyelid. The interior's light paint (luma 100 and over: the teeth, the tongue) is written as mouth_teeth and mouth_tongue on the same frame, split at each column's middle, riding the upper line and the opening's bottom and clipped to the cavity; mouth_inner takes the cavity's fill under it, its edge softened by the key's own coverage. An interior with no light paint writes neither and lists them in skipped. The key reads each antialiased pixel against its own ramp to the art's green, the interior is trimmed of the lip rim a generator draws round it, and the split is cut at the composed size so every boundary meets the rig's per-column contract by construction. The lip set is opt-in: with neither file the legacy route runs; one without the other, or either beside mouth.png / mouth_open.png, is refused naming the file to draw or remove. With the set, mouth and mouth_open are neither written nor listed in skipped. Optional: hair_back.png, body.png, mouth_open.png (legacy route), blush.png, nose.png — a parts dir without them still composes, minus those roles. One blush.png makes both cheeks' blush: blush_R takes it as drawn and blush_L mirrored. It is decoration, so the report does not flag a set without it. One hair_side.png — the front side lock on the screen left, hanging beside the ear with its root at the image's top — makes both locks: hair_side_R takes it as drawn and hair_side_L mirrored, drawn over the face, brows and lashes and under hair_front, and each is retuned through layout.hair_side_L / layout.hair_side_R. It is optional: without it both are listed in skipped. The rig needs a hair_front beside a lock. One arm.png — the arm on the screen left, drawn hanging with its shoulder at the top — makes both arms of a full body: arm_R takes it as drawn and arm_L mirrored, and each is hung on the body's shoulder (see layout). The arms are opt-in: a parts dir without arm.png composes as a bust does, and skipped never lists them. An arm.png needs a body.png. One forearm_pose.png — the arm's forearm raised, on the screen left, standing up from its elbow with the hand at the top — makes both pose forearms (forearm_pose_R as drawn, forearm_pose_L mirrored); it is opt-in too and needs an arm.png. With one the compose also writes preview-pose.png, the switch at 1 as the rig draws it (each arm with a pose forearm cropped to the rows above its elbow, the pose forearms over everything); preview.png stays the rest pose, where a pose forearm is invisible. Without a forearm_pose.png, preview-pose.png is removed. The nose is what the auto-rig leads the head turn with, and a face supplied alongside it must be drawn without one, or the painted nose stays on the face plate while the real one moves. Each part but the eye pair is cropped to its drawing before it is sized and placed. A faint speck detached from the drawing, one that never reaches alpha 128 and covers under 1 % of the part's pixels (residue a background removal leaves), is cut out with the margin it widened, so it cannot pull the part off its centre. A detached stroke that reaches alpha 128 is kept.
  • outDir — an existing directory (resolved against the working directory, confined to it exactly like auto_rig_from_layers's outputPath; the tool never creates directories) to write the role layer PNGs and a flattened preview.png (and, with a forearm_pose.png, preview-pose.png) into. Reusing a directory across runs is intentional — a role this run does not write (one it skips, e.g. composing a head-only set that omits body, or an arm or pose forearm once arm.png or forearm_pose.png is gone, preview-pose.png included) has its stale <role>.png from an earlier run deleted, so the directory always holds exactly this run's roles.
  • layout — optional per-role override merged over the built-in defaults, e.g. { "eye_L": { "cx": 660 } }, so a character can be retuned by re-running compose rather than editing a script. Each of cx, cy, w, h is optional; w must be an integer in 1..1100 (the canvas width) and h in 1..canvasHeight (the canvas height). The defaults of the face's features — blush, nose, mouth, mouth_open, mouth_inner, eyes, irises, lashes, brows, side locks — are proportions of the face: an override of face.cx, face.cy or face.w carries them with it (scaled by the width; face.h stretches the face alone), while a feature's own override names canvas px. Omitting h keeps the part's own aspect ratio, which is what every role wants until one does not: a generated eyewhite often comes back flatter than its reference, and stretching a flat white lens costs nothing where regenerating it is billed and unreliable. The nose is sized and placed by its dense core — its pixels at alpha ≥ 128, the drawing a viewer reads inside a soft nose's feather — rather than its whole part, which for a shaded-bump nose is mostly feather: w (default 20) and h size the core, cx (default 550) centres it, and a set cy centres its rows. By default its cy is unset, and the core's bottom row (the tip) lands 0.66 of the way from the eye row down to the mouth's, so the nose follows a retuned eye or mouth row. A nose with no pixel at alpha ≥ 128 is sized and placed whole, and so is one whose core is a speck of its trimmed part — under a quarter of its width or height, such as a lone nostril mark or highlight, which sized to w would blow the whole nose up — and the report warns of the speck. mouth_inner is the lip set's one frame (mouth_open's place by default): lip_lower, lip_upper, mouth_tongue and mouth_teeth have no key and land on it, so a retune moves them together, and with the set the nose's tip rule reads layout.mouth_inner.cy. Set h on a sclera and its lash together — they share one frame, and the blink fold tears if they diverge, so a pair set to land on different frames is rejected. arm_L and arm_R have no cx/cy/w defaults; each is derived from the placed body. An unset w is 0.4 of the body's width. An unset cx or cy hangs the arm's shoulder pivot — the one auto_rig_from_layers turns it about, read off the resized arm by the rig's own rule — on the body box's shoulder corner on that axis: its left edge for arm_R, its right edge for arm_L, 0.12 of its height under its top. On a torso widest at its shoulders, the shoulder cap's centre then sits on the torso's edge. A set one centres the arm as for every other role. Both values are provisional. forearm_pose_L and forearm_pose_R have no cx/cy/w defaults either: an unset w scales the forearm so its elbow end (the shoulder rule run from its bottom, on the trimmed source) is as wide as the placed arm's elbow run, and an unset cx or cy pins the elbow end's pivot — measured on the resized part — on the arm's placed elbow, the pivot auto_rig_from_layers hangs it from.
  • mirrorParts — optional list of part files to flip left-right as they are read, e.g. ["eyewhite.png"]. Which way a part faces is fixed by the layout, and "left eye" cannot pin it down — it reads as the viewer's left or the character's — so in image terms: eyewhite.png is read as the eye on the screen left, lash wing (outer corner) at the image's left end and lash-free tear duct at its right; brow.png as the brow on the screen right, thick head at the image's left end and tail at its right; blush.png as the blush on the screen left, outer end (toward the face's edge) at the image's left end and inner end at its right; arm.png as the arm on the screen left (the character's right), hanging, its shoulder at the image's top; hair_side.png as the front side lock on the screen left, its root at the image's top; forearm_pose.png as the raised forearm on the screen left, standing up from its elbow, the hand at the image's top and the thumb toward the body at its right. A part drawn the other way round is fixed here for free instead of regenerated. It flips the source, so every role cut from it flips together and an eye's sclera and lash stay in one frame.
  • canvasHeight — optional height of the canvas in px: an even integer in 1100..4096, default 1100, a square bust canvas — and at 1100 every output is byte-identical to leaving it out. The width stays 1100. The canvas grows downward: every default and every override keeps its canvas px from the top-left, so the head lands where it does on a bust and a full body gets room below. An odd height is refused, since model space is centred on the canvas and it would put the head on a half pixel. It is checked before any part decodes.
  • Result — on success the text is the written layer paths (one per line) followed by the same geometry report measure_layers returns — except that when the composer found the core of the nose's source part a speck, its nose check reports that verdict instead of what the composed file shows, so a speck that resampling erased from the layer is warned about here and not by measure_layers. structuredContent is { ok: true, outDir, layers, skipped, preview, previewPose?, measure } (previewPose only with a forearm_pose.png). With the lip set preview.png shows the mouth closed, as the rig draws the rest pose (the tongue and the teeth left out with the interior), and skipped lists mouth_tongue / mouth_teeth when the interior has no light paint. Invalid input (a missing required part, a canvasHeight that is odd or outside 1100..4096, an unknown layout role, an out-of-range w or h, a lash placed on a different frame from its sclera's, an arm.png without a body.png, a forearm_pose.png without an arm.png, a lip set with one source missing or beside the legacy mouth, a key that fails (no green, green outside the opening, an outline not closed round it, more than one opening, no skin under it, an interior that is only lips or drawn opaque on a non-white or noisy ground), an arm too short for the rig to hang an elbow under its shoulder, a mirrorParts entry that is not a part file, a part that lands entirely off-canvas, a non-existent outDir) returns { ok: false, error } with INVALID: … text.

measure_layers

Reports the same read-only geometry checks compose_layers_from_parts returns inline (iris size/offset relative to the sclera, eye aspect, an eye drawn facing the other way, cropped or flat-cut edges, a nose whose dense core is a speck of its crop, missing optional roles, for a side lock: one without hair_front, one whose top row shows past the bangs at rest, one covering the eye white's outer corner at rest, one whose lean on the turn away from it would bare columns neither hair_back nor the face paints, and a hair_side.png drawing two locks (a lock set on another canvas than hair_front's is warned of too), and for a full body: a body whose feet the bottom of a canvas taller than wide cuts off, an arm without a body, an arm whose shoulder cap — the one auto_rig_from_layers turns it about, read by the rig's own rule — does not reach half its radius under the torso's edge on its shoulder pivot's row, a pose forearm without its arm or whose elbow end is more than 2 px off the arm's elbow, more than 10 % off its elbow run in width, or more than 15 % off its hand's reach in length, and for the lip set: a partial set or one beside mouth / mouth_open, a column of the opening where the interior does not reach the line or the skin does not reach the interior, an opening under 0.3 of the upper lip's width or under 8 rows tall, a line under 2 rows, key green left, an interior with transparent holes, and a mouth_tongue / mouth_teeth with no lip set, on another canvas, or whose box leaves mouth_inner's, where the cavity clips it away), over an already-composed layers directory — for re-checking a layers dir without recomposing it. Its nose check reads the composed file against its crop, which is what auto_rig_from_layers acts on: a speck core there is one the rig does not turn or tilt the nose about. The composer's inline report does the same unless it found the source part's core a speck, which it reports instead, so a speck that resampling erased from the layer shows there and not here.

  • layersDir — directory of role-named layer PNGs (resolved against the working directory). Every preview*.png in it is skipped.
  • Result — the text is the report: a per-layer size/bbox-centre/mass-centre/margins table, then, with a lip set, one lips: line — the opening's width, its height at the centre, the line's rows and the MouthOpen below which no slit shows — then the checks that fired. structuredContent is { ok: true, layersDir, layers, empty, warnings, lips?, passed }. A missing or non-directory layersDir returns { ok: false, error } with INVALID: … text.

measure_turn_reference

Measures how far a head turns between two images of the same character — one facing front, one turned — and reports it as three ratios, so a rigged turn can be compared against a reference turn (or against an earlier rig) without registering the two images. Every number is a front→turned change divided by something measured in the same image, which cancels crop and position — not scale: the pair must already share framing and head size. A yaw never changes iris height, so that is what is checked — a pair whose mean iris height differs by more than 10% is refused rather than measured as if it were a turn. A pair that shows a custom part (see auto_rig_from_layers's customParts) crossing the eye row reads a wider head than the rig fits to, since the rig measures the role layers alone: measure a pair drawn without the custom parts.

  • front, turned — PNG file paths (resolved against the server's working directory). Engine renders (transparent backdrop) and opaque reference art both work; see the two foreground modes below.
  • iris — optional colour-window override merged over the violet default (hueMin 230, hueMax 300 degrees, satMin 0.22). The iris is found as a saturated blob inside that hue window, closed and paired on one row, so a character whose eyes are another colour needs its own window — otherwise the tool returns no iris pair found … naming the file and how many candidate blobs it had.
  • debugDir — optional existing directory (confined to the working directory, like every other write) to drop a front-<name>.debug.png and a turned-<name>.debug.png into (role-prefixed, so two inputs that share a basename do not overwrite each other), with the iris boxes, the head edges, the head centre and the eye-pair centre drawn on them. The measurement is only believable once those boxes are seen sitting on the irises.
  • Result — structuredContent is { ok: true, front, turned, farEyeRatio, eyeShift, silhouetteRatio, turnSign, debug? }, with front/turned carrying the raw per-image numbers (iris widths and centres, eye row, head span, which foreground mode was used). A missing file, a missing debugDir, an image with no iris pair, or a pair whose mean iris heights differ by more than 10% (not at the same scale) returns { ok: false, error } with INVALID: … text.

The three ratios:

Ratio What it is
farEyeRatio Turned far/near iris width, divided by that same far/near ratio at rest — so a resting asymmetry in the art divides out.
eyeShift How far the eye pair slides across the head, in units of the front head half-width (hh). Negative = toward the image's left.
silhouetteRatio Head half-width, turned over front.

turnSign is -1 when the pair moved toward the image's left and +1 when it moved right; the "far" eye is the one on the side it moved toward.

The head span is the silhouette at the eye row, over a ±10-row band — fixed rather than scaled to the image, so compare renders at like resolutions. The foreground it spans is found two ways, chosen per image:

  • alpha — the file has an alpha channel with transparent pixels (an engine render): foreground is alpha >= 128 and nothing else, so the character's near-black hair ink and pale highlights all count.
  • keyed — a fully opaque image (a reference): the flat lavender-grey backdrop (hue 220–260, low saturation, bright) and near-black frame borders are keyed out by colour instead.

The two rules do not agree on the same picture — a near-black outline is silhouette under alpha and background under keyed — so compare renders with renders and references with references.

render_poses

Renders a rigged .iki into the pose PNGs the character loop reviews, with the real engine, so the render step is one tool call. The engine runs in the Chrome, Edge or Chromium already installed on the machine, headless and driven over DevTools by the server itself: no Playwright and no browser download. Set CHROME_PATH to an executable to pick a browser; without it the usual install locations are searched, and with none found the tool returns INVALID: … saying so, and a CHROME_PATH that is not an executable file is refused the same way. A browser that is found but fails to start is a tool error. It needs Node 22 or newer.

  • modelPath — the rigged .iki (resolved against the working directory; must sit under it).
  • outDir — an existing directory under the working directory. One <pose>.png per pose is written into it, replacing a same-named file in place.
  • poses — optional caller-named poses rendered instead of the standard set, each { name, values, crop? }: name becomes <outDir>/<name>.png (letters, digits, _, ., -; unique ignoring case), values are parameter settings (the rest at their defaults), and crop { x, y, w, h } is a rectangle in model px from the top-left — the frame of describe_iki's boxes and the FOLD lines — clamped to the canvas and drawn 720 px wide (an empty list, a bad or repeated name, a non-finite value, or a crop that misses the canvas or would draw under 1 or over 8192 px tall is INVALID: poses…; a parameter id the model lacks is ignored). Each pose is also added to the fold sweep, after the engine's own poses.
  • sweep — optional { name, preset: "turn", crop? }, rendered in addition to the poses: ParamAngleX eased 0 → −30 → +30 → 0 over 3 s (sinusoidal, so it never pauses at a stop and crosses 0 at its top speed), at 30 fps on a 60 Hz clock, with the hair physics running through IkiMotion and the idle, clips and expressions off (only the physics outputs reach the player), every other parameter at its default, after a 0.5 s warm-up at rest. The frames share one fixed framing: crop (model px, as a pose's) or the standard shots. name becomes the directory <outDir>/<name>/ — it starts with a letter or digit, then letters, digits, _, ., -; the tool creates it, refuses a symbolic link or a non-directory there; every run clears the dir's earlier fNNN.png, sheet.png, kymograph.png, manifest.json and index.html (by name, nothing else) before writing, so the dir is always this run's sweep. Written: fNNN.png (90 frames), manifest.json (version 2: parameters, and per frame i, file, t and values, the effective value of every scripted parameter and every physics output), sheet.png (nine frames of the −30 → +30 leg, chronological in a 3 × 3 grid, labelled with angle and time only, at most 2000 px a side), kymograph.png (the eye row of every frame, three px each, stacked in time: a bend at the centre is a kink, a trailing curve the hair's lag) and index.html (a flipbook that opens from disk; ?b=<relative dir of another sweep> plays two side by side). A sweep adds about 4–5 s on a bust (measured on the corpus characters). A server before 0.31.0 strips sweep and renders the stills alone.
  • sweeps — optional list of more sweeps rendered after sweep, each { name, preset: "turn" | "turn-nod" | "roll", crop? } into its own <outDir>/<name>/ with its own manifest, sheet and flipbook; an uncropped entry is framed like sweep (the standard shots, the middle square on a full body). Names are distinct from sweep's and each other's ignoring case and presets are distinct, so there is at most one of each (an empty list, a repeat or a bad crop is INVALID: sweeps…). turn is sweep's preset. turn-nod is the box (0,0) → (0,−30) → (−30,−30) → (−30,+30) → (+30,+30) → (+30,−30) → (0,−30) → (0,0) of ParamAngleX × ParamAngleY through all eight non-rest grid stops, each leg eased by a half-cosine (so every corner is held at zero speed), at 50°/s: 6 s, 180 frames at 30 fps, with the hair physics running and the idle off. Every stop lands exactly on a captured frame (f018 (0,−30), f036 (−30,−30), f054 (−30,0), f072 (−30,+30), f090 (0,+30), f108 (+30,+30), f126 (+30,0), f144 (+30,−30)). Its sheet.png is a 3 × 3 grid BY ANGLE — columns AngleX −30/0/+30, rows AngleY +30/0/−30, rest in the centre, cells labelled X, Y and t only — so a column is the nod at one turn; it has no kymograph (a fixed eye row stops showing the eyes on a nod). roll is the turn's eased curve (0 → −30 → +30 → 0 over 3 s, 90 frames) on ParamAngleZ, with the hair physics running and the idle off; its sheet.png is the nine frames nearest the turn sheet's angles on the −30 → +30 leg, cells labelled Z and t, and it has no kymograph (the eye row moves with the roll). It goes through sweeps only (sweep stays turn), and a roll adds no SWEEP line of its own and changes none (the lines are read from the model). A turn-nod sweep adds about 9 s, twice a turn's, and the two face-cropped together (a turn and a turn-nod in one call) about 14–16 s, measured on the corpus characters. A server before 0.32.0 strips sweeps and renders the rest; a server before 0.31.0 still strips sweep.
  • hideParts — optional part ids left out of the drawn frames of the call, poses and sweeps alike: the page is handed the model without them, while the fold, physics and sweep reports still read the whole model. It renders a character without its custom parts, so measure_turn_reference reads the rig's own head (a custom part crossing the eye row widens the head it measures, as it does on a drawn reference). An id the model lacks, or one that is the clip mask of a part that stays, or one a part that stays names in its occlusion.by, is INVALID: hideParts[i] … (hide both). A server before 0.34.0 strips it and draws every part.
  • What is written — the model decides the set. A bust gets 560 × 560 shots: rest, turn-m30, turn-p30, turn-15, nod-15, blink, blink-half, gaze, combined (ParamAngleX/Y/Z all at 30), stress (ParamAngleX/Y/Z all at −30, ParamMouthOpenY 1, ParamEyeLOpen and ParamEyeROpen 0.5, ParamBrowLY −1, ParamBrowRY 1, ParamBrowLAngle 1, ParamBrowRAngle −1, and each of ParamBodyAngleX/Y/Z the model declares at −10: moves that each look fine alone, stacked). A model with a mouth or mouth_inner adds 720 × 480 mouth crops (mouth-open-*-form-*, mouth-laugh, mouth-surprised, mouth-turn-p30-half). A full body (canvas taller than wide) shoots the same squares from the model's top (the head), centred horizontally, and adds whole-canvas full-* shots (body, arm and elbow poses) at 1400 px wide; one with a pose forearm (ParamArmPoseR) adds the full-pose-* shots.
  • Result — the text is the written paths, one per line (then, with sweep and then each of sweeps, its directory, sheet.png, kymograph.png when it has one, index.html and manifest.json), then the model's fold report, then its physics report, then the SWEEP lines. failedTextures lists the atlas pages the engine could not load; their parts are missing from the renders. structuredContent is { ok: true, outDir, canvas, fullBody, mouth?, failedTextures, poses: [{ name, path }], modelCanvas, folds, physics, sweep?, sweeps? }; sweep is { name, preset, dir, fps, frames, manifest, sheet, kymograph?, flipbook, report, nod } (kymograph absent for turn-nod and roll), and sweeps is a list of objects of that same shape, in request order, absent from a server before 0.32.0. A missing model, an outDir that is missing or outside the working directory, or a file that is not a valid model returns { ok: false, error } with INVALID: … text.
  • Folds — folds is the engine's checkFolds over its own pose set (foldPoses: rest, each parameter alone at its min and max, and the corners of the head and body angles crossed with the eyes, the mouth, the arms and the elbows), not over the rendered shots: { poses, thresholds: { flip: 0, collapse: 0.1 }, targets, offenders }, one target per warp deformer (its grid cells) and per mesh part (its triangles), each { target: { kind, id }, kind, worst?, expected? }: worst and expected are the least ratio of an area at a pose to the same at rest over the poses that are not, and that are, a by-design closure (below), each with its cell or triangle, its pose and its rest point; kind (flip, collapse or ok) is read off worst alone, and offenders are the targets that are not ok. The text prints one FOLD line per offender, worst first — flip (ratio ≤ 0) or collapse (under 0.1), deformer or part, its id, cell (col,row) or triangle i, the ratio (two significant figures under 0.01, so a flip never reads -0.00), the pose in brackets as its sorted id=value settings (rest for none), and where it sits at rest in model space and in model px from the top-left of modelCanvas (the layer PNGs' own pixels, not a render's) — or FOLDS: none over N poses. Then, when one folds, a FOLDS expected: line names the closures the auto-rig draws on purpose, each by part id, ratio and the parameter that shuts it: eye_L and lash_lower_L while ParamEyeLOpen is 0, eye_R and lash_lower_R while ParamEyeROpen is 0, and the lip set (mouth_inner, mouth_tongue, mouth_teeth, lip_lower, lip_upper) while ParamMouthOpenY is 0, read as each pose's effective value, its default included. The sweep covers the engine's pose set plus the caller's poses; a caller's pose is named in the FOLD lines by its sorted id=value settings (rest when empty), never by its PNG name, so a host reproduces any fold by setting those parameters on a player. Report-only: a fold never fails the render.
  • Physics — physics is the engine's checkPhysics over the model's own rigs (poses do not enter it): { thresholds: { displacementPx: 1, pinnedFrames: 60 }, targets, offenders }, one target per model.physics rig, then one per chain segment, in model order, each { rig, input, output, drives, kind, why?, step, idle }. rig is { kind: "spring", id } or { kind: "chain", id, segment }; input is every input parameter of the spring, in rig order, or every parameter that turns the chain's anchor; output is the driven parameter; drives lists what reads it, the parts then the deformers ({ kind, id }); kind is ok, frozen or unstable, and why, present when it is not ok, is one phrase naming the window it came from; offenders are the targets that are not ok, unstable first. Each output is excited through the engine's real drivers on a 60 Hz clock. The step holds a fresh rig's input at its far end — the end farther from its default — for 5 s; a spring steps each input that has a range alone, in its own run, and a chain each parameter that turns its anchor, and either reports the run moving the parts most among those that are not unstable. A lag input's step peaks at once at its bound, −scale × weight (less one sub-step), and its final reads rest: the bound is what a one-frame step shows, and a gradual turn swings less. The idle runs every rig and chain together behind the procedural idle, on a seeded rng, for 30 s. step is { values, peak, at, final, displacementPx }: the setting held, the output's largest signed displacement from rest and when, in seconds, its value at the end of the window, and the largest vertex move of any part in model px with the output alone at every value the step emitted. idle is { peak, at, displacementPx }, its peak a size, since the sway goes both ways, and its move taken at every value the idle emitted. A target is unstable when a spring's one-sub-step map has a spectral radius over 1 (exact, in closed form) or sits on its undamped boundary dt²k/m = 4, when a driver's finiteness guard fires (why says how often), or when the raw output stays outside its range for 60 consecutive frames (1 s), in either window. A chain's update is nonlinear, so it gets no radius verdict: a chain that grows yet stays finite and inside its range trips none of these, which is deferred to a later slice, and shows in the numbers only. A target is frozen when it drives nothing, none of its spring's inputs has a range, nothing turns its chain's anchor, or the step moves the parts under 1 model px. The amplitudes are numbers only: however little the idle moves an output, that never flags. The text prints one PHYSICS line per target after the fold lines — its kind, the rig (id, or id/segment [inputs] for a chain segment) and input -> output; then step, its setting as sorted id=value pairs (rest for none), the peak and when, the final value and the move, with the ids it drives in parentheses; then idle, its peak, when and move; and — <why> when it is not ok — or PHYSICS: no rigs. Parameter values and seconds print to two decimals and px to one, rounded down, so a frozen 0.96 px never reads 1.0. Report-only: nothing here refuses a rig or fails a render.
  • Sweep — sweep.report (when sweep was asked for) is geometry from the engine's landParts, not pixels, and it needs no browser: ParamAngleX from −30 to +30 in 1° steps, every other parameter at its default and no physics (it reads the rig; the frames show the rig plus hair). The landmarks are the eye_L and eye_R parts and the nose when there is one; the local face plate is the face part's landed vertex nearest each landmark's rest centre. Every distance is in fw, the face part's width in model px (describe_iki's faceWidth, the unit of a patch's by). Per landmark: amplitude = x(+30) − x(−30) (0 on a frozen rig); x kink and, for an eye, width kink = |s₊ − s₋| / max(|s₊|, |s₋|) with s₋ the slope over −5 → 0 and s₊ over 0 → +5, in fw per degree, n/a when both are under 1e-4 fw/deg; lead at −30 and +30 = how far the landmark moved beyond the plate; pop = the largest second difference of x over the ladder (the two steps touching 0 excluded) over the mean step, 0 on a rig linear on each side and large at a keyform that is not a stop. A final plate line gives the plate's own amplitude. The text prints SWEEP turn <id>: amplitude … fw, x kink …, width kink …, lead -30 … fw / +30 … fw, pop … per landmark and SWEEP turn plate: amplitude … fw, after the PHYSICS lines; without a face part or an eye pair it is SWEEP: unavailable — <reason> (sweep.report.unavailable). Report-only: no number here refuses a rig or fails a render, and a small pop is the rig's construction (an eye under bodyWarp lands as a product of two maps). sweep.nod (on every sweep object) is the nod's geometry from the same landParts, no browser: three ladders of ParamAngleY −30 → +30 in 1° steps at ParamAngleX −30, 0 and +30, every other parameter at its default and no physics, every coordinate over fw. SWEEP nod eyes: gap range X -30 … / 0 … / +30 … fw is, at each turn, the max − min over the ladder of the distance between the landed eye bbox centres; irises is the same for iris_L/iris_R when both exist, and mouth reads width range off the landed bbox width of lip_upper, else mouth (omitted with neither). SWEEP corner <id>: residual (-30,-30) … / (-30,+30) … / (+30,-30) … / (+30,+30) … fw per landmark among eye_L, eye_R and nose is the additivity residual max(|r_x|, |r_y|) with r = p(cx,cy) − p(cx,0) − p(0,cy) + p(0,0) on the bbox centre, the rest term included, so an additive rig reads 0.000. Both print once per call, after the SWEEP turn lines, with either preset (SWEEP nod: unavailable — <reason> without a face part or an eye pair; sweep.nod.unavailable). They are read against each other and against zero, never a threshold: on an additive rig the three nod ranges are equal (0.000 on the corpus) and the corner residuals are 0, so a nod range that differs between the turns, or a non-zero corner residual, says a corner keyform or a stop-local patch departs from the edges. On the corpus every nod and corner line reads 0.000; mint's four dropped far-eye patches (3d07017), replayed on its layers, read 0.038 fw on the eye gap at X −30 and 0.026 fw on eye_R's (−30,−30) corner.

probe_rig

Measures a rigged .iki through the engine's own landParts, so the numbers are what the player draws. It is for a rigging program, or an agent checking a custom part, that needs an exact distance a picture cannot give.

  • modelPath — the rigged .iki (resolved against the working directory; must sit under it).
  • queries — 1 to 64, answered in order, each one of:
    • { op: "paint", path } — the opaque runs (alpha 128 and over) of the layer PNG at path, as { y0, rows }: rows[i] is the list of [x0, x1) runs (x1 exclusive) of canvas row y0 + i, [] for a row inside the painted range with none; a layer with no opaque pixel gives { y0: 0, rows: [] }. It reads the layer file, not the atlas, so a quantized model reads the same, and the PNG must be the model's canvas size.
    • { op: "land" | "displacement", part, points, pose? } — for each point [x, y] of points (1 to 5000, canvas px), where it lands in pose, or the landing minus the point. A point is found inside one of the part's mesh triangles at rest (a part without a mesh, its unit quad) and moved by barycentric interpolation of the triangle's landed vertices. A point outside the part's mesh gives null, never an extrapolation.
  • pose — parameter id to value. A parameter it does not name stays at its default, a value outside the parameter's range is clamped as the player does, and an undeclared id or a non-finite value is refused.
  • outputPath — optional path ending in .probe.json under the working directory, its folder existing (any other name is refused, so a package.json is never replaced). The results are written there, the same JSON the text otherwise carries, and the text is the path and one line per query, so a part's paint never crosses the agent's context.
  • 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.
  • 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.

cut_layers_from_illustration

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.

  • 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.
  • 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> ….
  • 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.
  • 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.
  • 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.
  • 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.

A worked example, cut from one picture with its landmarks and rigged on every corpus run: corpus/twin-picture.

Usage

Run directly with npx (no install needed):

npx -y @ikijs/mcp

Or install globally and use the iki-mcp bin:

npm install -g @ikijs/mcp
iki-mcp

Claude Desktop / Claude Code / Codex config

Add to your MCP server config:

{ "mcpServers": { "iki": { "command": "npx", "args": ["-y", "@ikijs/mcp"] } } }

For Claude Desktop this goes in claude_desktop_config.json; for Claude Code it goes in .claude/mcp.json (or the equivalent per-project config). For Codex, register it from the shell:

codex mcp add iki -- npx -y @ikijs/mcp

Scope note

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.

License

MIT © Zeikar