Skip to content

Add tool annotations #1147

@danhellem

Description

@danhellem

add mcp tool annotations to all tools


MCP (Model Context Protocol) Tool Annotations

MCP (Model Context Protocol) tool annotations are specialized metadata attached to tools that allow MCP servers to communicate specific behavior characteristics to AI clients (like Claude, ChatGPT, or VS Code).

These annotations act as "hints" to describe how a tool works, enabling safer, more efficient, and more user-friendly interaction between AI models and external systems.


Key Aspects of MCP Tool Annotations

1. Advisory Nature

Annotations are informational hints, not rigid contracts. Clients should treat them as untrusted unless they originate from a trusted server.

2. Safety and Trust

They help manage risks in agentic workflows by distinguishing between safe read-only tools and potentially harmful actions.

3. User Experience

They allow client applications to present better UI, such as clearer tool names and confirmation dialogs for risky actions.


Key Standard MCP Tool Annotations

The MCP specification includes several standard annotations for defining tool behavior:

  • title (string):
    A human-readable name for the tool, used in user interfaces.

  • readOnlyHint (boolean):
    If true, the tool only reads data and does not modify the environment.

  • destructiveHint (boolean):
    If true, the tool performs irreversible actions (e.g., deletion), signaling the client to require human confirmation.

  • idempotentHint (boolean):
    If true, repeated identical calls have the same effect as a single call, making them safe for retries.

  • openWorldHint (boolean):
    If true, the tool interacts with external systems (e.g., API calls, internet access) rather than local resources.


Examples and Implementation

Annotations are implemented within the tool definition on the server side.

Example (Conceptual / Go)

mcp.NewTool("delete_user", 
    mcp.WithDescription("Deletes a user by ID"),
    // Annotations
    mcp.WithTitleAnnotation("User: Delete"),                
    mcp.WithReadOnlyHintAnnotation(false), // It modifies data
    mcp.WithDestructiveHintAnnotation(true), // It's dangerous
    mcp.WithOpenWorldHintAnnotation(true),
)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions