Fixes #2018 - REST /tools list endpoint returns stale visibility data after tool update in multi-worker deployments#2020
Merged
crivetimihai merged 2 commits intomainfrom Jan 10, 2026
Conversation
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Add unit tests for CacheInvalidationSubscriber to prevent regression of the stale visibility data bug (#2018). Tests verify: - Registry cache invalidation for tools/prompts/resources - Tool lookup cache invalidation by name and gateway - Admin stats cache invalidation - Graceful handling of Redis unavailability - Concurrent invalidation message processing - Main regression scenario: tool visibility update clears caches Also updates .flake8 to ignore DAR docstring warnings for test file. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
7 tasks
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
… data after tool update in multi-worker deployments (IBM#2020) * Cache fix for token scoping Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * test: add regression tests for cross-worker cache invalidation Add unit tests for CacheInvalidationSubscriber to prevent regression of the stale visibility data bug (IBM#2018). Tests verify: - Registry cache invalidation for tools/prompts/resources - Tool lookup cache invalidation by name and gateway - Admin stats cache invalidation - Graceful handling of Redis unavailability - Concurrent invalidation message processing - Main regression scenario: tool visibility update clears caches Also updates .flake8 to ignore DAR docstring warnings for test file. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2018 - follow-up from #1915
Root Cause
Cache invalidation code existed and published messages to Redis pubsub channel
mcpgw:cache:invalidate, but no subscriber existed to listen for these messages. In multi-worker deployments (e.g., 3 gunicorn workers behind nginx), when Worker A updated a tool's visibility and invalidated its local cache, Workers B and C continued serving stale cached data.Solution
Added
CacheInvalidationSubscriberclass that:mcpgw:cache:invalidateon application startupMessage Formats Supported
registry:toolsregistry:promptsregistry:resourcesregistry:agentstool_lookup:{name}tool_lookup:gateway:{id}admin:{prefix}Changes
CacheInvalidationSubscriberclass (~220 lines)Testing
Automated Tests (14 tests)
Tests cover:
Manual Verification
Results (all passing):
Deployment Notes
Checklist
make flake8 pylint bandit)make mypy pyright)