Skip to content

JSON schema parsing does not handle boolean true/false as a property schema  #3783

@jmoses

Description

@jmoses

What happened?

When hydrating a tool call response.data based on a JSON schema, if the tool call output schema has a boolean value for it's one of it's properties, fastmcp fails parsing. This is a valid scenario (since draft 06: https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.4.4) which is equivalent to the value being {}.

Example Code

from fastmcp.utilities.json_schema_type import json_schema_to_type

schema = {'$schema': 'https://json-schema.org/draft/2020-12/schema', 'title': 'DeduplicatedLogs', 'type': 'object', 'properties': {'timeRange': {'$ref': '#/$defs/FromTo'}, 'totals': {'$ref': '#/$defs/Totals'}, 'entries': {'type': 'array', 'items': {'$ref': '#/$defs/LogWithCount'}}}, 'required': ['timeRange', 'totals', 'entries'], '$defs': {'FromTo': {'type': 'object', 'properties': {'from_ms': {'description': 'Absolute time in milliseconds since the epoch.', 'type': 'integer', 'format': 'int64'}, 'to_ms': {'description': 'Absolute time in milliseconds since the epoch.', 'type': 'integer', 'format': 'int64'}}, 'required': ['from_ms', 'to_ms']}, 'Totals': {'type': 'object', 'properties': {'fetched': {'type': 'integer', 'format': 'uint', 'minimum': 0}, 'unique': {'type': 'integer', 'format': 'uint', 'minimum': 0}}, 'required': ['fetched', 'unique']}, 'LogWithCount': {'type': 'object', 'properties': {'log': {'$ref': '#/$defs/LogEntry'}, 'count': {'type': 'integer', 'format': 'uint64', 'minimum': 0}}, 'required': ['log', 'count']}, 'LogEntry': {'type': 'object', 'properties': {'_ts': {'type': 'integer', 'format': 'int64'}, '_line': {'type': ['string', 'null']}, 'message': {'type': ['string', 'null']}, 'level': True, '_app': True, 'app': True, '_host': True, 'host': True, '_tag': {'type': ['array', 'null'], 'items': {'type': 'string'}}}, 'required': ['_ts'], 'additionalProperties': True}}}

json_schema_to_type(schema)

Version Information

FastMCP version:                                                                          3.2.0
MCP version:                                                                             1.26.0
Python version:                                                                         3.12.13
Platform:                                                          macOS-15.7.4-arm64-arm-64bit
FastMCP root path: /Users/jon.moses/dev/mezmo/qa-mcp-testing/.venv/lib/python3.12/site-packages

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions