8 views
-/https://github.com/berriai/litellm/issues/30560
GitHub · issue

#30560 OpenAPI-backed MCP server returns 401 when the spec URL is protected by the configured auth

  • State: open
  • Author: @Naroh091

When adding an MCP server from an OpenAPI specification and selecting Bearer Token authentication, the dashboard returns a 401 even with a valid token. The same spec URL loads correctly in Postman when the Authorization header is sent, which points at LiteLLM rather than the upstream API.

The root cause is that LiteLLM downloads the OpenAPI document (`spec_path`) without forwarding the configured credential. `load_openapi_spec_async` issues a plain GET with no Authorization header, both in the dashboard tools preview (`/v1/mcp/server/test/tools/list`) and in the server registration path in `mcp_server_manager._register_openapi_tools`. When the spec URL is hosted behind the same credential as its endpoints, which is the common case, the upstream replies 401 and the server can never be added.

This is separate from the request-time `extra_headers` forwarding addressed in #27383 and #26864; that work only covers headers sent while executing a tool, not the spec fetch itself, so the spec download was still going out unauthenticated.

To reproduce, serve an OpenAPI spec behind a Bearer token, then in the dashboard add a new MCP server from that spec URL, choose Bearer Token, and paste …

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (3 events)
#0 of 0 · 31d18h29m40s ago — entered · #import:https:::github.com:berriai:litellm post #2384
The left issue requires tracing authentication through multiple asynchronous code paths, preserving existing behavior, and adding integration/regression coverage for dashboard and registration flows. The right issue is a contained metadata update with limited implementation risk.
The security fix is harder because it affects privileged authentication control flow, distributed cache invalidation consistency, multi-worker behavior, and requires careful regression and security testing. The MCP change is comparatively localized to authenticated OpenAPI spec retrieval and its call sites.
#0 of 0 · 31d17h43m39s ago — current · #import:https:::github.com:berriai:litellm post #3156
The right issue is harder because it requires consistent credential propagation across multiple MCP/OpenAPI code paths, careful security handling, and regression tests; the left issue has insufficient detail but appears narrower in scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search