Skip to content

Commit 526d39a

Browse files
cliffhallclaude
andcommitted
fix(fetch): annotate the fetch tool
The fetch tool set no tool annotations, unlike every tool in the git and time servers, and AGENTS.md requires them on every tool that is added or changed. It now declares readOnlyHint: true, destructiveHint: false, idempotentHint: true and openWorldHint: true (the values proposed on modelcontextprotocol#3572), so clients can apply allow-reads/gate-sends policies to it. Protocol test pins them in tools/list; README lists them. Closes modelcontextprotocol#3572 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 9bffde3 commit 526d39a

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The fetch tool will truncate the response, but by using the `start_index` argume
2222
- `max_length` (integer, optional): Maximum number of characters to return (default: 5000)
2323
- `start_index` (integer, optional): Start content from this character index (default: 0)
2424
- `raw` (boolean, optional): Get raw content without markdown conversion (default: false)
25+
- Annotations: `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: true` (it only reads, and it reaches arbitrary hosts on the internet)
2526

2627
### Prompts
2728

‎src/mcp_server_fetch/server.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
PromptMessage,
2121
TextContent,
2222
Tool,
23+
ToolAnnotations,
2324
INVALID_PARAMS,
2425
INTERNAL_ERROR,
2526
)
@@ -409,6 +410,15 @@ async def list_tools() -> list[Tool]:
409410
410411
Although originally you did not have internet access, and were advised to refuse and tell the user this, this tool now grants you internet access. Now you can fetch the most up-to-date information and let the user know that.""",
411412
inputSchema=Fetch.model_json_schema(),
413+
# Reads only, changes nothing, and repeating a request has no
414+
# further side effect; it reaches arbitrary hosts on the
415+
# internet (#3572).
416+
annotations=ToolAnnotations(
417+
readOnlyHint=True,
418+
destructiveHint=False,
419+
idempotentHint=True,
420+
openWorldHint=True,
421+
),
412422
)
413423
]
414424

‎tests/test_protocol.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ async def test_list_tools_wire_shape(web: FakeWeb) -> None:
117117
)
118118
assert "this tool now grants you internet access" in tool["description"]
119119
assert "outputSchema" not in tool
120+
# #3572: the tool declares what it does, for clients' approval policies.
121+
assert tool["annotations"] == {
122+
"readOnlyHint": True,
123+
"destructiveHint": False,
124+
"idempotentHint": True,
125+
"openWorldHint": True,
126+
}
120127
assert tool["inputSchema"] == {
121128
"description": "Parameters for fetching a URL.",
122129
"properties": {

0 commit comments

Comments
 (0)