π The fast, Pythonic way to build MCP servers and clients.
Avoid new try_eval_type unavailable on older pydantic
Michael Jurasovic2c896845fac6
diff --git a/src/fastmcp/utilities/func_metadata.py b/src/fastmcp/utilities/func_metadata.pyindex 9bd49214d..53b86fa6e 100644--- a/src/fastmcp/utilities/func_metadata.py+++ b/src/fastmcp/utilities/func_metadata.py@@ -8,7 +8,7 @@ from typing import ()from pydantic import Fieldfrom fastmcp.exceptions import InvalidSignature-from pydantic._internal._typing_extra import try_eval_type+from pydantic._internal._typing_extra import eval_type_lenientimport jsonfrom pydantic import BaseModelfrom pydantic.fields import FieldInfo@@ -178,12 +178,7 @@ def func_metadata(func: Callable, skip_names: Sequence[str] = ()) -> FuncMetadatdef _get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) -> Any:if isinstance(annotation, str):annotation = ForwardRef(annotation)- annotation, status = try_eval_type(annotation, globalns, globalns)-- # This check and raise could perhaps be skipped, and we (FastMCP) just call- # model_rebuild right before using it π€·- if status is False:- raise InvalidSignature(f"Unable to evaluate type annotation {annotation}")+ annotation = eval_type_lenient(annotation, globalns, globalns)return annotation