Skip to content

Commit eda4646

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 #3572), so clients can apply allow-reads/gate-sends policies to it. Protocol test pins them in tools/list; README lists them. Closes #3572 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent e718eca commit eda4646

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/fetch/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/fetch/src/mcp_server_fetch/server.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
PromptMessage,
4141
TextContent,
4242
Tool,
43+
ToolAnnotations,
4344
INVALID_PARAMS,
4445
INTERNAL_ERROR,
4546
)
@@ -418,6 +419,14 @@ async def serve(
418419
419420
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.""",
420421
input_schema=Fetch.model_json_schema(),
422+
# Reads only, changes nothing, and repeating a request has no further
423+
# side effect; it reaches arbitrary hosts on the internet (#3572).
424+
annotations=ToolAnnotations(
425+
read_only_hint=True,
426+
destructive_hint=False,
427+
idempotent_hint=True,
428+
open_world_hint=True,
429+
),
421430
)
422431

423432
async def list_tools(

‎src/fetch/tests/test_protocol.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ async def test_list_tools_wire_shape(web: FakeWeb) -> None:
129129
)
130130
assert "this tool now grants you internet access" in tool["description"]
131131
assert "outputSchema" not in tool
132+
# #3572: the tool declares what it does, for clients' approval policies.
133+
assert tool["annotations"] == {
134+
"readOnlyHint": True,
135+
"destructiveHint": False,
136+
"idempotentHint": True,
137+
"openWorldHint": True,
138+
}
132139
assert tool["inputSchema"] == {
133140
"description": "Parameters for fetching a URL.",
134141
"properties": {

0 commit comments

Comments
 (0)