Repository navigation
How to forward Authorization headers through IBM MCP Context Forge to upstream MCP servers? #6211
Replies: 4 comments
|
To use the general header pass-through, set the global flag on the gateway: ENABLE_HEADER_PASSTHROUGH=true (and add the header name to the server's passthrough_headers). The Authorization header itself is used by the gateway's own auth, so it is not forwarded. Instead, send the credential in X-Upstream-Authorization- the gateway renames it to Authorization when forwarding to the upstream. This one works regardless of the flag above. You may also be interested in ENABLE_OVERWRITE_BASE_HEADERS=true, which lets the client header override a static auth_headers configured on the server. |
|
@maciejstepniak thanks for answering. I make the changes that you propose and it doesn't work: services:
mcp-context-forge:
image: ghcr.io/ibm/mcp-context-forge:latest
ports:
- "4444:4444"
environment:
- MCPGATEWAY_UI_ENABLED=true
- MCPGATEWAY_ADMIN_API_ENABLED=true
- HOST=0.0.0.0
- JWT_SECRET_KEY="1PlnAWCYzkFwQI7gHkkVouh26vgajOMb"
- AUTH_ENCRYPTION_SECRET="super_auth_encryption_key"
- AUTH_REQUIRED=false
- MCP_REQUIRE_AUTH=false
- PLATFORM_ADMIN_EMAIL=admin@example.com
- PLATFORM_ADMIN_PASSWORD=password
- PLATFORM_ADMIN_FULL_NAME="Platform Administrator"
- DATABASE_URL=sqlite:///./mcp.db
- SECURE_COOKIES=false
- PLUGINS_ENABLED=true
- REDIS_URL=redis://redis:6379
- ENABLE_HEADER_PASSTHROUGH=true
- ENABLE_OVERWRITE_BASE_HEADERS=trueI've already add the Passthrough Headers from the ui |
|
The flag you are missing is probably enable_sensitive_header_passthrough: bool = Field(
default=False,
description="Enable passthrough of sensitive headers (Authorization, X-API-Key, etc.) when explicitly whitelisted. "
"Requires enable_header_passthrough=true. Default: false for security. "
"When enabled, whitelisted sensitive headers bypass router-level filtering.",
)So in your compose environment you want both: The second thing worth checking is passthrough_headers_source: Literal["env", "db", "merge"] = Field(
default="db",
description="Source priority for passthrough headers: env (environment always wins), db (database wins, default), merge (combine both)",
)Since you also configured passthrough headers through the admin UI, that stored value is what is being used and your compose setting is ignored. Set Third, and this one overrides everything above: if the target gateway has if gateway.auth_type == "basic" and header_lower == "authorization":
logger.warning(f"Skipping Authorization header passthrough due to basic auth configuration on gateway {gateway.name}")
continue
if gateway.auth_type == "bearer" and header_lower == "authorization":
logger.warning(f"Skipping Authorization header passthrough due to bearer auth configuration on gateway {gateway.name}")
continueClient The fastest way to tell which branch you are hitting is the log output. Run with debug logging and look for one of these: The second means a collision with a base header, which is what If you just want it running without changing the target auth config, I am reading |
|
Hi @muhammadbalawal, thanks for the reply! Sending the X-Upstream-Authorization header worked for me. |









The flag you are missing is probably
ENABLE_SENSITIVE_HEADER_PASSTHROUGH.Authorizationis classified as a sensitive header, soENABLE_HEADER_PASSTHROUGH=trueon its own does not cover it. Both have to be set. Frommcpgateway/config.py:So in your compose environment you want both: