Skip to main content
Glama

Validate a Formhaus definition

validate_definition
Read-only

Call this after writing or editing a definition and before simulate_path or publish_form; it checks the structure and engine rules, while simulate_path checks how a user moves through the form.

Instructions

Call this after writing or editing a definition and before simulate_path or publish_form; it checks the structure and engine rules, while simulate_path checks how a user moves through the form. Checks a Formhaus form definition against the JSON Schema and the engine. Returns { valid, issues }. Each issue has code, severity ("error" or "warning"), a JSON pointer path, message, hint and, when a repair is known, fixes: a list of { title, safe, patch } where patch is an RFC 6902 JSON Patch. Errors make the engine reject the definition, such as a condition with zero or two operators, a condition on a later step, a duplicate key, a route to an earlier step, a condition outside a group on a field inside it (group-scope) or a section inside a section (invalid-nesting). Warnings point to likely mistakes, such as a condition value that is not an option, contains on a field that does not hold a list (contains-not-list), a contains value that is not an option (contains-not-in-options), a select without options, next: false without an autoAdvance radio, scale or rating, a scale range outside 3 to 11 points, an anchor outside the range, or matrix rows whose options differ. Fix each error at its path, or apply one of its fixes, and call again. To apply every safe fix at once, call fix_definition.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "definition": "<definition>"
    },
    "name": "validate_definition"
  }
}

Input Schema

NameRequiredDescriptionDefault
definitionYesFormhaus form definition as a JSON object or a JSON string. JSON Schema: https://formhaus.dev/schema/form-definition.json. Top level: id, title, submit { label }, and fields (one step) or steps [{ id, title, fields }]. Field: { key, type, label, validation?, options?, show?, showAny? }. Rules go inside "validation": { required, minLength, maxLength, min, max, pattern, matchField }. Condition: { field, eq | neq | in | notIn | contains | notContains | notEmpty | gt | gte | lt | lte } with exactly one operator, on a field of the same or an earlier step. Optional: lang, messages and labels catalogs, and i18n objects that map texts to translation keys.

Output Schema

NameRequiredDescriptionDefault
validYesfalse when at least one issue has severity "error".
issuesYesErrors first, then warnings. Fix every error at its path and validate again.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.13.4
    • changedInput schema / properties / definition / description
      Previous value: -"Formhaus form definition as a JSON object or a JSON string. JSON Schema: https://formhaus.dev/schema/form-definition.json. Top level: id, title, submit { label }, and fields (one step) or steps [{ id, title, fields }]. Field: { key, type, label, validation?, options?, show?, showAny? }. Rules go inside \"validation\": { required, minLength, maxLength, min, max, pattern, matchField }. Condition: { field, eq | neq | in | notIn | notEmpty | gt | gte | lt | lte } with exactly one operator, on a field of the same or an earlier step. Optional: lang, messages and labels catalogs, and i18n objects that map texts to translation keys."New value: +"Formhaus form definition as a JSON object or a JSON string. JSON Schema: https://formhaus.dev/schema/form-definition.json. Top level: id, title, submit { label }, and fields (one step) or steps [{ id, title, fields }]. Field: { key, type, label, validation?, options?, show?, showAny? }. Rules go inside \"validation\": { required, minLength, maxLength, min, max, pattern, matchField }. Condition: { field, eq | neq | in | notIn | contains | notContains | notEmpty | gt | gte | lt | lte } with exactly one operator, on a field of the same or an earlier step. Optional: lang, messages and labels catalogs, and i18n objects that map texts to translation keys."
  2. Changed1 schema field changedv0.13.3
    • addedOutput schema / properties / issues / items / properties / fixes
      Added value: +{
      +  "description": "Ready repairs for this issue. Apply one patch to the definition, then validate again.",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "patch": {
      +        "description": "RFC 6902 JSON Patch operations (add, replace, remove, move) with JSON pointer paths.",
      +        "items": {
      +          "additionalProperties": {},
      +          "propertyNames": {
      +            "type": "string"
      +          },
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "safe": {
      +        "description": "true when applying the patch only repairs the issue and changes nothing else. fix_definition applies these.",
      +        "type": "boolean"
      +      },
      +      "title": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "title",
      +      "safe",
      +      "patch"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  3. First observedv0.13.1

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=true; the description adds real behavioral context by explaining what 'error' versus 'warning' means (errors cause engine rejection), listing representative causes, and stating the iterate-until-clean workflow. The return shape is partly duplicated from the output schema, which caps it just below the top.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded: purpose, timing, return shape, then the error/warning taxonomy. The long enumeration of warning cases is informative for interpreting output but is bulkier than strictly needed for tool selection, costing some conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Output schema exists, so return values needn't be re-explained, yet the description still covers error semantics, the repair loop, and the escape hatch to fix_definition. An agent has everything needed to call it, interpret results, and act on them.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There is one parameter and schema coverage is 100%, with the schema description itself explaining the object-or-JSON-string form and the definition shape. The prose adds no syntax or format detail beyond that, so the baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: checks a Formhaus form definition against the JSON Schema and the engine. It explicitly contrasts its role with simulate_path (which checks user flow), so an agent can distinguish the two without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit timing ('after writing or editing a definition and before simulate_path or publish_form'), names the alternatives, and routes to fix_definition for batch repairs. The when-to-use and when-to-use-something-else are both spelled out.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.