Add type checker to examples/client (#1837)
This commit is contained in:
parent
3863f203e9
commit
1fd557afdc
1 changed files with 65 additions and 37 deletions
|
|
@ -4,12 +4,12 @@ import asyncio
|
|||
|
||||
import click
|
||||
from mcp import ClientSession
|
||||
from mcp.client.streamable_http import streamablehttp_client
|
||||
from mcp.client.streamable_http import streamable_http_client
|
||||
from mcp.types import CallToolResult, TextContent
|
||||
|
||||
|
||||
async def run(url: str) -> None:
|
||||
async with streamablehttp_client(url) as (read, write, _):
|
||||
async with streamable_http_client(url) as (read, write, _):
|
||||
async with ClientSession(read, write) as session:
|
||||
await session.initialize()
|
||||
|
||||
|
|
@ -28,12 +28,13 @@ async def run(url: str) -> None:
|
|||
task_id = result.task.taskId
|
||||
print(f"Task created: {task_id}")
|
||||
|
||||
status = None
|
||||
# Poll until done (respects server's pollInterval hint)
|
||||
async for status in session.experimental.poll_task(task_id):
|
||||
print(f" Status: {status.status} - {status.statusMessage or ''}")
|
||||
|
||||
# Check final status
|
||||
if status.status != "completed":
|
||||
if status and status.status != "completed":
|
||||
print(f"Task ended with status: {status.status}")
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue