Classes
MinLen
1
▼
Minimum length for strings (minLength) or items for arrays (minItems).
MinLen
1
▼
Minimum length for strings (minLength) or items for arrays (minItems).
Attributes
| Name | Type | Description |
|---|---|---|
value |
int
|
— |
MaxLen
1
▼
Maximum length for strings (maxLength) or items for arrays (maxItems).
MaxLen
1
▼
Maximum length for strings (maxLength) or items for arrays (maxItems).
Attributes
| Name | Type | Description |
|---|---|---|
value |
int
|
— |
Gt
1
▼
Exclusive minimum constraint for numbers.
Gt
1
▼
Exclusive minimum constraint for numbers.
Attributes
| Name | Type | Description |
|---|---|---|
value |
int | float
|
— |
Lt
1
▼
Exclusive maximum constraint for numbers.
Lt
1
▼
Exclusive maximum constraint for numbers.
Attributes
| Name | Type | Description |
|---|---|---|
value |
int | float
|
— |
Ge
1
▼
Inclusive minimum constraint for numbers.
Ge
1
▼
Inclusive minimum constraint for numbers.
Attributes
| Name | Type | Description |
|---|---|---|
value |
int | float
|
— |
Le
1
▼
Inclusive maximum constraint for numbers.
Le
1
▼
Inclusive maximum constraint for numbers.
Attributes
| Name | Type | Description |
|---|---|---|
value |
int | float
|
— |
Pattern
1
▼
Regex pattern constraint for strings.
Pattern
1
▼
Regex pattern constraint for strings.
Attributes
| Name | Type | Description |
|---|---|---|
value |
str
|
— |
Description
1
▼
Override or supplement the parameter description.
Description
1
▼
Override or supplement the parameter description.
Attributes
| Name | Type | Description |
|---|---|---|
value |
str
|
— |
Functions
function_to_schema
3
dict[str, Any]
▼
Generate MCP-compatible JSON Schema from function type annotations.
Parameters…
function_to_schema
3
dict[str, Any]
▼
def function_to_schema(func: Callable[..., Any], *, strict: bool = False, warn_missing_docs: bool = False) -> dict[str, Any]
Generate MCP-compatible JSON Schema from function type annotations.
Parameters with defaults are optional (not in required). X | None unions unwrapped to base type. Supports: str, int, float, bool, list[X], dict[str, X], X | None, Enum, Literal, dataclass, TypedDict, Union.
Parameter descriptions are extracted from the function's docstring
(Google, NumPy, or Sphinx style) and included as"description"
fields in the schema properties.
Context-typed parameters (and any parameter named ctx) are
intentionally omitted from the returned schema. The CLI dispatcher
injects them at call time, so they are invisible to MCP clients and
should not appear intools/listdescriptors. See
_is_context_type() for the exact detection rules.
When strict is True, unrecognized type annotations raise
TypeError instead of silently falling back to "string".
When warn_missing_docs is True, every schema parameter without a
description (noArgs: entry and no Annotated[..., Description(...)])
emits aUserWarning. Default Falseso production schema
generation stays silent;milo verifyopts in.
Parameters
| Name | Type | Description |
|---|---|---|
func |
Callable[..., Any] |
|
strict |
bool |
Default:False
|
warn_missing_docs |
bool |
Default:False
|
Returns
dict[str, Any]
_function_to_schema_cached
2
tuple[dict[str, Any], tu…
▼
Compute (schema, undocumented_param_names). Cached; warnings live in the wrappe…
_function_to_schema_cached
2
tuple[dict[str, Any], tu…
▼
def _function_to_schema_cached(func: Callable[..., Any], *, strict: bool = False) -> tuple[dict[str, Any], tuple[str, ...]]
Compute (schema, undocumented_param_names). Cached; warnings live in the wrapper.
Parameters
| Name | Type | Description |
|---|---|---|
func |
Callable[..., Any] |
|
strict |
bool |
Default:False
|
Returns
tuple[dict[str, Any], tuple[str, ...]]
_type_to_schema
4
dict[str, Any]
▼
Convert Python type annotation to JSON Schema fragment.
*_defs* accumulates ``…
_type_to_schema
4
dict[str, Any]
▼
def _type_to_schema(annotation: Any, _seen: set[int] | None = None, _defs: dict[str, dict[str, Any]] | None = None, *, _strict: bool = False) -> dict[str, Any]
Convert Python type annotation to JSON Schema fragment.
_defs accumulates$defsentries for recursive dataclasses so
they can be emitted as{"$ref": "#/$defs/ClassName"}.
When _strict is True, unrecognized types raise TypeError.
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
|
_seen |
set[int] | None |
Default:None
|
_defs |
dict[str, dict[str, Any]] | None |
Default:None
|
_strict |
bool |
Default:False
|
Returns
dict[str, Any]
_is_typed_dict
1
bool
▼
Check if annotation is a TypedDict subclass.
_is_typed_dict
1
bool
▼
def _is_typed_dict(annotation: Any) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
Returns
bool
_is_optional
1
bool
▼
Check if 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 non-None type from X | None.
_unwrap_optional
1
Any
▼
def _unwrap_optional(annotation: Any) -> Any
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
Returns
Any
return_to_schema
1
dict[str, Any] | None
▼
Generate JSON Schema from function return type annotation.
Returns None if the…
return_to_schema
1
dict[str, Any] | None
▼
def return_to_schema(func: Callable[..., Any]) -> dict[str, Any] | None
Generate JSON Schema from function return type annotation.
Returns None if the function has no return annotation or returns None.
Parameters
| Name | Type | Description |
|---|---|---|
func |
Callable[..., Any] |
Returns
dict[str, Any] | None
_is_context_type
2
bool
▼
Check if an annotation refers to milo's Context type.
_is_context_type
2
bool
▼
def _is_context_type(annotation: Any, name: str) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
annotation |
Any |
|
name |
str |
Returns
bool
_parse_param_docs
1
dict[str, str]
▼
Extract parameter descriptions from a docstring.
Supports Google, Sphinx, and …
_parse_param_docs
1
dict[str, str]
▼
def _parse_param_docs(docstring: str) -> dict[str, str]
Extract parameter descriptions from a docstring.
Supports Google, Sphinx, and NumPy docstring styles::
# Google style
Parameters
| Name | Type | Description |
|---|---|---|
docstring |
str |
Returns
dict[str, str]