claude-code - 💡(How to fix) Fix headersHelper does not expand ${CLAUDE_PLUGIN_ROOT} or set it as env var [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
anthropics/claude-code#47789Fetched 2026-04-15 06:42:17
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×6commented ×1

headersHelper in plugin .mcp.json does not expand ${CLAUDE_PLUGIN_ROOT} in the command string, nor is CLAUDE_PLUGIN_ROOT available as an environment variable when the helper runs. This makes it impossible to reference scripts bundled with a plugin.

Error Message

Error getting headers from headersHelper: headersHelper for MCP server

Root Cause

headersHelper in plugin .mcp.json does not expand ${CLAUDE_PLUGIN_ROOT} in the command string, nor is CLAUDE_PLUGIN_ROOT available as an environment variable when the helper runs. This makes it impossible to reference scripts bundled with a plugin.

Fix Action

Fix / Workaround

Workaround investigation

Code Example

{
     "mcpServers": {
       "test": {
         "type": "http",
         "url": "http://127.0.0.1:9499",
         "headersHelper": "${CLAUDE_PLUGIN_ROOT}/scripts/headers.sh"
       }
     }
   }

---

Error getting headers from headersHelper: headersHelper for MCP server
   'plugin:test:test' did not return a valid value
RAW_BUFFERClick to expand / collapse

Summary

headersHelper in plugin .mcp.json does not expand ${CLAUDE_PLUGIN_ROOT} in the command string, nor is CLAUDE_PLUGIN_ROOT available as an environment variable when the helper runs. This makes it impossible to reference scripts bundled with a plugin.

Steps to reproduce

  1. Create a plugin with a shell script at scripts/headers.sh that outputs JSON headers
  2. Configure .mcp.json:
    {
      "mcpServers": {
        "test": {
          "type": "http",
          "url": "http://127.0.0.1:9499",
          "headersHelper": "${CLAUDE_PLUGIN_ROOT}/scripts/headers.sh"
        }
      }
    }
  3. Install the plugin (tested both via --plugin-dir and marketplace install)
  4. The MCP server fails to connect. Debug log shows:
    Error getting headers from headersHelper: headersHelper for MCP server
    'plugin:test:test' did not return a valid value

Expected behavior

${CLAUDE_PLUGIN_ROOT} should be expanded in headersHelper strings (same as it is in command, args, and hook command fields). Alternatively, CLAUDE_PLUGIN_ROOT should be set as an environment variable when the helper command runs.

Workaround investigation

  • Hardcoded absolute path: works, confirming headersHelper itself functions correctly
  • $CLAUDE_PLUGIN_ROOT (shell syntax): does not work (the variable is not in the environment)
  • bash -c '$CLAUDE_PLUGIN_ROOT/scripts/headers.sh': does not work (same reason)
  • Static headers field: works correctly, confirming HTTP transport + custom headers function

Environment

We also confirmed that headersHelper only receives two environment variables:

  • CLAUDE_CODE_MCP_SERVER_NAME
  • CLAUDE_CODE_MCP_SERVER_URL

It does NOT receive CLAUDE_PLUGIN_ROOT or CLAUDE_PLUGIN_DATA, unlike hooks and MCP server subprocesses which do receive both.

Documentation references

The official plugin-dev skill reference at plugins/plugin-dev/skills/mcp-integration/references/authentication.md shows ${CLAUDE_PLUGIN_ROOT} in headersHelper examples, suggesting this is intended to work.

The plugins reference docs state: "Both [CLAUDE_PLUGIN_ROOT and CLAUDE_PLUGIN_DATA] are substituted inline anywhere they appear in skill content, agent content, hook commands, and MCP or LSP server configs."

Impact

Without CLAUDE_PLUGIN_ROOT expansion, plugins cannot use headersHelper to reference bundled scripts. This blocks the migration from stdio proxy patterns to native HTTP transport for plugins that need dynamic auth headers (e.g., IAP-protected MCP servers).

Versions tested

  • Claude Code v2.1.87
  • Claude Code v2.1.104

Tested on Linux (WSL2).

extent analysis

TL;DR

The most likely fix is to modify the headersHelper in the plugin's .mcp.json to use an absolute path or to set the CLAUDE_PLUGIN_ROOT environment variable before running the helper command.

Guidance

  • Verify that the CLAUDE_PLUGIN_ROOT environment variable is not being set in the environment where the headersHelper command runs by checking the environment variables received by headersHelper, which are currently only CLAUDE_CODE_MCP_SERVER_NAME and CLAUDE_CODE_MCP_SERVER_URL.
  • Consider using a hardcoded absolute path for the headersHelper command as a temporary workaround, as this has been confirmed to work.
  • Investigate modifying the plugin or the MCP server configuration to set the CLAUDE_PLUGIN_ROOT environment variable before running the headersHelper command.
  • Review the official plugin-dev skill reference and plugins reference docs to ensure that the intended behavior of ${CLAUDE_PLUGIN_ROOT} expansion in headersHelper is correctly understood.

Example

No code snippet is provided as the issue is related to configuration and environment variables.

Notes

The issue seems to be specific to the headersHelper command in the plugin's .mcp.json and the environment variables it receives. The CLAUDE_PLUGIN_ROOT expansion works in other fields such as command, args, and hook command fields.

Recommendation

Apply a workaround by using a hardcoded absolute path for the headersHelper command until the issue with CLAUDE_PLUGIN_ROOT expansion is resolved, as this has been confirmed to work and allows plugins to use headersHelper to reference bundled scripts.

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…

FAQ

Expected behavior

${CLAUDE_PLUGIN_ROOT} should be expanded in headersHelper strings (same as it is in command, args, and hook command fields). Alternatively, CLAUDE_PLUGIN_ROOT should be set as an environment variable when the helper command runs.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix headersHelper does not expand ${CLAUDE_PLUGIN_ROOT} or set it as env var [1 comments, 2 participants]