Skip to content

Conversation

@chr-hertel
Copy link
Member

@chr-hertel chr-hertel commented Feb 1, 2026

This is a working draft for emitting change notifications on dynamically added prompts, resources and tools.

The main issue here is that we need that indirection between Registry, source of truth on changing lists, and Protocol, that is able so send notifications. That's why we have those events, but we never really adopted them.

I introduced a slim EventDispatcher/ListenerProvider setup, but it feels a bit flaky - see wire up in example. The service landscape within the SDK just grows in complexity.

TBD

  1. Event Dispatcher
    The issue I had was mostly about PSR-14 - we want to empower library users to inject their own event dispatcher, to easily register subscriber/listener/whatever - but with the current implementation we also want to add our own listeners for triggering the notifications (again, we need a decoupling between registry and protocol currently).
    With PSR-14 the EventDispatcherInterface used in the Registry doesn't offer us to register our own listeners after a user injected it via Builder::setEventDispatcher()

  2. Session ID State
    I need to call the Protocol::sendNotification(...) from the listeners, but didn't have the session at hand - and there is basically no state in the Protocol - which is great, but we don't have a service concept to retrieve the session - it is only state in the transport or arguments looped through half the SDK.
    I went for introducing the session as state in the Protocol - needs better null-checks tho, but wanted to check with @CodeWithKyrian first - the other option would be to keep the transport as state, since it also has the session already as state.

WDYT?

edit: this currently messes up the session handling within a fiber intermediate client request.

@chr-hertel chr-hertel added the improves spec compliance Improves consistency with other SDKs such as TyepScript label Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improves spec compliance Improves consistency with other SDKs such as TyepScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant