Skip to content

Commit bedc297

Browse files
committed
taskhint gone
1 parent 9bd2aa8 commit bedc297

File tree

4 files changed

+89
-18
lines changed

4 files changed

+89
-18
lines changed

src/mcp/types.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,15 @@ class ToolAnnotations(BaseModel):
11181118
Default: true
11191119
"""
11201120

1121-
taskHint: TaskHint | None = None
1121+
model_config = ConfigDict(extra="allow")
1122+
1123+
1124+
class ToolExecution(BaseModel):
1125+
"""Execution-related properties for a tool."""
1126+
1127+
model_config = ConfigDict(extra="allow")
1128+
1129+
task: Literal["never", "optional", "always"] | None = None
11221130
"""
11231131
Indicates whether this tool supports task-augmented execution.
11241132
This allows clients to handle long-running operations through polling
@@ -1131,8 +1139,6 @@ class ToolAnnotations(BaseModel):
11311139
Default: "never"
11321140
"""
11331141

1134-
model_config = ConfigDict(extra="allow")
1135-
11361142

11371143
class Tool(BaseMetadata):
11381144
"""Definition for a tool the client can call."""
@@ -1155,6 +1161,9 @@ class Tool(BaseMetadata):
11551161
See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11561162
for notes on _meta usage.
11571163
"""
1164+
1165+
execution: ToolExecution | None = None
1166+
11581167
model_config = ConfigDict(extra="allow")
11591168

11601169

tests/experimental/tasks/server/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
TaskMetadata,
4545
TextContent,
4646
Tool,
47-
ToolAnnotations,
47+
ToolExecution,
4848
)
4949

5050

@@ -83,7 +83,7 @@ async def list_tools():
8383
"type": "object",
8484
"properties": {"input": {"type": "string"}},
8585
},
86-
annotations=ToolAnnotations(taskHint="always"),
86+
execution=ToolExecution(task="always"),
8787
)
8888
]
8989

tests/experimental/tasks/server/test_server.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
TaskMetadata,
4040
TextContent,
4141
Tool,
42-
ToolAnnotations,
42+
ToolExecution,
4343
)
4444

4545
# --- Experimental handler tests ---
@@ -215,8 +215,8 @@ async def handle_list_tasks(request: ListTasksRequest) -> ListTasksResult:
215215

216216

217217
@pytest.mark.anyio
218-
async def test_tool_with_task_hint_annotation() -> None:
219-
"""Test that tools can declare taskHint in annotations."""
218+
async def test_tool_with_task_execution_metadata() -> None:
219+
"""Test that tools can declare task execution mode."""
220220
server = Server("test")
221221

222222
@server.list_tools()
@@ -226,19 +226,19 @@ async def list_tools():
226226
name="quick_tool",
227227
description="Fast tool",
228228
inputSchema={"type": "object", "properties": {}},
229-
annotations=ToolAnnotations(taskHint="never"),
229+
execution=ToolExecution(task="never"),
230230
),
231231
Tool(
232232
name="long_tool",
233233
description="Long running tool",
234234
inputSchema={"type": "object", "properties": {}},
235-
annotations=ToolAnnotations(taskHint="always"),
235+
execution=ToolExecution(task="always"),
236236
),
237237
Tool(
238238
name="flexible_tool",
239239
description="Can be either",
240240
inputSchema={"type": "object", "properties": {}},
241-
annotations=ToolAnnotations(taskHint="optional"),
241+
execution=ToolExecution(task="optional"),
242242
),
243243
]
244244

@@ -250,12 +250,12 @@ async def list_tools():
250250
assert isinstance(result.root, ListToolsResult)
251251
tools = result.root.tools
252252

253-
assert tools[0].annotations is not None
254-
assert tools[0].annotations.taskHint == "never"
255-
assert tools[1].annotations is not None
256-
assert tools[1].annotations.taskHint == "always"
257-
assert tools[2].annotations is not None
258-
assert tools[2].annotations.taskHint == "optional"
253+
assert tools[0].execution is not None
254+
assert tools[0].execution.task == "never"
255+
assert tools[1].execution is not None
256+
assert tools[1].execution.task == "always"
257+
assert tools[2].execution is not None
258+
assert tools[2].execution.task == "optional"
259259

260260

261261
# --- Integration tests ---
@@ -274,7 +274,7 @@ async def list_tools():
274274
name="long_task",
275275
description="A long running task",
276276
inputSchema={"type": "object", "properties": {}},
277-
annotations=ToolAnnotations(taskHint="optional"),
277+
execution=ToolExecution(task="optional"),
278278
)
279279
]
280280

uv.lock

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)