WIP: feat: expose server notifications as an effect-specific stream - #232
Draft
sideeffffect wants to merge 1 commit into
Draft
WIP: feat: expose server notifications as an effect-specific stream#232sideeffffect wants to merge 1 commit into
sideeffffect wants to merge 1 commit into
Conversation
Add a `serverNotifications` extension to each streaming client module that surfaces server-pushed notifications as a stream native to the effect backend: an `ox.flow.Flow` for chimp-client-ox, a `ZStream` for chimp-client-zio, and a Pekko `Source` for chimp-client-pekko. Each stream registers a listener when it is run and removes it when it finishes. To support clean removal, `BidirectionalMcpClient` gains a `removeServerNotification` method (listeners are compared by reference). Closes softwaremill#222 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #222.
What
Alongside the existing callback API (
onServerNotification), each streaming client module now exposes server-pushed notifications as a stream native to its effect backend, via aserverNotificationsextension onBidirectionalMcpClient:chimp-client-oxox.flow.Flow[ServerNotification]chimp-client-zioZStream[Any, Throwable, ServerNotification]chimp-client-pekkoSource[ServerNotification, NotUsed]Each stream registers a listener when it is run/materialized and removes it when it finishes, so it does not leak listeners for the lifetime of the client.
How
BidirectionalMcpClientgainsremoveServerNotification(listener)(listeners compared by reference) so the streams can release their listener on completion. This is the only change to the public core API; the only implementor of the trait is the internal client impl.BoundedSourceQueue(synchronous, order-preserving FIFO) that drops the newest notification when the buffer is full.Tests
CapabilityHandlerSpecgets a case assertingremoveServerNotificationstops delivery.{Ox,Zio,Pekko}ServerNotificationsSpec) driving a sharedFakeNotificationClient, asserting the stream emits pushed notifications in order and removes its listener when done.sbt scalafmtCheckAll compile Test/compile compileDocsand the affected unit suites pass locally.Notes
docs/client/capabilities.md.🤖 Generated with Claude Code