openclaw - 💡(How to fix) Fix [Feature] MCP server auth: expose custom-header configuration in openclaw.json (some servers require x-api-key, not Bearer) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72196Fetched 2026-04-27 05:33:31
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

Root Cause

When connecting to an MCP server that authenticates via a non-Authorization: Bearer … scheme — for example a self-hosted LightRAG server which expects x-api-key: <key> — the request gets rejected because OpenClaw's MCP wiring (or the MCP client library it uses) sends the credential as Authorization: Bearer only.

Fix Action

Fix / Workaround

Current Workaround

We maintain a host cron (@reboot + */15) that patches the mcp-lightrag Python package's HTTP client to swap Authorization: Bearerx-api-key. This patches the downstream MCP package, but the underlying need is something openclaw.json should let me declare without monkey-patching:

If this config surface already exists somewhere I missed — please point me to docs and feel free to close this. If not, request is: support arbitrary authHeaders map in MCP server config so we can stop patching SDKs.

Code Example

{
  "mcp": {
    "servers": {
      "lightrag": {
        "url": "http://172.17.0.1:9621",
        "authHeaders": { "x-api-key": "${LIGHTRAG_API_KEY}" }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

When connecting to an MCP server that authenticates via a non-Authorization: Bearer … scheme — for example a self-hosted LightRAG server which expects x-api-key: <key> — the request gets rejected because OpenClaw's MCP wiring (or the MCP client library it uses) sends the credential as Authorization: Bearer only.

In our setup the call lands at LightRAG and returns 401 / null content, even though the same key works fine if sent as x-api-key via curl.

Current Workaround

We maintain a host cron (@reboot + */15) that patches the mcp-lightrag Python package's HTTP client to swap Authorization: Bearerx-api-key. This patches the downstream MCP package, but the underlying need is something openclaw.json should let me declare without monkey-patching:

{
  "mcp": {
    "servers": {
      "lightrag": {
        "url": "http://172.17.0.1:9621",
        "authHeaders": { "x-api-key": "${LIGHTRAG_API_KEY}" }
      }
    }
  }
}

If this config surface already exists somewhere I missed — please point me to docs and feel free to close this. If not, request is: support arbitrary authHeaders map in MCP server config so we can stop patching SDKs.

Environment

  • OpenClaw 2026.4.24 (commit cbcfdf6)
  • MCP server: LightRAG 1.4.13 (http://172.17.0.1:9621) — accepts only x-api-key
  • Downstream package patched as workaround: mcp-lightrag==0.2.2

Thanks for the project!

extent analysis

TL;DR

Support for arbitrary authHeaders in MCP server configuration is needed to fix the authentication issue with non-Authorization: Bearer schemes.

Guidance

  • Review the OpenClaw documentation to see if there's an existing configuration option for custom authentication headers that might have been missed.
  • Consider modifying the openclaw.json configuration file to include an authHeaders map, as shown in the provided example, to declare custom authentication headers for the MCP server.
  • If the issue persists, investigate the possibility of adding support for arbitrary authHeaders in the MCP server config, as requested.
  • Verify that the mcp-lightrag package is correctly patched and that the cron job is running as expected to ensure temporary workaround stability.

Example

The provided openclaw.json configuration example demonstrates how to declare custom authentication headers:

{
  "mcp": {
    "servers": {
      "lightrag": {
        "url": "http://172.17.0.1:9621",
        "authHeaders": { "x-api-key": "${LIGHTRAG_API_KEY}" }
      }
    }
  }
}

Notes

The current workaround using a cron job to patch the mcp-lightrag package is not ideal and may introduce maintenance and compatibility issues.

Recommendation

Apply workaround by modifying the openclaw.json configuration file to include custom authentication headers, as this is a more targeted and less invasive solution than patching the downstream package.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING