Update title precedence

This commit is contained in:
Jeremiah Lowin 2025-06-28 20:01:21 -04:00
commit e0b6c321d2
4 changed files with 11 additions and 12 deletions

View file

@ -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.title
return MCPPrompt(**kwargs | overrides)
@staticmethod

View file

@ -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.title
return MCPResource(**kwargs | overrides)
def __repr__(self) -> str:

View file

@ -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.title
return MCPResourceTemplate(**kwargs | overrides)
@classmethod

View file

@ -135,16 +135,21 @@ class Tool(FastMCPComponent):
pass # No context available
def 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.title
return MCPTool(**kwargs | overrides)
@staticmethod