Skip to content

Preserve ${VAR} placeholders in MCP server headers for runtime expansion#398

Merged
alex-feel merged 2 commits into
mainfrom
alex-feel-dev
Jun 30, 2026
Merged

Preserve ${VAR} placeholders in MCP server headers for runtime expansion#398
alex-feel merged 2 commits into
mainfrom
alex-feel-dev

Conversation

@alex-feel

Copy link
Copy Markdown
Owner

No description provided.

…xpansion

configure_mcp_server() interpolated the MCP --header (and the Windows --env) into the claude mcp add bash command using double quotes, so a ${VAR} placeholder in an Authorization header was expanded by the installer shell at setup time, baking the resolved token (or an empty string when the variable was unset) into the config instead of preserving the placeholder.

Switch these interpolations to shlex.quote, matching the Unix --env path that already did so, so the literal ${VAR} reaches claude mcp add and is stored verbatim; Claude Code then expands it from the environment at runtime, making env-var-referencing MCP headers work at user, local, and project scope, deterministically and independent of OS or shell.

Invert two tests that encoded the old double-quote behavior, add a Windows sibling unit test and a real cross-OS e2e test that drives the actual platform shell via a fake claude recorder, and document the runtime ${VAR} expansion, shell/OS independence, and the must-be-set / ${VAR:-default} caveat.
…e guard

test_install_claude_below_error_threshold asserted install_claude.py stays under a 120 KiB ceiling (Linux MAX_ARG_STRLEN/E2BIG), but the file is ~182 KiB, so it had been marked xfail.

That ceiling is obsolete: the Linux/macOS bootstrap scripts download install_claude.py to a file (curl -o) and run it via uv run <file>, never passing it inline as an execve() argument, so file size no longer maps to a real failure mode.

Replace the xfail'd hard gate (and the now-unused ERROR_THRESHOLD_BYTES) with a parametrized test asserting the real invariant -- every Linux/macOS bootstrap downloads install_claude.py to a file and never pipes a fetched script into uv/python -- while keeping the informational size warning.
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  scripts
  setup_environment.py
Project Total  

This report was generated by python-coverage-comment-action

@alex-feel alex-feel merged commit 2745775 into main Jun 30, 2026
17 checks passed
@alex-feel alex-feel deleted the alex-feel-dev branch June 30, 2026 10:53
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