Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/fastmcp/tools/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ def from_function(
input_schema,
prune_params=prune_params,
prune_titles=True,
dereference=True,
)
Comment on lines 500 to 503
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep input schemas dereferenced for client compatibility

Removing dereference=True here changes tool parameter schemas back to $ref/$defs form for common Pydantic inputs (e.g., user: UserInput), which regresses the compatibility behavior introduced for MCP clients that do not resolve JSON Schema refs. The codebase still documents this as required for clients like Copilot/Claude (src/fastmcp/utilities/json_schema.py) and existing tool-manager expectations assume inlined parameter objects, so this will make affected tools unusable in those clients rather than just changing formatting.

Useful? React with 👍 / 👎.


output_schema = None
Expand Down Expand Up @@ -561,7 +560,8 @@ def from_function(
output_schema = base_schema

output_schema = compress_schema(
output_schema, prune_titles=True, dereference=True
output_schema,
prune_titles=True,
)

# Resolve root-level $ref to meet MCP spec requirement for type: object
Expand Down
9 changes: 6 additions & 3 deletions tests/tools/test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,18 @@ def create_user(user: UserInput, flag: bool) -> dict:
"tags": set(),
"enabled": True,
"parameters": {
"properties": {
"user": {
"$defs": {
"UserInput": {
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name", "age"],
"type": "object",
},
}
},
"properties": {
"user": {"$ref": "#/$defs/UserInput"},
"flag": {"type": "boolean"},
},
"required": ["user", "flag"],
Expand Down
Loading