π The fast, Pythonic way to build MCP servers and clients.
fix tool description indentation issue #844 https://github.com/jlowin/fastmcp/issues/844
Ryan Fange485eb298f52
diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.pyindex c8193a078..48343e2bb 100644--- a/src/fastmcp/prompts/prompt.py+++ b/src/fastmcp/prompts/prompt.py@@ -155,7 +155,7 @@ class FunctionPrompt(Prompt):if param.kind == inspect.Parameter.VAR_KEYWORD:raise ValueError("Functions with **kwargs are not supported as prompts")- description = description or fn.__doc__+ description = description or inspect.getdoc(fn)# if the fn is a callable class, we need to get the __call__ method from here outif not inspect.isroutine(fn):diff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.pyindex fc4ece58f..8e7ce307f 100644--- a/src/fastmcp/resources/resource.py+++ b/src/fastmcp/resources/resource.py@@ -135,7 +135,7 @@ class FunctionResource(Resource):fn=fn,uri=uri,name=name or fn.__name__,- description=description or fn.__doc__,+ description=description or inspect.getdoc(fn),mime_type=mime_type or "text/plain",tags=tags or set(),enabled=enabled if enabled is not None else True,diff --git a/src/fastmcp/resources/template.py b/src/fastmcp/resources/template.pyindex 36e05be11..acbb98eeb 100644--- a/src/fastmcp/resources/template.py+++ b/src/fastmcp/resources/template.py@@ -214,7 +214,7 @@ class FunctionResourceTemplate(ResourceTemplate):f"URI parameters {uri_params} must be a subset of the function arguments: {func_params}")- description = description or fn.__doc__+ description = description or inspect.getdoc(fn)# if the fn is a callable class, we need to get the __call__ method from here outif not inspect.isroutine(fn):diff --git a/src/fastmcp/tools/tool.py b/src/fastmcp/tools/tool.pyindex 9b94bb00e..14fe7f8b6 100644--- a/src/fastmcp/tools/tool.py+++ b/src/fastmcp/tools/tool.py@@ -231,7 +231,7 @@ class ParsedFunction:# collect name and doc before we potentially modify the functionfn_name = getattr(fn, "__name__", None) or fn.__class__.__name__- fn_doc = fn.__doc__+ fn_doc = inspect.getdoc(fn)# if the fn is a callable class, we need to get the __call__ method from here outif not inspect.isroutine(fn):