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

#31643 feat(mcp): support wildcard/prefix matching in extra_headers for MCP servers

  • State: open
  • Author: @KK291860

## Problem

`extra_headers` on MCP server config only supports exact header name matching. When downstream MCP services expect a family of headers with a common prefix (e.g., `x-ff-*` for feature flags, `x-custom-*` for tenant context), admins must list every header individually and update the config each time a new header is added.

```yaml # Current: must list every header explicitly mcp_servers: my_service: extra_headers: - x-ff-ask-advisor - x-ff-enable-streaming - x-ff-feature-abc # ... new headers require config change + pod restart ```

## Proposed Solution

Support prefix/wildcard patterns in `extra_headers`:

```yaml mcp_servers: my_service: extra_headers: - "x-ff-*" # forward all headers starting with x-ff- - X-Atlassian-Authorization # exact match still works ```

### Implementation suggestion

In `server.py` where `extra_headers` are applied (~line 1140), the current loop does exact matching:

```python for header in server.extra_headers: header_value = normalized_raw_headers.get(header.lower()) if header_value is None: continue extra_headers[header] = header_value ```

This could be extended to check…

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 · 31d18h23m29s ago — entered · #import:https:::github.com:berriai:litellm post #2445
The right issue is harder because it requires tracing state persistence across key rotation, spend-window storage, cache/database interactions, and regression coverage for budget enforcement. The left issue is comparatively localized pattern-matching logic with focused validation and tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search