Skip to content

🚀 The fast, Pythonic way to build MCP servers and clients.

fix: save reference when using allOf / oneOf / anyOf (#1208)

Algirdas Čičinskas5b999ac6f19b
diff --git a/src/fastmcp/utilities/json_schema.py b/src/fastmcp/utilities/json_schema.py
index 29bb36aa3..e748ad8f9 100644
--- a/src/fastmcp/utilities/json_schema.py
+++ b/src/fastmcp/utilities/json_schema.py
@@ -53,7 +53,11 @@ def _prune_unused_defs(schema: dict) -> dict:
if skip_defs and k == "$defs":
continue
- walk(v, current_def=current_def)
+ if k in ["allOf", "oneOf", "anyOf"]:
+ for child in v:
+ walk(child, current_def=current_def)
+ else:
+ walk(v, current_def=current_def)
elif isinstance(node, list):
for v in node: