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:
parent
5045d86fb4
commit
d9714c61f1
1 changed files with 172 additions and 34 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue