Skip to content

feat(mcp): add ServerSession.Notify for custom notification methods#898

Open
andylbrummer wants to merge 1 commit intomodelcontextprotocol:mainfrom
standardbeagle:agnt-notify
Open

feat(mcp): add ServerSession.Notify for custom notification methods#898
andylbrummer wants to merge 1 commit intomodelcontextprotocol:mainfrom
standardbeagle:agnt-notify

Conversation

@andylbrummer
Copy link
Copy Markdown

Summary

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.

Motivation

The Go MCP SDK only exposes typed notification helpers (NotifyProgress,
SetLoggingLevel, etc.) for built-in MCP notification types. Protocol
extensions (e.g. Claude's channel mode) need to send notifications with
custom method names that aren't part of the core MCP spec. Currently
there's no public API to do this — handleNotify, getConn().Notify,
and the sending method handler are all unexported.

Changes

  • Add (*ServerSession).Notify(ctx context.Context, method string, params any) error
  • Validates method name starts with notifications/ prefix
  • Delegates to getConn().Notify() which is the same path used by
    NotifyProgress and other built-in notification senders

Testing

The fork is used in production by agnt
with an end-to-end test that:

  1. Creates an in-memory MCP client-server pair
  2. Server sends notifications/claude/channel with structured params
  3. Client reads the raw jsonrpc notification and asserts method + params match

Alternatives Considered

  • Middleware-only approach: Client-side middleware can intercept
    custom notifications, but there's no way for the server to send them
    without this method.
  • Raw jsonrpc2 access: Exposing the internal connection would break
    the abstraction boundary. A simple public method is cleaner.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@jba
Copy link
Copy Markdown
Contributor

jba commented Apr 15, 2026

Please look at #745 and make sure you're solving the problem there. Also refer to that issue in the commit message.

@jba
Copy link
Copy Markdown
Contributor

jba commented Apr 15, 2026

(No, you're not.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants