Expand description
Telling the sessions that a list changed — and the sessions that must not be told.
§The gate, and why it is the whole point
notifications/tools/list_changed is a capability a server advertises and a
client may or may not have asked about. Sending one to a session that never
advertised Feature::ToolsListChanged is a message the peer has no
contract for, and a peer that handles unknown notifications strictly — which
is most of them — answers with an error for a notification that has no id,
which cannot be correlated, and which then sits in a queue until the
connection times out.
So the fan-out is not “tell everyone what changed”. It is “tell the sessions whose negotiated profile already says they want to hear this, and tell each of them once”. Both halves are load-bearing and both have a test.
§What a subscriber carries, and why the caller supplies the method
A Subscriber holds a Feature and a method name, both supplied by the
caller rather than derived here. The registry’s job is “a session that
registered for this feature and this kind gets this frame”; which frame that
is, and which feature gates it, is a fact about the protocol, and the
protocol is not this module’s to name. A2A has no list_changed, and a
registry that hardcoded the MCP spelling would be a module that could not
serve it.
§Why one notification per publish, not per session
Each subscriber is sent at most once per publish, and only if the publish touched the kind it registered for. A publish that adds a tool and removes a resource sends a tool notification to tool subscribers and a resource notification to resource subscribers, and sends neither to anyone twice.
§Failures are counted, not propagated
A sink that has failed is counted in Fanout::failed and does not stop
the remaining subscribers from being told. One dead connection must not
silence the list_changed for every other live session — the count is
returned so the caller can drop the subscriber, and the fan-out carries on.
Structs§
- Fanout
- What one fan-out did.
- Subscriber
- One session’s standing interest in being told that a list changed.
- Subscriber
Set - The set of sessions currently listening.