Skip to content

Commit 800b409

Browse files
committed
Use call_tool_as_task helper in simple-task-client example
Replace manual send_request with session.experimental.call_tool_as_task(), the helper that was previously marked as TODO.
1 parent 34ad089 commit 800b409

File tree

1 file changed

+5
-21
lines changed
  • examples/clients/simple-task-client/mcp_simple_task_client

1 file changed

+5
-21
lines changed

examples/clients/simple-task-client/mcp_simple_task_client/main.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55
import click
66
from mcp import ClientSession
77
from mcp.client.streamable_http import streamablehttp_client
8-
from mcp.types import (
9-
CallToolRequest,
10-
CallToolRequestParams,
11-
CallToolResult,
12-
ClientRequest,
13-
CreateTaskResult,
14-
TaskMetadata,
15-
TextContent,
16-
)
8+
from mcp.types import CallToolResult, TextContent
179

1810

1911
async def run(url: str) -> None:
@@ -28,18 +20,10 @@ async def run(url: str) -> None:
2820
# Call the tool as a task
2921
print("\nCalling tool as a task...")
3022

31-
# TODO: make helper for this
32-
result = await session.send_request(
33-
ClientRequest(
34-
CallToolRequest(
35-
params=CallToolRequestParams(
36-
name="long_running_task",
37-
arguments={},
38-
task=TaskMetadata(ttl=60000),
39-
)
40-
)
41-
),
42-
CreateTaskResult,
23+
result = await session.experimental.call_tool_as_task(
24+
"long_running_task",
25+
arguments={},
26+
ttl=60000,
4327
)
4428
task_id = result.task.taskId
4529
print(f"Task created: {task_id}")

0 commit comments

Comments
 (0)