From 743a88792227963b253a8d9730aa30ea0c86cb92 Mon Sep 17 00:00:00 2001 From: techtoboggan Date: Thu, 9 Apr 2026 11:14:33 -0400 Subject: [PATCH] fix: inject progressToken when resetTimeoutOnProgress is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, _meta.progressToken was only injected into the outgoing JSON-RPC request when options.onprogress was provided. Setting resetTimeoutOnProgress: true alone had no effect because the SDK's _onprogress handler matches incoming notifications by params.progressToken → messageId — without a token in the request, server progress notifications can never be matched, and _resetTimeout is never called. This change expands the injection condition to also fire when resetTimeoutOnProgress is true, making the flag behave as its name implies: if you want the timeout to reset on progress, the server must be able to send progress notifications that match the request. The onprogress handler registration is unchanged — a no-op progressToken injection when only resetTimeoutOnProgress is set does not register a progress handler (avoiding unnecessary memory use). Fixes: https://github.com/modelcontextprotocol/typescript-sdk/issues/245 --- packages/core/src/shared/protocol.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/shared/protocol.ts b/packages/core/src/shared/protocol.ts index 57eab6932..7bd081e2c 100644 --- a/packages/core/src/shared/protocol.ts +++ b/packages/core/src/shared/protocol.ts @@ -832,8 +832,10 @@ export abstract class Protocol { id: messageId }; - if (options?.onprogress) { - this._progressHandlers.set(messageId, options.onprogress); + if (options?.onprogress || options?.resetTimeoutOnProgress) { + if (options.onprogress) { + this._progressHandlers.set(messageId, options.onprogress); + } jsonrpcRequest.params = { ...request.params, _meta: {