Skip to content

fix: use relative path in .mcp.json to silence CLAUDE_PLUGIN_ROOT warning#253

Merged
mksglu merged 13 commits intomksglu:nextfrom
flightlesstux:fix/mcp-json-plugin-root
Apr 13, 2026
Merged

fix: use relative path in .mcp.json to silence CLAUDE_PLUGIN_ROOT warning#253
mksglu merged 13 commits intomksglu:nextfrom
flightlesstux:fix/mcp-json-plugin-root

Conversation

@flightlesstux
Copy link
Copy Markdown
Contributor

Summary

  • Replace ${CLAUDE_PLUGIN_ROOT}/start.mjs with ./start.mjs in repo-root .mcp.json.
  • Silences the warning Claude Code prints when the repo is opened as a regular project (not as an installed plugin).
  • Plugin install path is unchanged — it still reads .claude-plugin/plugin.json.

Why

${CLAUDE_PLUGIN_ROOT} is only defined when Claude Code loads the repo as an installed plugin. Opening the repo as a normal project leaves the var undefined, so every session starts with:

[Warning] [context-mode] mcpServers.context-mode: Missing environment variables: CLAUDE_PLUGIN_ROOT

A relative path resolves correctly when Claude Code spawns the MCP server from the project root. Plugin-mode continues to use .claude-plugin/plugin.json, which is unchanged.

Pros / Cons

Pros

  • Removes the startup warning for contributors.
  • No behavior change for installed-plugin users.
  • Single-line change.

Cons

  • Depends on Claude Code spawning the MCP server with the project root as cwd. If that assumption ever breaks, the relative path would too — but so would most .mcp.json files in the wild.

Test plan

  • Fresh clone opened in Claude Code shows no CLAUDE_PLUGIN_ROOT warning.
  • /context-mode:ctx-doctor still passes on a normal plugin install.
  • node ./start.mjs starts successfully from the repo root.

Closes #252

github-actions Bot and others added 13 commits April 6, 2026 06:34
${CLAUDE_PLUGIN_ROOT} is only defined when the repo is loaded as an installed
Claude Code plugin. When contributors open the repo as a regular project, the
variable is undefined and Claude Code prints:

  [Warning] mcpServers.context-mode: Missing environment variables: CLAUDE_PLUGIN_ROOT

Use a relative path so the MCP entry works for repo-as-project usage. Plugin
install path is unaffected — it still uses .claude-plugin/plugin.json.

Closes mksglu#251

Co-authored-by: Ercan Ermis <eposta@ercanermis.com>
…not repo-root

The prior assertion required `${CLAUDE_PLUGIN_ROOT}` in repo-root
`.mcp.json`, but that file is only read when contributors open the repo
as a regular project — marketplace installs resolve paths from
`.claude-plugin/plugin.json` instead. The repo-root file now uses a
relative path to silence the "Missing environment variable" warning.

Split the original test into two:
- Plugin manifest must keep the placeholder (real marketplace contract).
- Repo-root .mcp.json must use a relative path (this PR's behavior).

Co-authored-by: Ercan Ermis <eposta@ercanermis.com>
@flightlesstux
Copy link
Copy Markdown
Contributor Author

CI failure was a stale test assertion, not a regression from this PR.

tests/core/cli.test.ts:145 required ${CLAUDE_PLUGIN_ROOT} in repo-root .mcp.json under the name "keeps ${CLAUDE_PLUGIN_ROOT} for marketplace compatibility" — but marketplace installs actually resolve the placeholder from .claude-plugin/plugin.json, not the repo-root file. The assertion was pointing at the wrong manifest.

Fixed in 3f66152 by splitting the test in two:

  • Plugin manifest must keep the placeholder — real marketplace contract, asserts .claude-plugin/plugin.json still contains ${CLAUDE_PLUGIN_ROOT}.
  • Repo-root .mcp.json must use a relative path — this PR's intent, asserts the path is relative (not the env var).

Local npx vitest run tests/core/cli.test.ts → 94/94 passing. CI should be green on the next run.

@mksglu mksglu changed the base branch from main to next April 13, 2026 19:49
@mksglu mksglu merged commit aea633c into mksglu:next Apr 13, 2026
5 checks passed
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.

fix: .mcp.json warning - CLAUDE_PLUGIN_ROOT missing env variable

2 participants