Skip to content

fix(aigw): support custom auth header for MCP servers - #2693

Open
kanurag94 wants to merge 1 commit into
theagentrouter:mainfrom
kanurag94:mcp-custom-auth-header
Open

kanurag94 wants to merge 1 commit into
theagentrouter:mainfrom
kanurag94:mcp-custom-auth-header

Conversation

@kanurag94

@kanurag94 kanurag94 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

aigw run --mcp-config only recognized a credential when it was supplied as Authorization: Bearer <token>. MCP servers that require a different header for auth, like Composio's x-consumer-api-key, never got their credential sent, because any non-Authorization header was silently dropped by the config generation template.

This extends AddMCPServers to also recognize a single non-Authorization header as the server's credential, and threads the header name through to the MCPRoute's securityPolicy.apiKey.header field, which the CRD and its controller already fully support, reusing that existing mechanism rather than adding anything new at the CRD/controller layer.

  • Authorization: Bearer <token> keeps working exactly as before.
  • A single custom header (e.g. x-consumer-api-key: ${COMPOSIO_API_KEY}) is now extracted and re-injected into that same header name on the upstream request, unprefixed.
  • Multiple simultaneous non-auth headers remain unsupported (pre-existing, separate limitation, out of scope here).

Test plan:

  • go test ./internal/autoconfig/... - new unit test for the custom-header extraction, plus a new golden-file test (testdata/composio.yaml) exercising the full template render end-to-end
  • go test ./cmd/aigw/...
  • go build ./...
  • gofmt -l / go vet clean on changed files

Related Issues/PRs (if applicable)

None.

Special notes for reviewers (if applicable)

None.

@netlify

netlify Bot commented Sep 15, 2026

Copy link
Copy Markdown

Deploy Preview for theagentrouter ready!

Name Link
🔨 Latest commit 223e265
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6aa9b9520b27f70008ca9cf1
😎 Deploy Preview https://deploy-preview-2693--theagentrouter.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

aigw run --mcp-config only recognized credentials supplied as
Authorization: Bearer <token>, so MCP servers that require a
different header (e.g. Composio's x-consumer-api-key) never got
their auth. Extend AddMCPServers to also recognize a single
non-Authorization header as the credential, and thread it through
to the MCPRoute securityPolicy.apiKey.header field the CRD already
supports.

Signed-off-by: Anurag Aggarwal <kanurag94@gmail.com>
@kanurag94
kanurag94 force-pushed the mcp-custom-auth-header branch from bc73f91 to 223e265 Compare September 15, 2026 21:32
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kanurag94
kanurag94 marked this pull request as ready for review September 15, 2026 22:57
@kanurag94
kanurag94 requested a review from a team as a code owner September 15, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant