mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
fix(mcp): build no throwaway dicts in catalog header resolution
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
b4ae8989f2
commit
68d61cc970
2 changed files with 13 additions and 7 deletions
|
|
@ -1438,8 +1438,14 @@ def _raise_single_server_list_failure(error: Exception, server: MCPServer) -> No
|
|||
case MCPUpstreamAuthError() | MCPServerListError():
|
||||
raise error
|
||||
case HTTPException() if error.status_code in (401, 403):
|
||||
headers: Final = error.headers or {}
|
||||
challenge_header: Final = headers.get("WWW-Authenticate") or headers.get("www-authenticate")
|
||||
challenge_header: Final = next(
|
||||
(
|
||||
value
|
||||
for name, value in (error.headers.items() if error.headers else ())
|
||||
if name.lower() == "www-authenticate"
|
||||
),
|
||||
None,
|
||||
)
|
||||
raise MCPUpstreamAuthError(
|
||||
status_code=error.status_code,
|
||||
www_authenticate=None if server.is_dcr_bridge else challenge_header,
|
||||
|
|
@ -4527,10 +4533,10 @@ class MCPServerManager:
|
|||
)
|
||||
|
||||
has_static_authorization: Final = any(
|
||||
isinstance(k, str) and k.lower() == "authorization" for k in (server.static_headers or {})
|
||||
isinstance(k, str) and k.lower() == "authorization" for k in (server.static_headers or ())
|
||||
)
|
||||
has_extra_authorization: Final = any(
|
||||
isinstance(k, str) and k.lower() == "authorization" for k in (extra_headers or {})
|
||||
isinstance(k, str) and k.lower() == "authorization" for k in (extra_headers or ())
|
||||
)
|
||||
if get_mcp_jwt_signer() is None or has_static_authorization or mcp_auth_header or has_extra_authorization:
|
||||
return _ListHeaders(headers, signed_for_user=False)
|
||||
|
|
@ -4540,7 +4546,7 @@ class MCPServerManager:
|
|||
raw_headers=raw_headers,
|
||||
for_list_tools=True,
|
||||
)
|
||||
unsigned_items: Final = frozenset((headers or {}).items())
|
||||
unsigned_items: Final = frozenset(headers.items() if headers else ())
|
||||
return _ListHeaders(
|
||||
signed,
|
||||
signed_for_user=True,
|
||||
|
|
|
|||
|
|
@ -1150,7 +1150,7 @@ if MCP_AVAILABLE:
|
|||
},
|
||||
)
|
||||
|
||||
@router.get("/prompts/list", dependencies=[Depends(user_api_key_auth)])
|
||||
@router.get("/prompts/list", dependencies=(Depends(user_api_key_auth),))
|
||||
async def list_prompts_rest_api(
|
||||
request: Request,
|
||||
server_id: Annotated[str, Query(description="The MCP server id, name, or alias to list prompts for")],
|
||||
|
|
@ -1176,7 +1176,7 @@ if MCP_AVAILABLE:
|
|||
raise _catalog_list_http_exception(e, context.server, "prompts") from e
|
||||
return ListMCPPromptsRestAPIResponse.from_prompts(prompts)
|
||||
|
||||
@router.get("/resources/list", dependencies=[Depends(user_api_key_auth)])
|
||||
@router.get("/resources/list", dependencies=(Depends(user_api_key_auth),))
|
||||
async def list_resources_rest_api(
|
||||
request: Request,
|
||||
server_id: Annotated[str, Query(description="The MCP server id, name, or alias to list resources for")],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue