Skip to content

Commit f75029f

Browse files
committed
taskhint gone
1 parent 109920e commit f75029f

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
@@ -1264,7 +1264,15 @@ class ToolAnnotations(BaseModel):
12641264
Default: true
12651265
"""
12661266

1267-
taskHint: TaskHint | None = None
1267+
model_config = ConfigDict(extra="allow")
1268+
1269+
1270+
class ToolExecution(BaseModel):
1271+
"""Execution-related properties for a tool."""
1272+
1273+
model_config = ConfigDict(extra="allow")
1274+
1275+
task: Literal["never", "optional", "always"] | None = None
12681276
"""
12691277
Indicates whether this tool supports task-augmented execution.
12701278
This allows clients to handle long-running operations through polling
@@ -1277,8 +1285,6 @@ class ToolAnnotations(BaseModel):
12771285
Default: "never"
12781286
"""
12791287

1280-
model_config = ConfigDict(extra="allow")
1281-
12821288

12831289
class Tool(BaseMetadata):
12841290
"""Definition for a tool the client can call."""
@@ -1301,6 +1307,9 @@ class Tool(BaseMetadata):
13011307
See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
13021308
for notes on _meta usage.
13031309
"""
1310+
1311+
execution: ToolExecution | None = None
1312+
13041313
model_config = ConfigDict(extra="allow")
13051314

13061315

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)