mcp: Implement retry on advised supportedVersions in UnsupportedProtocolVersion error (#989)

## Description

This PR introduces a retry mechanism for the discover method according
to SEP-2575 (Issue #966)
This commit is contained in:
Guglielmo Colombo 2026-06-08 15:09:07 +02:00 • committed by GitHub
commit d9714c61f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -64,6 +64,17 @@ func negotiatedVersion(clientVersion string) string {
return clientVersion
}
// negotiateMutuallySupportedVersion returns a protocol version that is supported
// by both the client and the server.
func negotiateMutuallySupportedVersion(supported []string) string {
for _, ver := range supportedProtocolVersions {
if slices.Contains(supported, ver) {
return ver
}
}
return ""
}
// A MethodHandler handles MCP messages.
// For methods, exactly one of the return values must be nil.
// For notifications, both must be nil.