From 3ece6656d2dbf0f9cc2db89134d1ef628b17a2fc Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 26 Mar 2026 11:01:04 +0000 Subject: [PATCH] feat(mcp): add ChannelPush IPC message + HandleIPCEvents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Services can now push channel events to Claude Code by sending a ChannelPush message via Core IPC. The MCP service catches it in HandleIPCEvents and calls ChannelSend to the stdio transport. - ChannelPush{Channel, Data} message type in subsystem.go - HandleIPCEvents on Service catches ChannelPush → ChannelSend - Enables runner→mcp→Claude Code notification pipeline Co-Authored-By: Virgil --- pkg/mcp/register.go | 12 ++++++++++++ pkg/mcp/subsystem.go | 11 +++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/mcp/register.go b/pkg/mcp/register.go index 6b81d82..75a5284 100644 --- a/pkg/mcp/register.go +++ b/pkg/mcp/register.go @@ -80,6 +80,18 @@ func (s *Service) OnStartup(ctx context.Context) core.Result { return core.Result{OK: true} } +// HandleIPCEvents implements Core's IPC handler interface. +// Catches ChannelPush messages from other services and pushes them to Claude Code sessions. +// +// c.ACTION(mcp.ChannelPush{Channel: "agent.status", Data: statusMap}) +func (s *Service) HandleIPCEvents(c *core.Core, msg core.Message) core.Result { + switch ev := msg.(type) { + case ChannelPush: + s.ChannelSend(context.Background(), ev.Channel, ev.Data) + } + return core.Result{OK: true} +} + // OnShutdown implements core.Stoppable — stops the MCP transport. func (s *Service) OnShutdown(ctx context.Context) core.Result { if err := s.Shutdown(ctx); err != nil { diff --git a/pkg/mcp/subsystem.go b/pkg/mcp/subsystem.go index 67eef39..c77f90d 100644 --- a/pkg/mcp/subsystem.go +++ b/pkg/mcp/subsystem.go @@ -38,8 +38,15 @@ type Notifier interface { ChannelSend(ctx context.Context, channel string, data any) } -// Compile-time assertion: *Service implements Notifier. -var _ Notifier = (*Service)(nil) +// ChannelPush is a Core IPC message that any service can send to push +// a channel event to connected Claude Code sessions. +// The MCP service catches this in HandleIPCEvents and calls ChannelSend. +// +// c.ACTION(mcp.ChannelPush{Channel: "agent.status", Data: map[string]any{"repo": "go-io"}}) +type ChannelPush struct { + Channel string + Data any +} // SubsystemWithNotifier extends Subsystem for those that emit channel events. // SetNotifier is called after New() before any tool calls.