yera.tools.mcp.schema
Compile MCP JSON Schemas into Yera Struct types.
Symbols
generation_struct_from_json_schema
generation_struct_from_json_schema(
name: str,
schema: dict[str, object],
) → type[Struct]Compile MCP arguments for sparse LLM structured generation.
Non-required properties accept null so strict structured-output providers can express omission. The resulting values must still be reduced and validated through the ordinary execution structure.
Parameters
Name assigned to the generated Struct class.
MCP JSON Schema describing the tool arguments.
Returns
A dynamic Struct subclass suitable only for argument generation.
struct_from_json_schema
struct_from_json_schema(
name: str,
schema: dict[str, object],
) → type[Struct]Compile an MCP object schema into a dynamic Yera Struct type.
Parameters
Name assigned to the generated Struct class.
MCP JSON Schema describing the tool arguments.
Returns
A dynamic Struct subclass validating those arguments.
Raises
If the root is not an object schema or a property uses an unsupported schema shape.
type_from_json_schema
type_from_json_schema(
name: str,
schema: dict[str, object],
) → objectCompile JSON Schema into a Yera-supported Python type.
Unlike tool input compilation, the schema root may describe any supported JSON value rather than requiring an object.
Parameters
Name used for any generated Struct classes.
JSON Schema to compile.
Returns
A Python annotation suitable for Yera's coercion infrastructure.
type_from_mcp_output_schema
type_from_mcp_output_schema(
name: str,
schema: dict[str, object],
) → objectCompile an MCP tool output schema into its Python return type.
MCP servers represent scalar returns as an object containing one
required property named result. This wrapper belongs to the
protocol and is not exposed to Python callers.
Parameters
Name used for any generated Struct classes.
MCP output schema advertised by the server.
Returns
The unwrapped scalar type or compiled structured result type.