mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
fix(mcp): reuse proxy_logging DualCache in inject_mcp_jwt_headers_for_upstream
Instead of allocating a fresh DualCache() on every tools/list invocation, prefer the shared proxy_logging_obj.internal_usage_cache.dual_cache when available. The cache argument is currently unused by MCPJWTSigner, but sharing the proxy's cache avoids per-call allocation overhead and matches the cache identity used elsewhere in the proxy hook plumbing — so any future per-request state stored in cache will survive across list calls. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4653773376
commit
ed10815152
1 changed files with 14 additions and 1 deletions
|
|
@ -945,9 +945,22 @@ async def inject_mcp_jwt_headers_for_upstream(
|
|||
call_type: CallTypesLiteral = (
|
||||
"list_mcp_tools" if for_list_tools else "call_mcp_tool"
|
||||
)
|
||||
try:
|
||||
from litellm.proxy.proxy_server import ( # noqa: PLC0415
|
||||
proxy_logging_obj as _proxy_logging,
|
||||
)
|
||||
|
||||
shared_cache = (
|
||||
_proxy_logging.internal_usage_cache.dual_cache
|
||||
if _proxy_logging is not None
|
||||
else DualCache()
|
||||
)
|
||||
except Exception:
|
||||
shared_cache = DualCache()
|
||||
|
||||
result = await signer.async_pre_call_hook(
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
cache=DualCache(),
|
||||
cache=shared_cache,
|
||||
data=hook_data,
|
||||
call_type=call_type,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue