Use Case
I am implementing an MCP Server for the Gemini CLI IDE Integration. The specification requires the server to send custom notifications to the client to signal specific events.
Specifically, I need to send:
ide/diffAccepted
ide/diffRejected
ide/contextUpdate
The Problem
Currently, the mcp.ServerSession struct only exposes specific notification helpers (like NotifyProgress and Log). There is no public API to send a generic/custom JSON-RPC notification.
I attempted to use session.Notify(ctx, method, params), but:
- The
conn field on ServerSession is unexported.
- The
mcp.Connection interface's Write method requires *mcp.JSONRPCMessage, which is an unexported struct.
Proposed Solution
Please expose a generic notification method on ServerSession, similar to:
// In mcp/server.go
func (s *ServerSession) SendNotification(ctx context.Context, method string, params any) error {
return s.conn.Notify(ctx, method, params)
}
Current Workaround
I am currently forced to use unsafe and reflect to access the underlying conn field to call its Notify method, which is fragile for obvious reasons.
Use Case
I am implementing an MCP Server for the Gemini CLI IDE Integration. The specification requires the server to send custom notifications to the client to signal specific events.
Specifically, I need to send:
ide/diffAcceptedide/diffRejectedide/contextUpdateThe Problem
Currently, the
mcp.ServerSessionstruct only exposes specific notification helpers (likeNotifyProgressandLog). There is no public API to send a generic/custom JSON-RPC notification.I attempted to use
session.Notify(ctx, method, params), but:connfield onServerSessionis unexported.mcp.Connectioninterface'sWritemethod requires*mcp.JSONRPCMessage, which is an unexported struct.Proposed Solution
Please expose a generic notification method on
ServerSession, similar to:Current Workaround
I am currently forced to use
unsafeandreflectto access the underlyingconnfield to call itsNotifymethod, which is fragile for obvious reasons.