From 5b999ac6f19bfebecb5910939e4f66cc048e0db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Algirdas=20=C4=8Ci=C4=8Dinskas?= Date: Mon, 21 Jul 2025 17:18:17 +0300 Subject: [PATCH] fix: save reference when using allOf / oneOf / anyOf (#1208) --- src/fastmcp/utilities/json_schema.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: