mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(mcp): keep BYOK fallback when per-server dict omits Authorization
Greptile P2: when mcp_server_auth_headers carries only non-Authorization per-server headers, still apply the BYOK mcp_auth_header so an operator-configured credential is not silently dropped.
This commit is contained in:
parent
80dd2b47a5
commit
f5bcd08ee5
2 changed files with 13 additions and 0 deletions
|
|
@ -379,6 +379,8 @@ def _resolve_openapi_tool_auth(
|
|||
auth_value = header_val
|
||||
else:
|
||||
extra[header_key] = header_val
|
||||
if auth_value is None and mcp_auth_header:
|
||||
auth_value = _format_byok_openapi_auth_header(mcp_server, mcp_auth_header)
|
||||
return auth_value, (extra or None)
|
||||
if isinstance(per_server_auth_header, str) and per_server_auth_header:
|
||||
return per_server_auth_header, forwarded
|
||||
|
|
|
|||
|
|
@ -7685,6 +7685,17 @@ class TestResolveOpenAPIToolAuth:
|
|||
)
|
||||
assert auth_value == "ApiKey byok-raw-token"
|
||||
|
||||
def test_per_server_non_auth_only_falls_back_to_byok_auth_header(self):
|
||||
auth_value, forwarded = _resolve_openapi_tool_auth(
|
||||
mcp_server=self._server(),
|
||||
mcp_auth_header="byok-raw-token",
|
||||
mcp_server_auth_headers={"report_openapi": {"X-Tenant-Id": "acme"}},
|
||||
raw_headers=None,
|
||||
user_api_key_auth=None,
|
||||
)
|
||||
assert auth_value == "Bearer byok-raw-token"
|
||||
assert forwarded == {"X-Tenant-Id": "acme"}
|
||||
|
||||
def test_no_credential_returns_none(self):
|
||||
auth_value, forwarded = _resolve_openapi_tool_auth(
|
||||
mcp_server=self._server(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue