Help us shape the future of Go! Take the 2026 Go Developer Survey

listchanged

package
v1.150.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package listchanged provides a debounced, broadcaster-backed notifier that publishes a single MCP "*/list_changed" notification for a runtime-mutable entity set (prompts, managed resources) to every connected SSE long-poll subscriber, cross-replica via the session broadcaster's LISTEN/NOTIFY channel.

The platform runs the MCP SDK server in stateless mode, so the SDK's native server-push channel never reaches the platform's SSE clients. The gateway toolkit already substitutes its own broadcaster-backed tools/list_changed signal (see pkg/toolkits/gateway); this package is the same pattern factored into one reusable owner so prompts and managed resources emit list_changed through the identical path without each subsystem re-implementing the debounce.

A Notifier is bound to one JSON-RPC method (e.g. "notifications/prompts/list_changed") and one broadcaster. Notify schedules a debounced publish so a burst of writes (a bulk import) collapses into a single notification. All methods are safe for concurrent use and safe to call on a nil *Notifier, so a subsystem assembled before its broadcaster is wired can hold a nil notifier and every write path degrades to a no-op until SetBound.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	Publish(ctx context.Context, ev session.Event) error
}

Broadcaster is the subset of session.Broadcaster the notifier needs: fan-out publish of a server-originated notification. *session.MemoryBroadcaster and the postgres broadcaster both satisfy it.

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier publishes a debounced list_changed notification for one method through one broadcaster. The zero value is not usable; construct with New.

func New

func New(b Broadcaster, method string) *Notifier

New builds a Notifier that publishes method (a fully-qualified JSON-RPC notification method such as "notifications/prompts/list_changed") through b. A nil broadcaster yields a Notifier whose Notify is a no-op, so callers need not special-case the no-broadcaster (e.g. no-database) deployment.

func (*Notifier) Notify

func (n *Notifier) Notify()

Notify schedules a debounced publish. Multiple calls within debounceWindow collapse into a single fire. Safe for concurrent use and safe on a nil receiver or a nil broadcaster (both no-op). Never blocks on the broadcaster: the publish runs on a timer goroutine.

func (*Notifier) Stop

func (n *Notifier) Stop()

Stop cancels any pending notification and makes future Notify calls no-ops. Idempotent and safe on a nil receiver. Wire it to the platform lifecycle so a pending debounce timer does not fire after shutdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL