The server consumes notifications/initialized and
notifications/cancelled itself; every other inbound notification
(notably notifications/roots/list_changed) is delivered here so the
application can react — for example, re-calling ctx.listRoots() after
the client signals its root list changed (client/roots: "Servers SHOULD
... handle root list changes gracefully"). Mirrors the client-side
onNotification observer. Purely an application-facing callback; it does
not affect the JSON-RPC wire output for any protocol version.
The observer itself receives no RequestContext: inbound notifications are
dispatched without one. To issue the ctx.listRoots() refresh, capture a
server->client-capable RequestContext from a prior request handler (e.g. a
tools/call) and call it from this observer; on stdio that captured context
(a StdioContext bound to the duplex channel) round-trips the roots/list
request to the client from any task.
Observe inbound client-originated notifications.
The server consumes notifications/initialized and notifications/cancelled itself; every other inbound notification (notably notifications/roots/list_changed) is delivered here so the application can react — for example, re-calling ctx.listRoots() after the client signals its root list changed (client/roots: "Servers SHOULD ... handle root list changes gracefully"). Mirrors the client-side onNotification observer. Purely an application-facing callback; it does not affect the JSON-RPC wire output for any protocol version.
The observer itself receives no RequestContext: inbound notifications are dispatched without one. To issue the ctx.listRoots() refresh, capture a server->client-capable RequestContext from a prior request handler (e.g. a tools/call) and call it from this observer; on stdio that captured context (a StdioContext bound to the duplex channel) round-trips the roots/list request to the client from any task.