mcp: allow per request Cacheable customization (#1203)

Fixes #1094
This commit is contained in:
Guglielmo Colombo 2026-09-01 20:57:51 +02:00 • committed by GitHub
commit 0d3036f785
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1191,9 +1191,16 @@ func (c Cacheable) GetTTLMs() int { return c.TTLMs }
// GetCacheScope returns the cache scope.
func (c Cacheable) GetCacheScope() string { return c.CacheScope }
// setDefaultCacheableValues sets the default values for the cacheable fields.
func (c *Cacheable) setDefaultCacheableValues() {
c.CacheScope = "public"
// normalize fills in the protocol default for any cache field left
// unset. An absent cacheScope means "public", but the field is required on the
// wire, so the default is materialized here rather than sent empty.
//
// Values already present are preserved: this must not undo a decision made by
// a resource handler or by [ServerOptions.SetCacheable].
func (c *Cacheable) normalize() {
if c.CacheScope == "" {
c.CacheScope = "public"
}
}
// The server's response to a prompts/list request from the client.