-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: remove caching of MCP metadata in MultiServerMCPClient #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes the caching mechanism for MCP (Model Configuration Protocol) metadata, transitioning to a strategy where tool metadata is fetched fresh from the MCP server on every request. The refactoring removes the McpToolsMetadataExpiringCache class entirely and updates all dependent components to eliminate cache-related logic.
- Deleted the entire
mcp_tools_expiring_cache.pyfile containing the caching implementation - Updated
MultiServerMCPClientWithCachingto always load fresh metadata instead of using cached data - Removed cache dependencies from
MCPToolProviderand the dependency injection container - Simplified the
get_toolsmethod to directly load and convert tools without cache management
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
language_model_gateway/gateway/utilities/cache/mcp_tools_expiring_cache.py |
Complete removal of the MCP tools metadata caching implementation |
language_model_gateway/gateway/tools/mcp_tool_provider.py |
Removed cache parameter from constructor and updated initialization logic |
language_model_gateway/gateway/langchain_overrides/multiserver_mcp_client_with_caching.py |
Refactored to always fetch fresh metadata; removed all caching logic from get_tools and related methods |
language_model_gateway/container/container_factory.py |
Removed singleton registration for McpToolsMetadataExpiringCache and removed cache injection into MCPToolProvider |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
language_model_gateway/gateway/langchain_overrides/multiserver_mcp_client_with_caching.py
Outdated
Show resolved
Hide resolved
| *, | ||
| tools: list[Tool], | ||
| session: ClientSession | None = None, | ||
| session: ClientSession | None, |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the default value (= None) from the session parameter changes the method signature. While this doesn't break existing code (since all current callers explicitly pass session=None), it does change the API by requiring callers to explicitly provide a value for session instead of being able to omit it. Consider whether this is intentional or if the default value should be preserved for backward compatibility.
| session: ClientSession | None, | |
| session: ClientSession | None = None, |
This PR removes the caching mechanism for MCP (Model Configuration Protocol) metadata, transitioning to a strategy where tool metadata is fetched fresh from the MCP server on every request. The refactoring removes the McpToolsMetadataExpiringCache class entirely and updates all dependent components to eliminate cache-related logic.
Deleted the entire mcp_tools_expiring_cache.py file containing the caching implementation
Updated MultiServerMCPClientWithCaching to always load fresh metadata instead of using cached data
Removed cache dependencies from MCPToolProvider and the dependency injection container
Simplified the get_tools method to directly load and convert tools without cache management