From 1e3ac8a81577d2592af636d0533eb503852b8b9c Mon Sep 17 00:00:00 2001 From: Claude Code Date: Wed, 15 Apr 2026 06:43:43 -0500 Subject: [PATCH] feat(mcp): add ServerSession.Notify for custom notification methods Adds a public Notify method on ServerSession that allows sending notifications with arbitrary custom method names (e.g. notifications/claude/channel). The method validates that the method name starts with "notifications/" per the MCP specification before delegating to the underlying jsonrpc2 connection. This is needed for protocol extensions like Claude channels that use custom notification methods not covered by the built-in MCP notification types. Co-Authored-By: Claude Opus 4.6 --- mcp/server.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mcp/server.go b/mcp/server.go index 97b5d446..cb2a203b 100644 --- a/mcp/server.go +++ b/mcp/server.go @@ -20,6 +20,7 @@ import ( "path/filepath" "reflect" "slices" + "strings" "sync" "sync/atomic" "time" @@ -1082,6 +1083,16 @@ func (ss *ServerSession) callProgressNotificationHandler(ctx context.Context, p return nil, nil } +// Notify sends a notification with an arbitrary custom method name. +// method MUST start with "notifications/". Returns when the peer has +// acknowledged the write or the context is cancelled. +func (ss *ServerSession) Notify(ctx context.Context, method string, params any) error { + if !strings.HasPrefix(method, "notifications/") { + return fmt.Errorf("Notify: method must start with notifications/, got %q", method) + } + return ss.getConn().Notify(ctx, method, params) +} + // NotifyProgress sends a progress notification from the server to the client // associated with this session. // This is typically used to report on the status of a long-running request