fastmcp icon indicating copy to clipboard operation
fastmcp copied to clipboard

Add support for tool annotations

Open jdraymon opened this issue 8 months ago • 1 comments

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

jdraymon avatar Apr 30 '25 19:04 jdraymon