Skip to content

fix(client): use public cache after private expiry - #3218

Open
1828703450qqcom-ux wants to merge 1 commit into
modelcontextprotocol:mainfrom
1828703450qqcom-ux:fix/cache-shared-fresh-fallback
Open

1828703450qqcom-ux wants to merge 1 commit into
modelcontextprotocol:mainfrom
1828703450qqcom-ux:fix/cache-shared-fresh-fallback

Conversation

@1828703450qqcom-ux

Copy link
Copy Markdown

Summary

When clients share a response cache but use different cachePartition values, one client can retain an expired private entry after another client stores a public replacement. _probe() currently returns the private entry before considering its TTL. read() then rejects that entry as stale without looking at the fresh public entry, causing an unnecessary request; tool descriptors and output validators also keep using the old private list.

Prefer the private entry while it is fresh, then use a held public entry. If the shared slot is absent or not public, retain the private entry for derived metadata as before. read() still enforces TTL, while descriptors and validators retain the selected public list when it later expires. The single-partition case still performs one store lookup.

This is a small bug fix under the contribution guide's exception for straightforward fixes with regression tests. No API or protocol change.

Validation

  • The new Client-level regression fails with unchanged production code: after private expiry, listTools() returns the private server's ['a'] through a second request rather than serving the public cached ['b'].
  • Focused response-cache suite: 56 passed. Covers the exact TTL boundary, fresh private precedence, absent/non-public shared fallback, descriptor and validator re-derivation, both-stale metadata retention, and a single-partition lookup count.
  • Full client suite: 47 files, 1,120 tests passed.
  • Client typecheck, client ESLint/Prettier, changeset formatting, and git diff --check pass.
  • Core and client package builds pass.
  • The repository's unchanged pre-push hooks pass: pnpm run typecheck:all, pnpm run lint:all, and pnpm run build:all.

On Windows, the initial cold full-client run hit the existing ensureBuilt harness problem (spawn pnpm ENOENT; see #3177). I explicitly ran corepack pnpm --filter @modelcontextprotocol/core build and corepack pnpm --filter @modelcontextprotocol/client build, then reran the full client suite successfully. The harness is unchanged in this PR.

Prepared and checked with Codex agents. The test execution and source review described here were automated; no human-review attestation is implied.

@1828703450qqcom-ux
1828703450qqcom-ux requested a review from a team as a code owner November 20, 2026 22:52
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25e0f02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/core-internal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3218

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3218

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3218

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3218

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3218

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3218

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3218

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3218

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3218

commit: 25e0f02

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant