π The fast, Pythonic way to build MCP servers and clients.
Update title precedence
Jeremiah Lowine0b6c321d29d
diff --git a/src/fastmcp/prompts/prompt.py b/src/fastmcp/prompts/prompt.pyindex 5022d0711..98518a24b 100644--- a/src/fastmcp/prompts/prompt.py+++ b/src/fastmcp/prompts/prompt.py@@ -99,10 +99,8 @@ class Prompt(FastMCPComponent, ABC):"name": self.name,"description": self.description,"arguments": arguments,+ "title": self.title,}- # Add title field if provided- if self.title is not None:- kwargs["title"] = self.titlereturn MCPPrompt(**kwargs | overrides)@staticmethoddiff --git a/src/fastmcp/resources/resource.py b/src/fastmcp/resources/resource.pyindex 113960630..77941e73d 100644--- a/src/fastmcp/resources/resource.py+++ b/src/fastmcp/resources/resource.py@@ -113,10 +113,8 @@ class Resource(FastMCPComponent, abc.ABC):"name": self.name,"description": self.description,"mimeType": self.mime_type,+ "title": self.title,}- # Add title field if provided- if self.title is not None:- kwargs["title"] = self.titlereturn MCPResource(**kwargs | overrides)def __repr__(self) -> str:diff --git a/src/fastmcp/resources/template.py b/src/fastmcp/resources/template.pyindex d8558e746..6680de9c9 100644--- a/src/fastmcp/resources/template.py+++ b/src/fastmcp/resources/template.py@@ -146,10 +146,8 @@ class ResourceTemplate(FastMCPComponent):"name": self.name,"description": self.description,"mimeType": self.mime_type,+ "title": self.title,}- # Add title field if provided- if self.title is not None:- kwargs["title"] = self.titlereturn MCPResourceTemplate(**kwargs | overrides)@classmethoddiff --git a/src/fastmcp/tools/tool.py b/src/fastmcp/tools/tool.pyindex c9787adc6..03cab7d3c 100644--- a/src/fastmcp/tools/tool.py+++ b/src/fastmcp/tools/tool.py@@ -135,16 +135,21 @@ class Tool(FastMCPComponent):pass # No context availabledef to_mcp_tool(self, **overrides: Any) -> MCPTool:+ if self.title:+ title = self.title+ elif self.annotations and self.annotations.title:+ title = self.annotations.title+ else:+ title = None+kwargs = {"name": self.name,"description": self.description,"inputSchema": self.parameters,"outputSchema": self.output_schema,"annotations": self.annotations,+ "title": title,}- # Add title field if provided- if self.title is not None:- kwargs["title"] = self.titlereturn MCPTool(**kwargs | overrides)@staticmethod