From 3c6cfe7e7ea5212d159f74babbd9605eedae1342 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Sun, 6 Jul 2025 12:08:05 -0400 Subject: [PATCH] Use isawaitable instead of iscoroutine --- src/fastmcp/prompts/prompt.py | 2 +- src/fastmcp/resources/resource.py | 2 +- src/fastmcp/resources/template.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.py index 98518a24b..bd159663c 100644 --- a/src/fastmcp/prompts/prompt.py +++ b/src/fastmcp/prompts/prompt.py @@ -329,7 +329,7 @@ class FunctionPrompt(Prompt): # Call function and check if result is a coroutine result = self.fn(**kwargs) - if inspect.iscoroutine(result): + if inspect.isawaitable(result): result = await result # Validate messages diff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.py index 33d685322..a88174b8a 100644 --- a/src/fastmcp/resources/resource.py +++ b/src/fastmcp/resources/resource.py @@ -182,7 +182,7 @@ class FunctionResource(Resource): kwargs[context_kwarg] = get_context() result = self.fn(**kwargs) - if inspect.iscoroutinefunction(self.fn): + if inspect.isawaitable(result): result = await result if isinstance(result, Resource): diff --git a/src/fastmcp/resources/template.py b/src/fastmcp/resources/template.py index 6680de9c9..1b23081d2 100644 --- a/src/fastmcp/resources/template.py +++ b/src/fastmcp/resources/template.py @@ -190,7 +190,7 @@ class FunctionResourceTemplate(ResourceTemplate): kwargs[context_kwarg] = get_context() result = self.fn(**kwargs) - if inspect.iscoroutine(result): + if inspect.isawaitable(result): result = await result return result