MCP · Lesson 23 of 120
Tool Annotations
Read-only or destructive.
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.

- 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.
| key | value |
|---|---|
| read_only_hint | changes nothing |
| destructive_hint | may delete |
| idempotent_hint | safe to repeat |
| open_world_hint | reaches 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