Repository navigation
Closed
Labels
enhancementNew feature or requestgoPull requests that update go codevmcpVirtual MCP Server related issues
Description
Summary
Create a mutable DynamicRegistry implementation that supports thread-safe backend updates with version-based cache invalidation for the discovery manager.
Background
Part of the vMCP K8s-aware refactor (THV-2884). The current immutableRegistry discovers backends once at startup and never changes. For dynamic discovery mode, we need a mutable registry that supports real-time updates when backends change in K8s.
Proposed Design
Interface
type DynamicRegistry interface {
BackendRegistry // Embed existing interface (Get, List, Count)
// Upsert adds or updates a backend atomically.
// Idempotent - calling with the same backend multiple times is safe.
// Increments Version() on every call.
Upsert(backend *Backend) error
// Remove deletes a backend by ID.
// Idempotent - removing non-existent backends returns nil.
// Increments Version() on every call.
Remove(backendID string) error
// Version returns the current registry version.
// Increments on every mutation (Upsert/Remove).
// Used for cache invalidation in discovery manager.
Version() uint64
}Implementation
type dynamicRegistry struct {
mu sync.RWMutex
backends map[string]*Backend
version uint64
}Cache Invalidation
The discovery manager maintains per-user cache entries tagged with the registry version:
type cacheEntry struct {
capabilities *AggregatedCapabilities
expiresAt time.Time
registryVersion uint64 // Version when this entry was computed
}Cache hit is valid only if not expired AND registryVersion == currentVersion. This provides lazy invalidation without thundering herd problems.
Files to Modify
pkg/vmcp/registry.go- AddDynamicRegistryinterface anddynamicRegistryimplementationpkg/vmcp/discovery/manager.go- AddregistryVersionfield to cache entries and version check on lookup
Acceptance Criteria
-
DynamicRegistryinterface extendingBackendRegistry -
Upsert(backend *Backend) error- idempotent add/update -
Remove(backendID string) error- idempotent delete -
Version() uint64- monotonic counter, increments on mutation - Thread-safe with RWMutex
- Cache entries tagged with
registryVersion - Stale entries (version mismatch) trigger recomputation
- Lazy invalidation (no thundering herd)
- Unit tests for all operations
Notes
- No event callbacks needed - reconciler pattern handles "what changed" logic
- In static mode, the existing
immutableRegistrycontinues to be used
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestgoPull requests that update go codevmcpVirtual MCP Server related issues
Activity
slyt3 commentedon Dec 16, 2025
Hey. I’d like to take this issue if it’s still available. The design looks clear and I’m comfortable working on it.
Please let me know if I can get assigned.
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation
Add DynamicRegistry with version-based cache invalidation (#3188)