fix: add optional timeout to McpClient::send_request() (#852)

We now impose a 10s timeout on the initial `tools/list` request to an
MCP server. We do not apply a timeout for other types of requests yet,
but we should start enforcing those, as well.
This commit is contained in:
Michael Bolin
2025-05-07 12:56:38 -07:00
committed by GitHub
parent 0360b4d0d7
commit 9da6ebef3f
6 changed files with 85 additions and 31 deletions

View File

@@ -34,8 +34,9 @@ async fn main() -> Result<()> {
.with_context(|| format!("failed to spawn subprocess: {original_args:?}"))?;
// Issue `tools/list` request (no params).
let timeout = None;
let tools = client
.list_tools(None::<ListToolsRequestParams>)
.list_tools(None::<ListToolsRequestParams>, timeout)
.await
.context("tools/list request failed")?;