mcp: add Cacheable fields to DiscoverResult (#1022)

This PR add the Cacheable fields to the DiscoverResult, as it was added
later
(8e4c2322ca)
This commit is contained in:
Guglielmo Colombo 2026-06-24 14:08:43 +02:00 • committed by GitHub
commit a817f61412
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 19 deletions

View file

@ -1129,6 +1129,7 @@ func (x *DiscoverParams) SetProgressToken(t any) { setProgressToken(x, t) }
type DiscoverResult struct {
Meta `json:"_meta,omitempty"`
Cacheable
// The versions of the Model Context Protocol that the server supports.
SupportedVersions []string `json:"supportedVersions"`
// The server's capabilities.

View file

@ -869,12 +869,14 @@ func (s *Server) discover(_ context.Context, req *ServerRequest[*DiscoverParams]
ClientInfo: req.ClientInfo(),
}
})
return &DiscoverResult{
res := &DiscoverResult{
SupportedVersions: versions,
Capabilities: s.capabilities(),
ServerInfo: s.impl,
Instructions: s.opts.Instructions,
}, nil
}
res.setDefaultCacheableValues()
return res, nil
}
// filterSupportedVersions returns the subset of [supportedProtocolVersions]

View file

@ -21,6 +21,8 @@ supports, its capabilities, and its identity.
"jsonrpc": "2.0",
"id": 1,
"result": {
"ttlMs": 0,
"cacheScope": "public",
"supportedVersions": [
"2026-07-28",
"2025-11-25",

View file

@ -42,7 +42,7 @@ func ExampleLoggingTransport() {
}
// Output:
// read: {"jsonrpc":"2.0","id":1,"result":{"supportedVersions":["2026-07-28","2025-11-25","2025-06-18","2025-03-26","2024-11-05"],"capabilities":{"logging":{}},"serverInfo":{"name":"server","version":"v0.0.1"}}}
// read: {"jsonrpc":"2.0","id":1,"result":{"ttlMs":0,"cacheScope":"public","supportedVersions":["2026-07-28","2025-11-25","2025-06-18","2025-03-26","2024-11-05"],"capabilities":{"logging":{}},"serverInfo":{"name":"server","version":"v0.0.1"}}}
// write: {"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/clientCapabilities":{"roots":{"listChanged":true}},"io.modelcontextprotocol/clientInfo":{"name":"client","version":"v0.0.1"},"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}}
}