explain_model
Generate human-readable documentation for Pydantic models and Python types to clarify data structures, constraints, and examples for better understanding.
Instructions
Turn a model or type into a human-readable contract.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| include_examples | No | ||
| include_constraints | No | ||
| include_defaults | No |
Implementation Reference
- src/pydantic_mcp/tools.py:102-125 (handler)The `explain_model` tool implementation, which resolves the target model and uses `explain_model_data` to generate a contract.
@mcp.tool(tags={"inspect", "pydantic"}) def explain_model( target: str, include_examples: bool = True, include_constraints: bool = True, include_defaults: bool = True, ) -> ToolResponse: """Turn a model or type into a human-readable contract.""" runtime_target = resolve_target( target, registry=REGISTRY, settings=SERVER_SETTINGS, ) result = explain_model_data( runtime_target, include_constraints=include_constraints, include_defaults=include_defaults, ) if include_examples: result["examples"] = [ item.model_dump(mode="json") for item in create_examples(runtime_target, count=1, invalid=True) ] return make_response(resolved_target=runtime_target.resolved, result=result)