create_example_payload
Generate example valid and invalid payloads for Pydantic models and Python types to test data validation and understand type contracts.
Instructions
Generate example valid and invalid payloads for a target model or type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| count | No | ||
| invalid_examples | No |
Implementation Reference
- src/pydantic_mcp/tools.py:203-219 (handler)The implementation of the `create_example_payload` tool, which uses `resolve_target` and `create_examples` to generate valid/invalid payloads for a specified model.
@mcp.tool(tags={"examples", "pydantic"}) def create_example_payload( target: str, count: int = 1, invalid_examples: bool = False, ) -> ToolResponse: """Generate example valid and invalid payloads for a target model or type.""" runtime_target = resolve_target( target, registry=REGISTRY, settings=SERVER_SETTINGS, ) examples = create_examples(runtime_target, count=count, invalid=invalid_examples) return make_response( resolved_target=runtime_target.resolved, result={"examples": [item.model_dump(mode="json") for item in examples]}, )