4141 GetPromptResult ,
4242 ImageContent ,
4343 TextContent ,
44+ ToolAnnotations ,
4445)
4546from mcp .types import Prompt as MCPPrompt
4647from mcp .types import PromptArgument as MCPPromptArgument
@@ -180,6 +181,7 @@ async def list_tools(self) -> list[MCPTool]:
180181 name = info .name ,
181182 description = info .description ,
182183 inputSchema = info .parameters ,
184+ annotations = info .annotations ,
183185 )
184186 for info in tools
185187 ]
@@ -248,6 +250,7 @@ def add_tool(
248250 fn : AnyFunction ,
249251 name : str | None = None ,
250252 description : str | None = None ,
253+ annotations : ToolAnnotations | None = None ,
251254 ) -> None :
252255 """Add a tool to the server.
253256
@@ -258,11 +261,17 @@ def add_tool(
258261 fn: The function to register as a tool
259262 name: Optional name for the tool (defaults to function name)
260263 description: Optional description of what the tool does
264+ annotations: Optional ToolAnnotations providing additional tool information
261265 """
262- self ._tool_manager .add_tool (fn , name = name , description = description )
266+ self ._tool_manager .add_tool (
267+ fn , name = name , description = description , annotations = annotations
268+ )
263269
264270 def tool (
265- self , name : str | None = None , description : str | None = None
271+ self ,
272+ name : str | None = None ,
273+ description : str | None = None ,
274+ annotations : ToolAnnotations | None = None ,
266275 ) -> Callable [[AnyFunction ], AnyFunction ]:
267276 """Decorator to register a tool.
268277
@@ -273,6 +282,7 @@ def tool(
273282 Args:
274283 name: Optional name for the tool (defaults to function name)
275284 description: Optional description of what the tool does
285+ annotations: Optional ToolAnnotations providing additional tool information
276286
277287 Example:
278288 @server.tool()
@@ -297,7 +307,9 @@ async def async_tool(x: int, context: Context) -> str:
297307 )
298308
299309 def decorator (fn : AnyFunction ) -> AnyFunction :
300- self .add_tool (fn , name = name , description = description )
310+ self .add_tool (
311+ fn , name = name , description = description , annotations = annotations
312+ )
301313 return fn
302314
303315 return decorator
0 commit comments