Skip to main content

fastmcp.utilities.openapi.schemas

Schema manipulation utilities for OpenAPI operations.

Functions

clean_schema_for_display

Clean up a schema dictionary for display by removing internal/complex fields.

extract_output_schema_from_responses

Extract output schema from OpenAPI responses for use as MCP tool output schema. This function finds the first successful response (200, 201, 202, 204) with a JSON-compatible content type and extracts its schema. If the schema is not an object type, it wraps it to comply with MCP requirements. Args:
  • responses: Dictionary of ResponseInfo objects keyed by status code
  • schema_definitions: Optional schema definitions to include in the output schema
  • openapi_version: OpenAPI version string, used to optimize nullable field handling
Returns:
  • MCP-compliant output schema with potential wrapping, or None if no suitable schema found