Skip to content

Add Server.ResyncTools for embedder resync - #7072

Draft
reyortiz3 wants to merge 1 commit into
mainfrom
vmcp-resync-session-tools
Draft

reyortiz3 wants to merge 1 commit into
mainfrom
vmcp-resync-session-tools

Conversation

@reyortiz3

Copy link
Copy Markdown
Collaborator

Summary

An embedder that wraps the vMCP core with a per-identity view has a change that nothing reports. For example, a user loses the credential for one backend and that user's tool list should change, while the backend and its health do not. Neither a backend notifications/tools/list_changed nor a backend health change fires, so an already-connected client keeps the tool list it got at registration until it reconnects.

Server already re-derives a live session's tools (runListChangedResync) and replaces its tool store, and the SDK then sends notifications/tools/list_changed downstream. Only two things trigger it today, and both entry points are unexported. This adds an exported trigger for the embedder.

  • Add Server.ResyncTools(match func(*auth.Identity) bool) int. It schedules the registered sessions' tools resync workers for the sessions whose registration-time identity satisfies match (nil selects all), and returns how many it scheduled.
  • Record the registration-time identity on listChangedResyncWorker, which already closes over it, so the registry signature and its callers stay unchanged.
  • Purge the capability cache once per call, like the health fan-out, and purge nothing when match selects no session. Per-session coalescing is unchanged.
  • No-op in optimizer mode, like the health fan-out, because the advertised meta-tools do not change.

Type of change

  • New feature

Test plan

  • go test -race ./pkg/vmcp/server/ (whole package, including the existing resync and list_changed tests)
  • golangci-lint run ./pkg/vmcp/server/... reports 0 issues
  • task test (the full repo) was not run

New tests in serve_session_resync_test.go cover: only matching sessions are resynced, a nil match selects all, an anonymous session reaches match as nil, no match does nothing and does not purge, and optimizer mode does nothing. Removing the match filter makes the first and fourth fail.

Does this introduce a user-facing change?

A new exported method on Server. Existing behavior is unchanged.

Special notes for reviewers

  • Reach: the method reaches only sessions that the registry already holds, which is passthrough mode with backend health monitoring enabled. That gate exists because, with no health monitor, nothing would ever run the registry's lazy prune. An embedder without health monitoring would get 0. Loosening the gate means giving the registry another pruning trigger; I kept this PR to the trigger. Open to doing it here if you prefer.
  • Naming: ResyncTools is deliberately not ResyncSessionTools, which would differ from the existing unexported resyncSessionTools only by case.
  • match runs on the caller's goroutine over a snapshot of the registry, outside its lock, and receives the identity the session was registered for. It must not mutate it.
  • No linked issue. Happy to open one and move the discussion there if that is the preferred flow for a new exported API.

Generated with Claude Code

An embedder that wraps the vMCP core with a per-identity view has a
change that neither a backend list_changed nor a health flip reports,
so connected clients keep the tool list they got at registration.

ResyncTools triggers the registered sessions' tools resync workers for
the sessions whose registration-time identity satisfies a match
function.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Nov 6, 2026
@reyortiz3
reyortiz3 marked this pull request as draft November 6, 2026 22:30
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.84%. Comparing base (3738fc9) to head (8fbf4ad).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7072      +/-   ##
==========================================
- Coverage   80.89%   80.84%   -0.05%     
==========================================
  Files         864      864              
  Lines       88634    88647      +13     
==========================================
- Hits        71699    71669      -30     
- Misses      16930    16973      +43     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant