Skip to main content
Glama

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
NameRequiredDescriptionDefault
targetYes
countNo
invalid_examplesNo

Implementation Reference

  • 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]},
        )

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