Hermolaos.Client.PubSubNotificationHandler (Hermolaos v0.3.0)

View Source

Notification handler that broadcasts events via Phoenix.PubSub or Registry.

This handler allows multiple processes to subscribe to MCP notifications.

Usage with Phoenix.PubSub

{:ok, conn} = Hermolaos.Client.Connection.start_link(
  transport: :stdio,
  command: "my-server",
  notification_handler: {
    Hermolaos.Client.PubSubNotificationHandler,
    %{pubsub: MyApp.PubSub, topic: "mcp:events"}
  }
)

# Subscribe in another process
Phoenix.PubSub.subscribe(MyApp.PubSub, "mcp:events")

receive do
  {:mcp_notification, method, params} -> ...
end

Usage with Registry

{:ok, conn} = Hermolaos.Client.Connection.start_link(
  transport: :stdio,
  command: "my-server",
  notification_handler: {
    Hermolaos.Client.PubSubNotificationHandler,
    %{registry: MyApp.MCPRegistry, key: "mcp_events"}
  }
)