Skip to content

Documentation mixes annotations={} options (dict/ToolAnnotations) #3944

@pamelafox

Description

@pamelafox

Enhancement

The documentation uses both approaches:

@mcp.tool(annotations={"readOnlyHint": True})
def get_user(user_id: str) -> dict:
    """Retrieve user information by ID."""
    return {"id": user_id, "name": "Alice"}

@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,  # Same result for repeated calls
        openWorldHint=False   # Only internal data
    )
)
def search_products(query: str) -> list[dict]:
    """Search the product catalog."""
    return [{"id": 1, "name": "Widget", "price": 29.99}]

Is that intentional? I would think the ToolAnnotations was the better approach for more type-safety, but I'm confused by the mixing of them in one example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationUpdates to docs, examples, or guides. Primary change is documentation-related.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions