callServerTool: opt into progress-based timeout reset (#600)

A host may interpose a long-running or user-interactive step between the
guest's tools/call and the server's response. Without this, the base
SDK's default request timeout in Protocol.request() fires and the guest
sees -32001 even though the host is still working.

Passing onprogress causes Protocol.request to include _meta.progressToken
in the outgoing request and register a progress handler;
resetTimeoutOnProgress makes incoming notifications/progress reset the
per-request timer. Hosts can then heartbeat during long-running steps.
Callers can still override both.
This commit is contained in:
Roy Li 2026-04-14 05:06:22 -07:00 • committed by GitHub
commit c59c6060cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -860,7 +860,14 @@ export class App extends ProtocolWithEvents<
return await this.request(
{ method: "tools/call", params },
CallToolResultSchema,
options,
{
// Hosts may interpose long-running or user-interactive steps before the
// tool result arrives. Opting in here lets a host heartbeat keep the
// request alive past the default timeout; callers can still override.
onprogress: () => {},
resetTimeoutOnProgress: true,
...options,
},
);
}