Skip to content

Commit 709d7d0

Browse files
Avoid helper checks on parameterized generics
1 parent b65095d commit 709d7d0

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/mcp/server/mcpserver/utilities/func_metadata.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,15 @@ def _try_create_model_and_schema(
428428

429429
def _contains_content_helper_type(annotation: Any) -> bool:
430430
"""Return whether an annotation contains an MCPServer content helper type."""
431-
if inspect.isclass(annotation):
432-
try:
433-
if issubclass(annotation, Image | Audio):
434-
return True
435-
except TypeError:
436-
pass
431+
origin = get_origin(annotation)
432+
if origin is None and inspect.isclass(annotation) and issubclass(annotation, Image | Audio):
433+
return True
437434

438435
args = get_args(annotation)
439436
if not args:
440437
return False
441438

442-
if get_origin(annotation) is Annotated:
439+
if origin is Annotated:
443440
return _contains_content_helper_type(args[0])
444441

445442
return any(_contains_content_helper_type(arg) for arg in args)

0 commit comments

Comments
 (0)