-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(client): add reconnectionScheduler to StreamableHTTPClientTransport #1763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
felixweinberger
wants to merge
3
commits into
main
Choose a base branch
from
fweinberger/reconnection-scheduler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+212
−19
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@modelcontextprotocol/client': minor | ||
| --- | ||
|
|
||
| Add `reconnectionScheduler` option to `StreamableHTTPClientTransport`. Lets non-persistent environments (serverless, mobile, desktop sleep/wake) override the default `setTimeout`-based SSE reconnection scheduling. The scheduler may return a cancel function that is invoked on `transport.close()`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Nit: The
@exampleblock onReconnectionScheduler(lines 96–102) uses inline code, but CLAUDE.md L46 requires JSDoc examples to reference companion.examples.tsfiles withsource="./streamableHttp.examples.ts#ReconnectionScheduler_basicUsage". All other files in this directory (auth.ts,client.ts,middleware.ts,authExtensions.ts) follow this convention.Extended reasoning...
The project convention documented in CLAUDE.md line 46 states:
The new
ReconnectionSchedulertype exported fromstreamableHttp.tsincludes an inline@exampleblock (lines 96–102) that defines a code snippet directly in the JSDoc comment rather than pulling it from a companion file. NostreamableHttp.examples.tsfile exists. Meanwhile, all four other source files inpackages/client/src/client/that export public types with examples (auth.ts,authExtensions.ts,client.ts,middleware.ts) each have a corresponding.examples.tscompanion file.Addressing the refutation: The refutation argues that the example is "inherently non-type-checkable" because it references
platformBackgroundTask, a fictional API. This is a fair point — the example is conceptual. However, the convention still applies: the.examples.tsfile could define a minimal local interface (e.g.,interface PlatformBackgroundTask { schedule(...): string; cancel(id: string): void; }) to make the example type-check, or the example could be rewritten to use a real scheduling API. Other.examples.tsfiles in the project similarly set up mock infrastructure to make their examples compile.Impact: This is a documentation style convention issue only — no runtime behavior is affected. The inline example is perfectly clear and helpful to users. It simply does not follow the established project convention for type-checked examples.
Fix: Create a
packages/client/src/client/streamableHttp.examples.tscompanion file with a//#region ReconnectionScheduler_basicUsageblock containing the example code (with a local type stub for the hypothetical platform API), then update the JSDoc fence tosource="./streamableHttp.examples.ts#ReconnectionScheduler_basicUsage".