Repository navigation
fix(claude): keep ${VAR} references in project .mcp.json - #3377
Open
Aaryan Dadu (Aaryan-Dadu) wants to merge 1 commit into
Open
Aaryan Dadu (Aaryan-Dadu) wants to merge 1 commit into
Aaryan Dadu (Aaryan-Dadu) wants to merge 1 commit into
Conversation
Claude Code expands ${VAR} and ${VAR:-default} in the project .mcp.json,
so apm install keeps the references there instead of prompting for and
writing the real values. Reinstall replaces values an earlier release
wrote when APM can confirm it wrote them; otherwise it keeps the entry
and names the fields to fix. User scope is unchanged.
Adds an MCP variable compatibility page covering every harness.
Closes microsoft#3252
Aaryan Dadu (Aaryan-Dadu)
requested review from
Daniel Meppiel (danielmeppiel) and
Sergio Sisternes (sergio-sisternes-epam)
as code owners
October 24, 2026 09:16
This branch has not been deployed
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.
Description
With
--target claude,apm installresolved${VAR}values at install time and wrote the real secrets into the project's.mcp.json, which is usually committed. Claude Code expands${VAR}and${VAR:-default}itself when it starts a server, so APM now keeps the references there.How it works:
.mcp.jsonkeeps${VAR}and${VAR:-default}incommand,args,env,urlandheaders.${env:VAR}and<VAR>become${VAR}. There are no prompts, and no values end up in.mcp.json,apm.lock.yamlor the output.LOG_LEVEL: debugstay as written. Registry servers get${NAME}for their variables and secret arguments.~/.claude.json) is unchanged.I checked Claude Code's behavior with Claude Code 2.1.310: a recording stdio command and a local HTTP endpoint showed it expands references and defaults in all five fields, in both
.mcp.jsonand~/.claude.json, and leaves an unset variable as literal text with a warning.Closes #3252
Before
After
Issue and approved scope
Issue: #3252
Human scope-approval comment: #3252 (comment)
Does this PR complete the issue, or what remains? It completes the Claude project repair. Gaps in other harnesses are recorded on the new page for separate decisions.
Type of change
Testing
New installed-CLI tests in
tests/integration/test_claude_mcp_env_references_e2e.pycover set, unset and defaulted variables, a registry server, user scope, mixed targets, unrelated entries and Claude's approval file, and reinstall over old values (replaced, or kept when APM can't confirm it wrote them). 6 of the 7 fail onmain; the user-scope one pins the unchanged behavior. There are also unit tests intest_claude_mcp.pyandtest_mcp_ownership.py.I also installed the same declarations for all 12 harnesses and both scopes on
mainand on this branch. The only output that changes is Claude's project config.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.