Skip to content

Declared schema defaults stay unhydrated with additionalProperties: true #5737

Closed

Description

@Vittuu

What happened?

With additionalProperties: true, a declared property's valid JSON default is returned without the hydration applied to the same explicitly supplied value. A default date is a str, while the equivalent explicit date becomes datetime.date. A nested-object default similarly remains a dict. Setting additionalProperties: false makes both paths hydrate consistently.

I also reproduced the date case through an in-memory Client(server): a tool returning ToolResult(structured_content={}) yields a string in result.data.day. I expected the same Python type whether the valid value came from the schema default or from the result. The wire content should stay unchanged.

Example Code

from fastmcp.utilities.json_schema_type import json_schema_to_type_adapter

schema = {
    "type": "object",
    "additionalProperties": True,
    "properties": {
        "day": {"type": "string", "format": "date", "default": "2026-10-13"}
    },
}
adapter = json_schema_to_type_adapter(schema)
print(type(adapter.validate_python({}).day).__name__)                       # str
print(type(adapter.validate_python({"day": "2026-10-13"}).day).__name__)   # date

Version Information

Reproduced on unchanged main at e2fcc412001ff7414095c5dc282f94c70299a612: FastMCP 4.1.1.dev2+e2fcc412, MCP 2.0.0, Pydantic 2.13.4, Python 3.13.14, Windows 11. No network or model credentials needed.

I searched related issues and PRs. #5656 addresses typed additional fields; this report concerns defaults of declared fields with additionalProperties: true.

AI assistance: Codex helped investigate and run the local reproductions. I would like to contribute a focused fix and regression tests for this inconsistency.

Activity

  1. added
    bug
    server
    on Oct 13, 2026
  2. added a commit that references this issue on Oct 19, 2026
    af562ae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugserver

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions