Skip to content

Commit 3fad50f

Browse files
committed
SEP 1938 - Add agencyHint to tool annoations
1 parent c2bd1fa commit 3fad50f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/mcp/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,10 +1292,10 @@ class ToolAnnotations(BaseModel):
12921292

12931293
agencyHint: bool | None = None
12941294
"""
1295-
If true, this tool encapsulates an internal agent loop (e.g., plan–act–observe cycles, tool-chaining, or autonomous retries).
1295+
If true, this tool encapsulates an internal "agent loop" (e.g., plan–act–observe cycles, tool-chaining, or autonomous retries).
12961296
Default: false
12971297
"""
1298-
1298+
12991299
model_config = ConfigDict(extra="allow")
13001300

13011301

tests/server/fastmcp/test_tool_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ def read_data(path: str) -> str: # pragma: no cover
428428
title="File Reader",
429429
readOnlyHint=True,
430430
openWorldHint=False,
431+
agencyHint=True,
431432
)
432433

433434
manager = ToolManager()
@@ -437,14 +438,15 @@ def read_data(path: str) -> str: # pragma: no cover
437438
assert tool.annotations.title == "File Reader"
438439
assert tool.annotations.readOnlyHint is True
439440
assert tool.annotations.openWorldHint is False
441+
assert tool.annotations.agencyHint is True
440442

441443
@pytest.mark.anyio
442444
async def test_tool_annotations_in_fastmcp(self):
443445
"""Test that tool annotations are included in MCPTool conversion."""
444446

445447
app = FastMCP()
446448

447-
@app.tool(annotations=ToolAnnotations(title="Echo Tool", readOnlyHint=True))
449+
@app.tool(annotations=ToolAnnotations(title="Echo Tool", readOnlyHint=True, agencyHint=False))
448450
def echo(message: str) -> str: # pragma: no cover
449451
"""Echo a message back."""
450452
return message
@@ -454,6 +456,7 @@ def echo(message: str) -> str: # pragma: no cover
454456
assert tools[0].annotations is not None
455457
assert tools[0].annotations.title == "Echo Tool"
456458
assert tools[0].annotations.readOnlyHint is True
459+
assert tools[0].annotations.agencyHint is False
457460

458461

459462
class TestStructuredOutput:

tests/server/test_lowlevel_tool_annotations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async def list_tools(): # pragma: no cover
3535
annotations=ToolAnnotations(
3636
title="Echo Tool",
3737
readOnlyHint=True,
38+
agencyHint=True,
3839
),
3940
)
4041
]
@@ -98,3 +99,4 @@ async def handle_messages():
9899
assert tools_result.tools[0].annotations is not None
99100
assert tools_result.tools[0].annotations.title == "Echo Tool"
100101
assert tools_result.tools[0].annotations.readOnlyHint is True
102+
assert tools_result.tools[0].annotations.agencyHint is True

0 commit comments

Comments
 (0)