Adds support for notifications/progress #168
Open
+123
−3
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.
Motivation and Context
this PR adds support for progress notifications (aka
notifications/progress) from the 2025-03-26 spec.How Has This Been Tested?
i validated this change locally within a private codebase that uses this swift package. i updated that codebase to point to this feature branch via
and confirmed that i received progress notifications when i attached a
progressTokento acallToolrequest.the spec mandates that both clients and servers should be capable of subscribing to progress notifications, but i only validated the client case. however, i believe the logic i wrote should work for servers subscribing to clients as well. if reviewers know of any sample projects in which i might validate this behavior, please let me know!
i also wrote some unit tests for the new ProgressNotification type following the existing pattern set by the ResourceUpdatedNotification unit tests.
Breaking Changes
there shouldn't be any! i followed @stallent's first suggestion in #82, which avoids breaking changes.
Types of changes
Checklist
i roughly adhered to the pattern set by ResourceUpdatedNotification, which has no special error handling. however, please let me know if there's something i missed, and i'd be happy to update this PR!
Additional context
there are multiple ways to support progress notifications within this repository, most of which @stallent outlines in #82. i'll summarize them here briefly, and explain why i chose this particular design:
progressTokenin_metaarguments when invoking a method (e.g.,callTool). sender does not deliver progress directly; instead, the caller must subscribe to thenotifications/progressstream for notifications (messages) with theprogressTokenpassed into the method.i did not consider option 2 because it doesn't feel like a modern iOS design pattern, and chose option 1 over option 3 because i like that it should work for all eligible methods with a minimal code footprint. the downside of option 1, however, is that the SDK does not make subscribing to progress notifications very obvious 😅 maintainers and community users, let me know what you think!