Spaces:
Running
Running
Ryan Fang commited on
Commit ·
06b166f
1
Parent(s): 9fab331
fix tool description indentation issue #844 https://github.com/jlowin/fastmcp/issues/844
Browse files
src/fastmcp/prompts/prompt.py
CHANGED
|
@@ -155,7 +155,7 @@ class FunctionPrompt(Prompt):
|
|
| 155 |
if param.kind == inspect.Parameter.VAR_KEYWORD:
|
| 156 |
raise ValueError("Functions with **kwargs are not supported as prompts")
|
| 157 |
|
| 158 |
-
description = description or
|
| 159 |
|
| 160 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 161 |
if not inspect.isroutine(fn):
|
|
|
|
| 155 |
if param.kind == inspect.Parameter.VAR_KEYWORD:
|
| 156 |
raise ValueError("Functions with **kwargs are not supported as prompts")
|
| 157 |
|
| 158 |
+
description = description or inspect.getdoc(fn)
|
| 159 |
|
| 160 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 161 |
if not inspect.isroutine(fn):
|
src/fastmcp/resources/resource.py
CHANGED
|
@@ -135,7 +135,7 @@ class FunctionResource(Resource):
|
|
| 135 |
fn=fn,
|
| 136 |
uri=uri,
|
| 137 |
name=name or fn.__name__,
|
| 138 |
-
description=description or
|
| 139 |
mime_type=mime_type or "text/plain",
|
| 140 |
tags=tags or set(),
|
| 141 |
enabled=enabled if enabled is not None else True,
|
|
|
|
| 135 |
fn=fn,
|
| 136 |
uri=uri,
|
| 137 |
name=name or fn.__name__,
|
| 138 |
+
description=description or inspect.getdoc(fn),
|
| 139 |
mime_type=mime_type or "text/plain",
|
| 140 |
tags=tags or set(),
|
| 141 |
enabled=enabled if enabled is not None else True,
|
src/fastmcp/resources/template.py
CHANGED
|
@@ -214,7 +214,7 @@ class FunctionResourceTemplate(ResourceTemplate):
|
|
| 214 |
f"URI parameters {uri_params} must be a subset of the function arguments: {func_params}"
|
| 215 |
)
|
| 216 |
|
| 217 |
-
description = description or
|
| 218 |
|
| 219 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 220 |
if not inspect.isroutine(fn):
|
|
|
|
| 214 |
f"URI parameters {uri_params} must be a subset of the function arguments: {func_params}"
|
| 215 |
)
|
| 216 |
|
| 217 |
+
description = description or inspect.getdoc(fn)
|
| 218 |
|
| 219 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 220 |
if not inspect.isroutine(fn):
|
src/fastmcp/tools/tool.py
CHANGED
|
@@ -231,7 +231,7 @@ class ParsedFunction:
|
|
| 231 |
|
| 232 |
# collect name and doc before we potentially modify the function
|
| 233 |
fn_name = getattr(fn, "__name__", None) or fn.__class__.__name__
|
| 234 |
-
fn_doc =
|
| 235 |
|
| 236 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 237 |
if not inspect.isroutine(fn):
|
|
|
|
| 231 |
|
| 232 |
# collect name and doc before we potentially modify the function
|
| 233 |
fn_name = getattr(fn, "__name__", None) or fn.__class__.__name__
|
| 234 |
+
fn_doc = inspect.getdoc(fn)
|
| 235 |
|
| 236 |
# if the fn is a callable class, we need to get the __call__ method from here out
|
| 237 |
if not inspect.isroutine(fn):
|