fastmcp
fastmcp copied to clipboard
Add support for tool annotations
Enhancement Description
The MCP spec includes a section for tool annotations, allowing you to, among other things, provide human readable names to the consuming tools. Presently I don't see a way to pipe these annotations through the @tool decorator.
Use Case
For my part I'd like to provide more human names for tools than the name parameter allows, but the uses cases are mostly provided in the spec itself.
Proposed Implementation
Add an Annotations @dataclass for use in the tool decorator:
@dataclass
class Annotations:
title: str = None
read_only_hint: bool = false
destructive_hint: bool = true
idempotent_hint: bool = false
open_world_hint: bool = true
And expose the ability to apply this class from the top level decorator:
@mcp.tool(annotations = Annotations(title="Start a MyCompanyâ„¢ FooBar job")
def do_my_company_foo_bar:
pass