Jeremiah Lowin commited on
Commit
78cdd55
·
1 Parent(s): ab749aa

Use isawaitable instead of iscoroutine

Browse files
src/fastmcp/prompts/prompt.py CHANGED
@@ -329,7 +329,7 @@ class FunctionPrompt(Prompt):
329
 
330
  # Call function and check if result is a coroutine
331
  result = self.fn(**kwargs)
332
- if inspect.iscoroutine(result):
333
  result = await result
334
 
335
  # Validate messages
 
329
 
330
  # Call function and check if result is a coroutine
331
  result = self.fn(**kwargs)
332
+ if inspect.isawaitable(result):
333
  result = await result
334
 
335
  # Validate messages
src/fastmcp/resources/resource.py CHANGED
@@ -182,7 +182,7 @@ class FunctionResource(Resource):
182
  kwargs[context_kwarg] = get_context()
183
 
184
  result = self.fn(**kwargs)
185
- if inspect.iscoroutinefunction(self.fn):
186
  result = await result
187
 
188
  if isinstance(result, Resource):
 
182
  kwargs[context_kwarg] = get_context()
183
 
184
  result = self.fn(**kwargs)
185
+ if inspect.isawaitable(result):
186
  result = await result
187
 
188
  if isinstance(result, Resource):
src/fastmcp/resources/template.py CHANGED
@@ -190,7 +190,7 @@ class FunctionResourceTemplate(ResourceTemplate):
190
  kwargs[context_kwarg] = get_context()
191
 
192
  result = self.fn(**kwargs)
193
- if inspect.iscoroutine(result):
194
  result = await result
195
  return result
196
 
 
190
  kwargs[context_kwarg] = get_context()
191
 
192
  result = self.fn(**kwargs)
193
+ if inspect.isawaitable(result):
194
  result = await result
195
  return result
196