fastmcp.utilities.json_schema
Functions
dereference_refs
$ref values (those starting with #) are resolved.
Remote URIs (http://, file://, etc.) are stripped before
resolution to prevent SSRF / local-file-inclusion attacks when proxying
schemas from untrusted servers.
Args:
schema: JSON schema dict that may contain $ref references
- A new schema dict with defs removed
- when no longer needed
resolve_root_ref
schema: JSON schema dict that may have $ref at root level
- A new schema dict with root-level $ref resolved, or the original schema
- if no resolution is needed
compress_schema
schema: The schema to compressprune_params: List of parameter names to remove from propertiesprune_additional_properties: Whether to remove additionalProperties: false. Defaults to False to maintain MCP client compatibility, as some clients (e.g., Claude) require additionalProperties: false for strict validation.prune_titles: Whether to remove title fields from the schemadereference: Whether to dereference $ref by inlining definitions. Defaults to False; dereferencing is typically handled by middleware at serve-time instead.

