Functions
function_to_schema
1
dict[str, Any]
▼
Generate MCP-compatible JSON Schema from a function's type annotations.
Parame…
function_to_schema
1
dict[str, Any]
▼
def function_to_schema(func: Callable[..., Any]) -> dict[str, Any]
Generate MCP-compatible JSON Schema from a function's type annotations.
Parameters namedrequest or annotated as Requestare excluded
(same convention as chirp route handlers).
Parameters with defaults are optional (not inrequired).
X | Noneunions are unwrapped to the base type.
Supports:str, int, float, bool, list[str],
list[int], list[float], X | None.
Parameters
| Name | Type | Description |
|---|---|---|
func |
Callable[..., Any] |
Returns
dict[str, Any]
_type_to_schema
1
dict[str, Any]
▼
Convert a Python type annotation to a JSON Schema fragment.
_type_to_schema
1
dict[str, Any]
▼
def _type_to_schema(annotation: Any) -> dict[str, Any]
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
Returns
dict[str, Any]
_is_optional
1
bool
▼
Check if an annotation is X | None.
_is_optional
1
bool
▼
def _is_optional(annotation: Any) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
Returns
bool
_unwrap_optional
1
Any
▼
Extract the non-None type from X | None.
_unwrap_optional
1
Any
▼
def _unwrap_optional(annotation: Any) -> Any
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
Returns
Any