mcp: reject calls to methodDiscover for <20260728 requests (#1084)

This PR adds a gate for requests towards methodDiscover if it is coming
from a client that does not support the 20260728 protocol version
This commit is contained in:
Guglielmo Colombo 2026-07-14 12:13:40 +02:00 • committed by GitHub
commit 7fde7d3452
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1883,6 +1883,12 @@ func (ss *ServerSession) handle(ctx context.Context, req *jsonrpc.Request) (any,
// In case of methodDiscover call the state.initializeParams is populated
// within the discover handle function to make sure the method is supported
// when the user is probing a pre-2026-07-28 server.
if !validatedMeta.usesNewProtocol {
return nil, &jsonrpc.Error{
Code: jsonrpc.CodeMethodNotFound,
Message: fmt.Sprintf("%q is only supported in protocol version >= %s", req.Method, protocolVersion20260728),
}
}
default:
if !initialized && !validatedMeta.usesNewProtocol {
ss.server.opts.Logger.Error("method invalid during initialization", "method", req.Method)