Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com> Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1.8 KiB
| @modelcontextprotocol/client |
|---|
| minor |
Client now honours the server-stamped SEP-2549 ttlMs/cacheScope cache hints on the cacheable verbs (listTools(), listPrompts(), listResources(), listResourceTemplates(), readResource()): a still-fresh held entry is served without a round trip. New CacheableRequestOptions.cacheMode ('use' — the default; 'refresh' — always fetch and re-store; 'bypass' — fetch without consulting or writing the cache) gives per-call control. The behaviour is opt-in by hint: a server that sends ttlMs: 0 (the conservative default this SDK's server stamps) sees byte-identical behaviour — every call fetches.
Entries are automatically scoped by connected-server identity (derived from serverInfo after connect, encoded collision-free via JSON.stringify); ClientOptions.cachePartition is the opaque per-principal slot for 'private'-scoped entries — set it to your principal identifier (e.g. the auth subject) when one responseCacheStore backs several principals. With the default '' every entry lives at the connected server's shared partition (the safe single-tenant posture). ClientOptions.defaultCacheTtlMs (default 0) supplies the TTL when a result lacks one (e.g. a legacy-era response); the server-supplied ttlMs is clamped at 24 h (MAX_CACHE_TTL_MS). The list verbs always store the aggregate (so callTool's mirroring/output-validation index keeps working at any TTL); readResource stores only when the resolved TTL is positive. notifications/resources/updated evicts the cached resources/read body for that URI. ResponseCacheStore gained delete(key); InMemoryResponseCacheStore is now bounded ({ maxEntries }, default 512, oldest-first eviction). New exports: CacheMode, CacheableRequestOptions, InMemoryResponseCacheStoreOptions, MAX_CACHE_TTL_MS.