fix(mcp): do not respond to JSON-RPC notifications
The supervisor's MCP HTTP handler was answering every parsed request, including notifications (messages with no id field). Per JSON-RPC 2.0, notifications must not receive a response. The Apr-29 incident saw Claude Code's MCP client receive a -32601 error for the standard notifications/initialized handshake step and disconnect immediately after a successful initialize. Skip writing the response when req.ID == nil. Cover both the known-method (notifications/initialized) and unknown-method paths with tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,11 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// JSON-RPC 2.0 notifications (no id) must not receive a response.
|
||||
if req.ID == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var result any
|
||||
var rpcErr *rpcError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user