Custom Pipes
Register formatting functions that become available in{{ }} expressions. Each pipe receives the current value and an optional colon-separated argument, just like built-in pipes. Drag the slider to see the stars pipe update live:
The tempColor pipe adds contextual emoji based on the value:
The initials pipe extracts first letters. Type a name to see it update:
Custom pipes follow the same rules as built-in ones — they’re synchronous, pure functions. Built-in pipes always take priority, so you can’t accidentally shadow number or currency.
Custom Action Handlers
Register functions that transform state in response to events. Handlers receive a context object with the current state snapshot and the triggering event, and return an object of state updates to merge.| Field | Description |
|---|---|
ctx.state | Snapshot of the full state at the time the handler fires. Read-only — return updates instead of mutating. |
ctx.event | The $event value from the triggering interaction (slider value, click event, etc.). |
ctx.arguments | Optional extra arguments from the CallHandler action spec. |
SetState. If the handler returns nothing (void/undefined), no state changes happen.
CallHandler Action
CallHandler is the action that invokes a registered handler. It mirrors CallTool — where CallTool calls a server-side MCP tool, CallHandler calls a client-side JavaScript function.
$result in onSuccess callbacks, just like CallTool:
Example: Linked Sliders
Three budget sliders constrained to sum to 100%. Moving one redistributes the others proportionally. This is the kind of client-side coordination that expressions can’t do — you need a function that knows about all the sliders and can compute the redistribution.uv run python examples/linked_sliders.py to see it in action. The handler runs client-side on every drag — no server round-trip, no lag.
API Reference
PrefabApp Fields
Custom pipe functions. Keys are pipe names, values are JavaScript function expressions. Each function receives
(value, arg?) and returns the transformed value.Custom action handlers. Keys are handler names, values are JavaScript function expressions. Each function receives
(ctx) with {state, event, arguments} and returns state updates to merge.