π The fast, Pythonic way to build MCP servers and clients.
Use isawaitable instead of iscoroutine
Jeremiah Lowin3c6cfe7e7ea5
diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.pyindex 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 coroutineresult = self.fn(**kwargs)- if inspect.iscoroutine(result):+ if inspect.isawaitable(result):result = await result# Validate messagesdiff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.pyindex 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 resultif isinstance(result, Resource):diff --git a/src/fastmcp/resources/template.py b/src/fastmcp/resources/template.pyindex 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 resultreturn result