Repository navigation
test(claude-code): authenticate the real-host E2E with the saved credential - #2707
Merged
hidb4ai merged 1 commit intoNov 18, 2026
Merged
Conversation
…ential Only setup receives POWERCONTEXT_CLAUDE_AUTHORIZATION, and claude runs without it, so the hooks read the credential setup saved and the plugin MCP server gets it from its headersHelper, as in a session that does not inherit the variable. The fixture now fails early when setup saved no credential.
hidb4ai
approved these changes
Nov 18, 2026
hidb4ai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed efacf75. No blocking findings. Restricting the authorization environment variable to setup correctly exercises saved-credential authentication for hooks and MCP, and the setup assertion makes missing persistence fail early. This test-only change adds no database tables or public interfaces.
Validated the four host/model cases on Linux with Claude Code 2.1.277 and the frozen dependency environment, including an incorrect inherited authorization value; all passed. The 150 plugin tests and changed-file Ruff checks also passed. CI is green. This verifies the real host/plugin/Server chain with fixture models, not live-provider behavior. Merge confidence: 90/100.
hireview001
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue or RFC does this PR close?
No tracking issue. It follows the real-host Claude Code E2E (#2686) and the plugin MCP
headersHelperthat reads the saved credential (#2669).Rationale for this change
The documented Claude Code path is that
powercontext setup claude-codesaves the client'sPOWERCONTEXT_CLAUDE_AUTHORIZATIONfor itsserver_url. The hooks read that saved credential when the variable is not set, and the plugin MCP server gets it from theheadersHelper(scripts/mcp_headers.py). The static${POWERCONTEXT_CLAUDE_AUTHORIZATION:-}header in.mcp.jsonapplies only when nothing is saved.The real-host E2E set
POWERCONTEXT_CLAUDE_AUTHORIZATIONfor everyclauderun. The hooks therefore used the variable, and MCP authenticated through the static header. Removing the static header from.mcp.jsonfailed the tools case, and removingheadersHelperdid not. The suite did not cover the saved-credential path that sessions without the variable depend on. The E2E token also contains only letters and hyphens. Claude Code 2.1.277 removes credential-like values (digits,_ + / =) from aheadersHelper's environment, the cause of #1530, so the old setup also hid that stripping.What changes are included in this PR?
tests/e2e/test_claude_code_host_service_chain.py:POWERCONTEXT_CLAUDE_AUTHORIZATION. It saves the credential for this Server under$CLAUDE_CONFIG_DIR/powercontext/credentials.json.clauderuns without the variable. An inherited value from the developer's or CI's environment was already dropped with the otherPOWERCONTEXT_*variables; the comment now says why that matters here.headersHelper.authorization_state == "configured", so a credential that setup did not save fails at setup and names the cause, not later as a missing prepare record or a failed MCP server.The hook scripts' handling of an exported
POWERCONTEXT_CLAUDE_AUTHORIZATIONstays covered bytests/e2e/test_claude_code_service_chain.py, which runs them directly against a Server. This suite does not exercise Claude Code's expansion of the static.mcp.jsonheader: whenever setup has saved a credential, theheadersHelperheader replaces it.No plugin, product, CI or documentation change. Nothing in
.github/ordocs/described this E2E's credential handling.Are there any user-facing changes?
No. This PR changes one test.
How was this change tested?
CLAUDE_CODE_CLI_BIN=<claude 2.1.277> UV_OFFLINE=1 uv run --frozen pytest tests/e2e/test_claude_code_host_service_chain.py tests/e2e/test_host_model_messages.py -v, the files theclaude-code-hostjob runs, on macOS (arm64): 4 passed in each of three runs, in 15.4, 15.8 and 17.2 s. Not run on Linux locally; theclaude-code-hostjob runs on Linux.The same cases with
POWERCONTEXT_CLAUDE_AUTHORIZATION="Bearer wrong-inherited-value"exported in the outer environment: 3 passed, so an inherited value does not reachclaude.A temporary probe in
mcp_headers.py, reverted afterwards, logged eachheadersHelperrun in all three cases. Each run hadCLAUDE_CONFIG_DIR, noPOWERCONTEXT_CLAUDE_AUTHORIZATION, andCLAUDE_CODE_MCP_SERVER_URLset to this Server's/mcpendpoint, and each emitted the savedAuthorizationheader.Each mutation below was applied, the cases were run, and the files were restored and checked byte for byte with sha256:
.mcp.jsonwithoutheadersHelperclaude_turn_error_400: API Error: 400 fixture_tool_unavailable_remember_memory, because the MCP server failed to connect and offered no toolsmcp_headers.pyalways emits{}mcp_serversreportsplugin:powercontext:powercontextasfailed.mcp.jsonwithout the staticheadersblockpowercontext_setup_saved_no_credential(not_configured)authentication_failed), bootstrap fails (no bootstrap record), tools fails (fixture_tool_unavailable_remember_memory)uv run ruff checkanduv run ruff format --checkon the changed file;UV_OFFLINE=1 uv run --frozen pytest tests/claude_code_plugin -q: 150 passed;make check, includingty: passed.AI usage statement
Claude Code (Claude Opus 5.5) wrote the change and this description, and ran the verification above.