Skip to content

fix(virtual-mcp): invalidate the request-cached project list on metadata writes - #7966

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/virtual-mcp-cache-invalidate-patch-w3
Oct 16, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/virtual-mcp-cache-invalidate-patch-w3

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Bug found reading apps/api/src/storage/virtual.ts (virtual storage cleanup focus area).

createRequestCachedVirtualMcps memoizes VirtualMCPStorage.list() for the lifetime of one request, clearing the memo cache on create/update/delete/removeConnectionReferences. It missed two other methods that also mutate the connections row: patchMetadata and clearAnalyticsSiteSlugReferences.

This is reachable today: PROJECT_FOLDER_ENSURE (apps/api/src/tools/virtual/project-folder-ensure.ts) calls ctx.storage.virtualMcps.list(organizationId) (populating the cache) and then, later in the same request, ctx.storage.virtualMcps.patchMetadata(...) to persist projectFolderName — without busting the cache. Any further list() call in that same request (e.g. another tool invoked in the same batched MCP call) would replay the pre-patch snapshot instead of the just-written metadata. admin.ts's clearAnalyticsSiteSlugReferences call has the identical gap.

Fix: add both methods to the proxy's cache-clearing branch, same as the existing writers.

Verification: added apps/api/src/storage/virtual.test.ts cases that stub a minimal VirtualMCPStorage and assert list() returns a fresh (non-identical) result after patchMetadata() or clearAnalyticsSiteSlugReferences() — previously these would have failed since both calls were no-ops for the cache. Reviewer can run bun test apps/api/src/storage/virtual.test.ts.

Locally ran: bun run fmt, cd apps/api && bunx tsc --noEmit, bun test apps/api/src/storage/virtual.test.ts, bunx oxlint apps/api/src/storage/virtual.ts apps/api/src/storage/virtual.test.ts — all clean. Full CI validates the rest.

🤖 Generated with Claude Code


Summary by cubic

Fixes the request-cached virtual MCP project list so it no longer serves stale data after metadata writes.

createRequestCachedVirtualMcps memoizes list() per request and cleared its cache on create/update/delete/removeConnectionReferences, but not on patchMetadata or clearAnalyticsSiteSlugReferences. Both mutate the same connections row, so a list() call later in the same request could replay the pre-write snapshot. PROJECT_FOLDER_ENSURE hits this today by calling list() then patchMetadata() in one request.

  • Adds patchMetadata and clearAnalyticsSiteSlugReferences to the cache-clearing branch.
  • Adds tests asserting list() returns a fresh result after each of these writes.

Written for commit 5a9108a. Summary will update on new commits.

View guided diff Turn on auto-fix

…ata writes

createRequestCachedVirtualMcps memoizes list() per request but only cleared
the cache on create/update/delete/removeConnectionReferences. patchMetadata
and clearAnalyticsSiteSlugReferences also mutate the connections row (e.g.
PROJECT_FOLDER_ENSURE calls list() then patchMetadata() in the same
request) without busting the cache, so a later list() in that request
could replay stale data.
@github-actions github-actions Bot added the claude PR authored by a coding agent label Oct 15, 2026
@pedrofrxncx
pedrofrxncx merged commit a80849b into main Oct 16, 2026
34 of 36 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/virtual-mcp-cache-invalidate-patch-w3 branch October 16, 2026 19:51
decocms Bot pushed a commit that referenced this pull request Oct 16, 2026
PR: #7966 fix(virtual-mcp): invalidate the request-cached project list on metadata writes
Bump type: patch

- decocms (apps/api/package.json): 4.498.1 -> 4.498.2

Deploy-Scope: server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant