Repository navigation
The Claude Code MCP header helper takes its code scope from the session's project directory - #415
Merged
Merged
Conversation
…on's project directory
Claude Code starts a plugin's headersHelper in the plugin root, so the helper's
working directory named no checkout, or the wrong one when the plugin root sits
inside a checkout. The plugin's .mcp.json now passes ${CLAUDE_PROJECT_DIR}, which
Claude Code substitutes in headersHelper, and the helper resolves the scope from
that argument. An empty or unsubstituted argument names no checkout. The Codex
entry passes none and keeps the directory it runs in.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…fragment, which no shell reads
Inside the headersHelper command the shell ran $(...) and backticks in a
substituted project path. The entry's url now ends in #${CLAUDE_PROJECT_DIR};
Claude Code hands the helper that URL in CLAUDE_CODE_MCP_SERVER_URL and sends no
fragment, and the headersHelper command is back to what it was.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
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.
Fixes #337
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The Claude Code plugin's
X-Loom-Code-Scopeheader names the checkout the session works in. Before, it named no checkout for a plugin installed from a git marketplace, and the plugin's own checkout for one installed from a local clone.Why
Claude Code starts a plugin's
headersHelperin the plugin root, socheckoutScope(process.cwd())resolved the plugin's directory, not the project's. The helper's environment carries no project directory. Claude Code does substitute${CLAUDE_PROJECT_DIR}in a plugin entry'surl, and it hands the helper that URL inCLAUDE_CODE_MCP_SERVER_URL. The entry's URL now ends in#${CLAUDE_PROJECT_DIR}, and the helper reads its project directory from the fragment. An HTTP client never sends a fragment, so the server sees/mcp?toolset=<toolset>as before.The path is never in the
headersHelpercommand. A command line carrying it would have the shell evaluate$(...)and backticks in a directory name, and Claude Code runs a plugin's helper before the folder is trusted.A fragment that is not an absolute path names no checkout, so the plugin root is never used. That covers an empty one and a Claude Code that leaves
${CLAUDE_PROJECT_DIR}unsubstituted, which keeps an unknown${VAR}as written and still connects.LOOM_CODE_REPO/code_repostill name a repository. A URL with no fragment (the Codex entry) keeps the directory the helper runs in.Scope and risk
.mcp.jsonurl, their tests and the Claude Code integration page. The bearer lookup and theheadersHelpercommand are unchanged./mcpnow ends in the project directory.Compatibility, rollout and rollback
Tests
node --test integrations/claude-code-plugin/tests/*.test.mjs: 606 pass. A new test gives the helper a project directory in the fragment while it runs in another checkout, and the header names the project's scope; this test fails onmain. An empty or unsubstituted fragment gives no header, and no fragment keeps the working directory.projectDirreturns a path holding#,%,$(id), backticks, quotes and an apostrophe as it is.claude -p --plugin-dirwith a probe plugin whose entry has thisurland a local listener: the helper ran in the plugin root and read the project path fromCLAUDE_CODE_MCP_SERVER_URL. The path held#50% $(id) `x` "q" it'sand came through unchanged. Every request the listener logged was/mcp?toolset=coding, with no fragment and no path.${CLAUDE_PROJECT_DIR:-}is not substituted (it reads as an environment variable), which is why the bare form is used. An undefined${VAR}in the URL stays literal and the entry still connects.claude plugin validateon the plugin and the marketplace;agent_plugin_sync;pyteston the codex-plugin, install, docs-link and public-copy tests: 249 pass.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. How Claude Code substitutes the variable and what reaches the server were checked against a real session, as above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code