Commit 3a7aacd
committed
feat(client): honor SEP-2549 cacheHints (ttlMs/scope) on cacheable list*/readResource
The four list verbs and readResource now serve a still-fresh ResponseCacheStore
entry without a round trip when the server-stamped ttlMs has not elapsed.
Additive on the substrate (#2336): _listAllPages now stamps {expiresAt, scope}
on the aggregate write; a _serveFromCache front gates each verb on freshness;
readResource is newly cached (URI-keyed; only stored when ttl > 0, since the
URI keyspace is unbounded and there is no derived index).
Per-call CacheableRequestOptions.cacheMode ('use' | 'refresh' | 'bypass') maps
to mcp.d's CacheMode. ClientOptions.cachePartition is the per-principal slot
for 'private'-scoped entries (the spec's MUST-NOT-share-across-authz-contexts);
'public' entries always live at partition '' so a shared store serves them to
every co-tenant. ClientResponseCache reads probe own-partition then '' (mcp.d's
two-probe order — own-first because scope is only known after a fetch); the
toolDefinition/outputValidator derived indices use the same probe so SEP-2243
mirroring works under partitioning. readResource applies the same partition
derivation as the list verbs and treats absent cacheScope as 'private', so a
shared store cannot serve one principal's resource body to another.
ClientOptions.defaultCacheTtlMs (default 0) supplies the TTL when the result
lacks one (e.g. a legacy-era response); an explicit server-sent ttlMs:0 is
honoured as immediately stale. List aggregates are always stored regardless of
TTL (mcp.d's retainForSchema posture) so callTool's mirroring/output-validation
index keeps working at any TTL while the freshness gate never serves a stale
entry. A list_changed eviction beats TTL (the existing partition-agnostic
evict). Clock seam (now) injectable on ClientResponseCache for tests.
New exports: CacheMode, CacheableRequestOptions.1 parent 5f18fcd commit 3a7aacd
10 files changed
Lines changed: 1432 additions & 151 deletions
File tree
- .changeset
- docs
- packages
- client
- src
- client
- test/client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| 575 | + | |
| 576 | + | |
575 | 577 | | |
576 | 578 | | |
577 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
578 | 597 | | |
579 | 598 | | |
580 | 599 | | |
| |||
0 commit comments