Tools Reference
The server exposes eight tools, split across two authoring surfaces. Each one is deterministic — no model calls happen inside the server.
- JSON form definition —
json_validate_form_definition,json_generate_from_schema,json_generate_from_openapi,json_get_widget_spec,get_concept. - Typed
gui.*builder code —dx_list_factories,dx_get_spec,dx_check_code.
The two surfaces have separate validators: use json_validate_form_definition for a JSON definition
object, and dx_check_code for gui.* TypeScript — they are not interchangeable.
json_validate_form_definition
Section titled “json_validate_form_definition”Validates a GolemUI form definition against the bundled JSON Schemas. Use it after generating or modifying a definition, to guarantee it is correct before the user pastes it into their codebase.
Input: { formDefinition: { form: [...], states?: {...} } } — pass the JSON object, not a
stringified version.
Output: { valid, errors, warnings, expressionWarnings, interpolationWarnings }.
errors— hard mistakes (typos in a widgettype, missing required props, invalid validator shapes). These flipvalidtofalse. Each carries a JSON Pointer path and a concrete fix suggestion (e.g. “format: 'mail'is not valid — did you mean'email'?”).warnings— likely-custom widgets (atypethat isn’t a built-in and isn’t close to one). These do not affectvalid.expressionWarnings— reactive expressions (include.when,disabled.when, …) linted for common mistakes like a missing$form.prefix, a single=in an equality check, or unbalanced brackets.interpolationWarnings: string interpolations ({{ }}in labels and other text) and the expressions in i18nparams, linted for the same class of mistakes. Advisory, likewarningsandexpressionWarnings; does not affectvalid.
Both lints also run the form’s own expression check.
An expression the form always rejects at runtime is an error in errors instead, with the keyword
reactiveExpression or stringInterpolation, and flips valid to false. These are the writes and
the code that the expression check lists, such as $form.tags.push(1), alert(1) or
$form.items['map'](f), and an expression that doesn’t parse. A call to a method that is not in the
allowed list, such as $form.name.padStart(2), stays a warning, because the form runs it unless
expressionPolicy is 'strict'.
json_generate_from_schema
Section titled “json_generate_from_schema”Converts a JSON Schema describing the form-data shape (e.g. an API request body or a Zod-derived
schema) into a GolemUI form definition, with fromJsonSchema and the gui
preset. The schema can be draft-04, draft-07 or 2020-12, and its top level must be an object. The tool
handles formats, enums, local $refs, allOf, nested objects, arrays, discriminated oneOf and
anyOf, and if/then/else, dependentRequired and dependentSchemas. The result is validated
before it is returned, so it is guaranteed syntactically correct.
Input: { jsonSchema, submitAction?, submitLabel?, layout?, rules?, overrides? }. layout is
one of vertical (default), horizontal, or grid. rules and overrides choose other widgets,
see Choosing other widgets.
Output: { formDefinition, unmapped, diagnostics, validation }. diagnostics lists everything
the form cannot express exactly. Each entry has a severity (error: not rendered, warning:
rendered approximately, info: a note), a code, a message, the data path and a JSON
pointer into the input. unmapped repeats the errors and warnings as { path, reason }. Surface
them to the user.
json_generate_from_openapi
Section titled “json_generate_from_openapi”Resolves a specific OpenAPI 3.x operation and converts its JSON request body like
json_generate_from_schema. The $refs in the body resolve against the whole document. Falls back
to the operation’s parameters when there is no request body, or when the body is not an object.
Input: { document | documentUrl, operation, submitAction?, submitLabel?, rules?, overrides? }.
operation is either "METHOD /path" (e.g. "POST /users") or an exact operationId. Pass the
spec as a parsed document or a documentUrl to fetch.
Output: { resolvedOperation, formDefinition, unmapped, diagnostics, validation }, same
guarantees as json_generate_from_schema.
See Generating from a schema for full examples of both generators.
json_get_widget_spec
Section titled “json_get_widget_spec”Returns the JSON Schema, kind, a minimal working example, and authoring notes for a single widget.
Cheaper than dumping the whole API into the model’s context — reach for it when you need to know
which props a widget accepts, what kind value it uses, or what shape its validator takes.
Input: { widgetType } — one of the widget type constants (textinput, dropdown,
repeater, grid, …). See the Widgets Reference for
the full list.
get_concept
Section titled “get_concept”Returns a detailed guide for a cross-cutting concept — things that span multiple widgets and affect
the whole form, rather than the API of a single widget. Call it when you need to change a widget’s
props based on form state (state-suffixed props like "label.<stateName>": "…"), reuse the same
condition across several widgets (include: { in: [...] } / exclude: { from: [...] }), reference
form data in reactive expressions ($form, $meta, $errors, $formIsInvalid, $fn), write
validators with custom error messages, or add icons to widgets. The validation guide covers the
same traps as Handling empty values: no validation at
mount, boolean required vs const, and the invalid message key.
Input: { concept } — currently supported: "states", "string-interpolation",
"reactive-scope", "validation", "icons".
dx_list_factories
Section titled “dx_list_factories”The complete gui.* typed-builder reference in a single call: every factory with its namespace,
calling convention, a compile-verified example, and its gotchas, plus the cross-cutting patterns
(e.g. conditional visibility) and the common authoring rules. The imports and render snippet are
tailored to your target framework. Call this first when writing gui.* code and author from it
directly — it is self-sufficient for most forms, so you rarely need a follow-up lookup. Import gui
only from @golemui/gui-shared; never hand-write raw { kind, type, path } widget JSON.
Input: none.
Output: the full factory catalog — every gui.* factory with its example and gotchas, the shared
patterns, and the framework-specific import + render snippet.
dx_get_spec
Section titled “dx_get_spec”A deep-dive on a single gui.* factory — its calling convention, a compile-verified example, and
authoring notes. You rarely need it: dx_list_factories already carries every factory’s example and
the cross-cutting rules. Reach here only to re-confirm one factory in isolation. Distinct from
json_get_widget_spec, which returns the JSON form-definition shape for the same widget.
Input: { factory } — the camelCase factory name (textInput, dropdown, radiogroup,
button, …).
dx_check_code
Section titled “dx_check_code”Type-checks gui.* builder code (TypeScript) against the real @golemui type declarations — the
DX-code counterpart to json_validate_form_definition (which checks a JSON object). The two are not
interchangeable. Because GolemUI isn’t in any model’s training data, generated gui.* code is often
a confident fabrication that doesn’t compile, and inspection misses it.
Beyond type errors it catches two defects the compiler can’t see: an include/exclude attached as
a sibling of a gui.* spread ({ ...gui.inputs.x(...), include } compiles but silently never hides
the field — it belongs inside the config argument), and reactive-expression mistakes in when
strings (linted by the same engine as json_validate_form_definition).
Input: { code } — the gui.* snippet as a string. A bare array of gui.inputs.* items is fine;
the @golemui/gui-shared import is added if missing.
Output: { ok, diagnostics, expressionWarnings }. Each diagnostic carries a TypeScript code
(0 for the static lints), a message, line/column, and — for recognized GolemUI mistakes — a
fix hint. An expression the form always rejects at runtime is a diagnostic too, so it flips ok. The
other expressionWarnings are advisory and do not flip ok. Treat ok: false as blocking:
apply the fixes and re-check until ok is true.