serialize_data
Convert validated Pydantic models into serialized formats like JSON or Python dictionaries using configurable serialization options.
Instructions
Dump validated data using Pydantic serialization behavior.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | ||
| data | Yes | ||
| output_mode | No | python | |
| by_alias | No | ||
| exclude_unset | No | ||
| exclude_defaults | No | ||
| exclude_none | No | ||
| round_trip | No |
Implementation Reference
- src/pydantic_mcp/tools.py:154-181 (handler)The implementation of the serialize_data tool handler.
def serialize_data( target: str, data: object, output_mode: str = "python", by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, ) -> ToolResponse: """Dump validated data using Pydantic serialization behavior.""" runtime_target = resolve_target( target, registry=REGISTRY, settings=SERVER_SETTINGS, ) response = serialize_with_adapter( runtime_target, data=data, output_mode=output_mode, by_alias=by_alias, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, round_trip=round_trip, ) _record_response_errors("serialize_data", target, response) return response