Skip to main content

Overview

ChannelRegistry extends RegistryAbstract and manages all channel instances in a scope. It advertises experimental: { 'claude/channel': {} } in server capabilities when channels are registered.

Methods

getChannels

Get all channel entries.

getChannelInstances

Get all concrete channel instances.

findByName

Find a channel by its declared name.

hasAny

Check if any channels are registered.

size

Get the number of registered channels.

getCapabilities

Get MCP server capabilities contributed by channels.
Returns { experimental: { 'claude/channel': {} } } when channels exist, empty object otherwise.

subscribe

Subscribe to channel registry changes.
Returns an unsubscribe function.

ChannelChangeEvent

Accessing the Registry

The channel registry is available on the scope after initialization:

Session-Scoped Subscriptions

Channel notifications are session-scoped. Sessions must be subscribed to a channel to receive its notifications. This prevents data from leaking between connected agents. Subscription methods are on NotificationService (accessed via scope.notifications):

subscribeChannel

Subscribe a session to a specific channel. Returns true if this is a new subscription.

unsubscribeChannel

Remove a session’s subscription to a channel.

subscribeAllChannels

Bulk subscribe a session to multiple channels. Called automatically during MCP initialize when the client has claude/channel capability.

isChannelSubscribed

getSubscribersForChannel

Returns all session IDs subscribed to a channel.

getChannelSubscriptions

Returns all channel names a session is subscribed to.
Auto-subscription: When a session initializes with experimental: { 'claude/channel': {} } capability, it is automatically subscribed to all available channels. Channel subscriptions are cleaned up automatically when a session disconnects.

Session-Targeted Delivery

Events from session-scoped sources (agent completion, job completion) carry the originating sessionId and are delivered ONLY to that session:
Global events (webhooks, file changes, app events) have no targetSessionId and go to all subscribed sessions.

Replay Buffer

Channels with replay: { enabled: true } buffer events for later delivery:

replayBufferedEvents

Replay all buffered events to a session. Returns the number of events replayed. Replayed events include replayed: "true" in their meta.

clearReplayBuffer

Session-targeted events are NOT buffered (they’re ephemeral to the session). Only global events are stored in the replay buffer.

ChannelNotificationService

The companion service for sending notifications (session-scoped):

ChannelEventBus

The in-process event bus for app-event sources: