Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
e98b7a0
1
Parent(s): 3caabbd
Update title precedence
Browse files
src/fastmcp/prompts/prompt.py
CHANGED
|
@@ -99,10 +99,8 @@ class Prompt(FastMCPComponent, ABC):
|
|
| 99 |
"name": self.name,
|
| 100 |
"description": self.description,
|
| 101 |
"arguments": arguments,
|
|
|
|
| 102 |
}
|
| 103 |
-
# Add title field if provided
|
| 104 |
-
if self.title is not None:
|
| 105 |
-
kwargs["title"] = self.title
|
| 106 |
return MCPPrompt(**kwargs | overrides)
|
| 107 |
|
| 108 |
@staticmethod
|
|
|
|
| 99 |
"name": self.name,
|
| 100 |
"description": self.description,
|
| 101 |
"arguments": arguments,
|
| 102 |
+
"title": self.title,
|
| 103 |
}
|
|
|
|
|
|
|
|
|
|
| 104 |
return MCPPrompt(**kwargs | overrides)
|
| 105 |
|
| 106 |
@staticmethod
|
src/fastmcp/resources/resource.py
CHANGED
|
@@ -113,10 +113,8 @@ class Resource(FastMCPComponent, abc.ABC):
|
|
| 113 |
"name": self.name,
|
| 114 |
"description": self.description,
|
| 115 |
"mimeType": self.mime_type,
|
|
|
|
| 116 |
}
|
| 117 |
-
# Add title field if provided
|
| 118 |
-
if self.title is not None:
|
| 119 |
-
kwargs["title"] = self.title
|
| 120 |
return MCPResource(**kwargs | overrides)
|
| 121 |
|
| 122 |
def __repr__(self) -> str:
|
|
|
|
| 113 |
"name": self.name,
|
| 114 |
"description": self.description,
|
| 115 |
"mimeType": self.mime_type,
|
| 116 |
+
"title": self.title,
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
| 118 |
return MCPResource(**kwargs | overrides)
|
| 119 |
|
| 120 |
def __repr__(self) -> str:
|
src/fastmcp/resources/template.py
CHANGED
|
@@ -146,10 +146,8 @@ class ResourceTemplate(FastMCPComponent):
|
|
| 146 |
"name": self.name,
|
| 147 |
"description": self.description,
|
| 148 |
"mimeType": self.mime_type,
|
|
|
|
| 149 |
}
|
| 150 |
-
# Add title field if provided
|
| 151 |
-
if self.title is not None:
|
| 152 |
-
kwargs["title"] = self.title
|
| 153 |
return MCPResourceTemplate(**kwargs | overrides)
|
| 154 |
|
| 155 |
@classmethod
|
|
|
|
| 146 |
"name": self.name,
|
| 147 |
"description": self.description,
|
| 148 |
"mimeType": self.mime_type,
|
| 149 |
+
"title": self.title,
|
| 150 |
}
|
|
|
|
|
|
|
|
|
|
| 151 |
return MCPResourceTemplate(**kwargs | overrides)
|
| 152 |
|
| 153 |
@classmethod
|
src/fastmcp/tools/tool.py
CHANGED
|
@@ -135,16 +135,21 @@ class Tool(FastMCPComponent):
|
|
| 135 |
pass # No context available
|
| 136 |
|
| 137 |
def to_mcp_tool(self, **overrides: Any) -> MCPTool:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
kwargs = {
|
| 139 |
"name": self.name,
|
| 140 |
"description": self.description,
|
| 141 |
"inputSchema": self.parameters,
|
| 142 |
"outputSchema": self.output_schema,
|
| 143 |
"annotations": self.annotations,
|
|
|
|
| 144 |
}
|
| 145 |
-
# Add title field if provided
|
| 146 |
-
if self.title is not None:
|
| 147 |
-
kwargs["title"] = self.title
|
| 148 |
return MCPTool(**kwargs | overrides)
|
| 149 |
|
| 150 |
@staticmethod
|
|
|
|
| 135 |
pass # No context available
|
| 136 |
|
| 137 |
def to_mcp_tool(self, **overrides: Any) -> MCPTool:
|
| 138 |
+
if self.title:
|
| 139 |
+
title = self.title
|
| 140 |
+
elif self.annotations and self.annotations.title:
|
| 141 |
+
title = self.annotations.title
|
| 142 |
+
else:
|
| 143 |
+
title = None
|
| 144 |
+
|
| 145 |
kwargs = {
|
| 146 |
"name": self.name,
|
| 147 |
"description": self.description,
|
| 148 |
"inputSchema": self.parameters,
|
| 149 |
"outputSchema": self.output_schema,
|
| 150 |
"annotations": self.annotations,
|
| 151 |
+
"title": title,
|
| 152 |
}
|
|
|
|
|
|
|
|
|
|
| 153 |
return MCPTool(**kwargs | overrides)
|
| 154 |
|
| 155 |
@staticmethod
|