AI Hints
Home›MCP Tutorial›Files, Annotations and Tool Shape
MCP · Lesson 23 of 120

Tool Annotations

Read-only or destructive.

⏱ 2 min read▶ Video at 20:48🎓 Free
Watch this lesson in the MCP courseWatch on YouTube ↗Full MCP course

Some tools only read. Others delete or change things. Tool annotations tell the host which is which, so it can, for example, ask the user before running a destructive tool.

Tool Annotations
From the video: Tool Annotations
  • Read or change
  • Annotations
  • Host can ask first

Marking tools

Tool annotations are hints. Search is read only. Cancel order is destructive, and not idempotent, since cancelling twice isn't the same as once. Run it. The client sees each tool's hints.

annotations.pypython
from mcp.server.mcpserver import MCPServer
from mcp_types import ToolAnnotations
from tester import tools

mcp = MCPServer("shop")

@mcp.tool(annotations=ToolAnnotations(read_only_hint=True))
def search(query: str) -> str:
    """Search products."""
    return "..."

@mcp.tool(annotations=ToolAnnotations(destructive_hint=True, idempotent_hint=False))
def cancel_order(order_id: int) -> str:
    """Cancel an order."""
    return "cancelled"

for t in tools(mcp):
    print(t.name, "| read only:", t.annotations.read_only_hint, "| destructive:", t.annotations.destructive_hint)
Output
search | read only: True | destructive: None
cancel_order | read only: None | destructive: True
Also uses tester.py
import asyncio
from mcp import Client

def call(server, tool, args=None, **options):
    async def go():
        async with Client(server, **options) as client:
            return await client.call_tool(tool, args or {})
    return asyncio.run(go())

def tools(server):
    async def go():
        async with Client(server) as client:
            return (await client.list_tools()).tools
    return asyncio.run(go())

The hints

Read only means it changes nothing. Destructive means it may delete or overwrite. Idempotent means calling twice is the same as once. Open world means it reaches outside, like the web. Hosts may use them, but they're only hints.

keyvalue
read_only_hintchanges nothing
destructive_hintmay delete
idempotent_hintsafe to repeat
open_world_hintreaches outside

Summary

Annotations tell hosts which tools only read and which can destroy. They're hints, not security. Next, many small tools or one big one.

Key takeaways
  • read_only
  • destructive
  • Only hints
Next up: Many Small Tools — or one big one