From f507fca384b63c0bac2d0a3c67ece0d6e17325bf Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Fri, 20 Jun 2025 07:03:24 -0400 Subject: [PATCH] Set type adapter parent depth to 3 --- src/fastmcp/utilities/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fastmcp/utilities/types.py b/src/fastmcp/utilities/types.py index 2397f73bf..0aee04791 100644 --- a/src/fastmcp/utilities/types.py +++ b/src/fastmcp/utilities/types.py @@ -38,8 +38,11 @@ def get_cached_typeadapter(cls: T) -> TypeAdapter[T]: create them once in a global scope and reuse them as often as possible. However, this isn't feasible for user-generated functions. Instead, we use a cache to minimize the cost of creating them as much as possible. + + The _parent_depth is set to 3 to look at an additional frame, since this + function is in its own scope. """ - return TypeAdapter(cls) + return TypeAdapter(cls, _parent_depth=3) def issubclass_safe(cls: type, base: type) -> bool: