Skip to content

feat: support nested objects, typed arrays, and enums in schema conversion#4

Open
Alex647648 wants to merge 1 commit intodimensionalOS:masterfrom
Alex647648:feat/nested-schema-support
Open

feat: support nested objects, typed arrays, and enums in schema conversion#4
Alex647648 wants to merge 1 commit intodimensionalOS:masterfrom
Alex647648:feat/nested-schema-support

Conversation

@Alex647648
Copy link

Summary

  • Extract a recursive jsonSchemaPropToTypebox helper for per-property conversion
  • Nested object schemas with properties are now recursively converted instead of flattened to Record<string, unknown>
  • array types now preserve their items schema (e.g. Array<number> instead of Array<unknown>)
  • enum values are converted to Type.Union(Type.Literal(...))

Motivation

MCP tools often define complex input schemas with nested objects, typed arrays, and enum constraints. The previous flat conversion lost all this type information, meaning OpenClaw's type validation and agent tooling couldn't enforce correct parameter shapes.

Test plan

  • Register a tool with nested object params — verify the TypeBox schema reflects the nesting
  • Register a tool with items: { type: "number" } array — verify Array schema
  • Register a tool with enum params — verify Union/Literal schema is generated
  • Verify existing flat schemas still convert correctly (backwards compatible)

…conversion

The jsonSchemaToTypebox function previously flattened nested objects
into Record<string, unknown> and arrays into Array<unknown>, losing
all type information. Enum values were also ignored.

Extract a recursive jsonSchemaPropToTypebox helper that:
- Recursively converts nested object schemas with their properties
- Preserves array item schemas (e.g. Array<number> instead of Array<unknown>)
- Converts enum values to TypeBox Union/Literal types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant