You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR allows us to use in-memory caching which is the default behavior in fastMCP by removing the hard requirement of having an external Redis store.
Also, added more info in the config section so it's clear how caching and the store work
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
Has associated issue:
Required feature flags:
Changes UI
Includes DB Migration (follow approval process in SIP-59)
Migration is atomic, supports rollback & is backwards-compatible
Confirm DB migration upgrade and downgrade tested
Runtime estimates and downtime expectations provided
Introduces new feature or API
Removes existing feature or API
CodeAnt-AI Description
Use in-memory cache by default when no external store is configured
What Changed
When caching is enabled but no external store is configured, MCP now uses FastMCP's built-in in-memory cache instead of requiring Redis.
If the optional store config is enabled, caching will use Redis and requires a cache key prefix; if the prefix is missing the code logs a warning and falls back to in-memory caching.
Configuration documentation updated to show three clear scenarios: caching disabled, caching with in-memory store (default), and caching with Redis store; unit tests updated to cover the new fallback behaviors.
Impact
✅ Fewer runtime failures when Redis is not configured ✅ Clearer cache configuration for in-memory vs Redis scenarios ✅ Consistent caching behavior when external store is optional
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Missing cache prefix enforcement If consumers enable MCP_STORE_CONFIG (Redis) but leave MCP_CACHE_CONFIG["CACHE_KEY_PREFIX"] as None, different features using the same Redis instance can conflict. The config currently allows a None prefix which risks key collisions or unexpected shared state. The code that creates/uses the store should validate or derive a safe default prefix when the store is enabled.
Store enabled without Redis URL The new config permits enabling the shared store via MCP_STORE_CONFIG["enabled"]. If a user enables the store but does not set "CACHE_REDIS_URL", the runtime code that instantiates a Redis client may fail. There should be a validation/warning and a clear fallback (e.g., refuse to enable or fall back to in-memory).
Possible AttributeError The code reads nested config objects via variables like store_config = flask_app.config.get("MCP_STORE_CONFIG", {})
and later calls store_config.get("enabled", False). If the config key exists but its value is None
this will assign None to store_config and the subsequent .get call will raise an AttributeError.
Consider defensive handling for config values that are present but falsy/None.
Wrapper type import risk The WRAPPER_TYPE string points to an import path for a wrapper class. If that path is incorrect or the package is not installed, runtime import will fail. Ensure code that uses WRAPPER_TYPE attempts to import it with a clear error message and fallbacks.
Missing settings assertions The new tests assert that middleware is created and that cache_storage is None when falling back to in-memory store, but they do not assert that the per-operation settings (e.g., list_tools_settings) are passed through to the middleware. This leaves a gap where caching settings might be ignored while tests still pass.
App context path untested All new tests patch flask.has_app_context to return True. The branch where no app context exists (so the code pushes one via flask_app.app_context()) is not exercised by these new tests. The context-push path could behave differently and should be covered.
Brittle config mocking The tests configure mock_flask_app.config.get with a side_effect that looks up keys in mock_configs.
This is fine, but it relies on the signature get(key, default=None) and returning default when key missing. If production code ever uses different keys or extra calls (e.g., without default), the tests may behave differently than a real Flask config dict. Consider using a dict-like object or setting mock_flask_app.config to a real dict to more closely mimic Flask behavior.
❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.77%. Comparing base (1bde06b) to head (b5182d4). ⚠️ Report is 2 commits behind head on master.
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
infra:cachingInfra setup and configuration related to cachingsize/Lsize:LThis PR changes 100-499 lines, ignoring generated files
2 participants
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.
User description
SUMMARY
This PR allows us to use in-memory caching which is the default behavior in fastMCP by removing the hard requirement of having an external Redis store.
Also, added more info in the config section so it's clear how caching and the store work
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CodeAnt-AI Description
Use in-memory cache by default when no external store is configured
What Changed
Impact
✅ Fewer runtime failures when Redis is not configured✅ Clearer cache configuration for in-memory vs Redis scenarios✅ Consistent caching behavior when external store is optional💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.