(ctx: ServerRequestContext, params: CallToolRequestParams)
| 47 | ) |
| 48 | |
| 49 | async def handle_call_tool(ctx: ServerRequestContext, params: CallToolRequestParams) -> CallToolResult: |
| 50 | nonlocal call_count, first_request_id |
| 51 | if params.name == "test_tool": |
| 52 | call_count += 1 |
| 53 | if call_count == 1: |
| 54 | first_request_id = ctx.request_id |
| 55 | ev_first_call.set() |
| 56 | await anyio.sleep(5) # First call is slow |
| 57 | return CallToolResult(content=[TextContent(type="text", text=f"Call number: {call_count}")]) |
| 58 | raise ValueError(f"Unknown tool: {params.name}") # pragma: no cover |
| 59 | |
| 60 | server = Server("test-server", on_list_tools=handle_list_tools, on_call_tool=handle_call_tool) |
| 61 |
nothing calls this directly
no test coverage detected