Skip to main content
Glama

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
NameRequiredDescriptionDefault
targetYes
dataYes
output_modeNopython
by_aliasNo
exclude_unsetNo
exclude_defaultsNo
exclude_noneNo
round_tripNo

Implementation Reference

  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BitingSnakes/pydantic-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server