Repository navigation
Show env values in the server.json launch preview and confirm runtime-control vars - #2945
Conversation
…-control vars The server.json import copies each declared environment variable's default/value into the saved config's env, and the stdio transport passes it to the spawned process, but the "Command to Run" preview listed env var names only while stating it is exactly what will be saved and run. Several variables change what an unchanged command line executes or where it fetches the package from (NODE_OPTIONS, npm_config_*, UV_*, PIP_*, PYTHON*, DOCKER_*, LD_*, DYLD_*, DOTNET_*, NUGET_*, PATH). - The preview now shows NAME=value (shell-quoted) for every variable the launch sets. A declared isSecret variable is masked and badged Secret. - A new pure classifier, isRuntimeControlEnvVar (core/mcp/import), flags runtime-control variables case-insensitively, with a short allowlist of output-only names (NODE_ENV, PYTHONUNBUFFERED, ...). Flagged variables are badged in the preview, are never masked even when declared secret, and get a warning that explains why. - Add stays disabled until the user confirms the flagged values. The confirmation is recorded against the flagged names and values, so editing one withdraws it; submit re-checks it against the config being saved. Values are not refused or dropped, since a legitimate server can need one (a registry mirror, PYTHONPATH, a remote docker host); clearing a flagged value removes it and the need to confirm. - isSecret fields in the form render as a PasswordInput. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
…_/OPENSSL_ - Show a declared secret's document-supplied value in clear in the preview and form; mask only values the user entered (those differing from the declared default/value). A document could otherwise mark any variable isSecret to hide its own value, and a variable the classifier misses would then slip past the preview unseen. The form uses a PasswordInput only for a secret the document supplies no value for, so the field never swaps input types mid-typing. - Flag CORECLR_* (profiler variables load a native library into the .NET runtime dnx starts), COMPlus_* (the legacy spelling of DOTNET_* knobs) and OPENSSL_* (an OpenSSL config can load an engine/provider library). - Give the resolved-environment list role="group" so its label is announced. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
A name declared twice has one effective value in the saved env, but the declared-secrets map took its value from whichever declaration came last, so a duplicate isSecret entry with no default could mask the value actually saved. Read each secret's document-supplied value from the option's base env, the same map the saved config is built from, for both the preview mask and the form's password field. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can expose secrets through duplicate fields, forward the host’s PATH without confirmation, and crash import previews for declarations named constructor or toString.
3 open issues
What changed in this PR
This PR addresses #2949 by showing environment values in the web client’s server.json launch preview and requiring confirmation for runtime-control variables, using a shared classifier in core/.
Changes:
- Shows shell-quoted environment values, masking user-entered secrets but keeping runtime-control values visible.
- Adds warning badges and confirmation tied to the flagged names and values.
- Adds classifier, hook, and component tests plus Storybook examples.
| File | Description |
|---|---|
core/mcp/import/runtimeControlEnv.ts |
Adds case-insensitive runtime-control classification. |
core/mcp/import/index.ts |
Exports the classifier. |
clients/web/src/test/core/mcp/import/runtimeControlEnv.test.ts |
Tests flagged names, prefixes, and exemptions. |
clients/web/src/hooks/useServerJsonImport.ts |
Builds value previews, derives masking, and gates submission on confirmation. |
clients/web/src/hooks/useServerJsonImport.test.tsx |
Tests preview values, masking, confirmation, and submission. |
clients/web/src/components/groups/ServerImportJsonModal/ServerImportJsonModal.tsx |
Connects confirmation state to the panel. |
clients/web/src/components/groups/ImportServerJsonPanel/ImportServerJsonPanel.tsx |
Renders environment rows, warnings, confirmation, and password fields. |
clients/web/src/components/groups/ImportServerJsonPanel/ImportServerJsonPanel.test.tsx |
Tests environment display and confirmation interactions. |
clients/web/src/components/groups/ImportServerJsonPanel/ImportServerJsonPanel.stories.tsx |
Updates preview fixtures and adds runtime-control examples. |
Review effort: Balanced
| const masked = isMaskedSecret(name, value, secrets); | ||
| return { | ||
| name, | ||
| display: `${name}=${masked ? SECRET_MASK : quoteShellArg(value)}`, |
There was a problem hiding this comment.
Fixed in 177fc08. buildServerConfigForSelection now reads the override map with Object.hasOwn, and the hook reads the override and document env maps through an own-property helper (ownValue), so a declaration named constructor/toString resolves to undefined rather than an inherited function. Regression test: "previews declarations named like Object.prototype members" (it failed with the arg.replace TypeError before the fix).
A name declared twice shares one value, so the form now hides every field of a name any declaration marks secret, as the preview already did. Env lookups keyed by a declared name read own properties only, so a declaration named after an Object.prototype member no longer reads an inherited function into the preview. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
|
Copilot round 1 (review 5863778608), answered in each thread:
No suppressed comments. Round 2 requested. |
|
Copilot round 2 (review 5864006510) was clean: no inline comments, the headline recommends approval, and there are no suppressed comments. The one item it still lists as open is the round-1 prototype-name thread, already fixed in 177fc08 and answered there. The review loop is closed on the clean-round exit (pr-flow 7c). |


Closes #2949
Fix for GHSA-pp85-586h-2m95 (v2 only, affects <= 2.14.0).
Problem
Importing a registry
server.jsoncopies each declared environment variable'sdefault/valueinto the saved config'senv, and the stdio spawn passes it to the launched process. The import panel's "Command to Run" preview listed only the env var names, but it told the user the preview "is exactly what will be saved and run". Some variables change what an unchanged-looking command line actually runs, or where it downloads the package from.Fix
NAME=value(value shell-quoted, the same quoting the command line uses) for every variable the launch sets. It is built from the samebuildServerConfigForSelectionoutput thatsubmitpersists, so it cannot drift from what is saved. A variable declaredisSecretis masked (********) and badged Secret only when its value was entered by the user. A value the document itself supplies is not secret (it is in the pastedserver.json), so it is always shown in clear. That decision compares against the document value inselectedOption.baseConfig.env, the same map the saved config is built from, so a name declared twice cannot mask a document-supplied value.isRuntimeControlEnvVar(core/mcp/import/runtimeControlEnv.ts, exported from the import barrel), matches case-insensitively onPATHand the prefixesNODE_,NPM_CONFIG_,UV_,PIP_,PYTHON,DOCKER_,LD_,DYLD_,DOTNET_,NUGET_,CORECLR_,COMPLUS_andOPENSSL_. It exempts a short allowlist of names that only change output (NODE_ENV,NODE_NO_WARNINGS,PYTHONUNBUFFERED,PYTHONIOENCODING,PYTHONUTF8,PYTHONDONTWRITEBYTECODE), and flags anything else in those families by default.DOTNET_/NUGET_/CORECLR_/COMPLUS_are included becausednxis the fourth launch runtime (the CoreCLR profiler variables load a native library, the same class asLD_PRELOAD).OPENSSL_is included because an OpenSSL config can load an engine or provider library into Node or Python. Flagged rows get a Runtime control badge and a warning that explains why. A flagged variable is never masked, even when it is declaredisSecret. Otherwise a document could hide the exact value the preview exists to show.submitre-checks the signature against the config it is about to save.PYTHONPATH, a remoteDOCKER_HOST). Refusing would make those servers impossible to import. Silently dropping the value would save a misconfigured server whose preview no longer matches what the author intended. Confirmation keeps the "exactly what will run" promise honest. Every value is shown, the risky ones are explained, and nothing is saved until the user has affirmatively accepted those specific values.isSecretform fields usePasswordInputwhen the document supplies no value for them (decided from the declaration, so the field does not switch type while typing). A flagged variable stays a plainTextInputeven when declared secret, for the same reason as in 2. The password field has no clear button because its right section holds the visibility toggle.Tests
clients/web/src/test/core/mcp/import/runtimeControlEnv.test.ts: flagged, case-insensitive, and not-flagged names, includingPATHNAME/MY_PATH/NODEthe allowlist, and theCORECLR_/COMPlus_/OPENSSL_families.useServerJsonImport.test.tsx:describeLaunchproducesNAME=value, masks secrets, and never masks flagged vars.runtimeControlSignaturechanges only with flagged values. For the hook, Add is disabled until confirmed, editing a flagged value withdraws the confirmation (a non-flagged edit does not), clearing the flagged values removes the need to confirm,submitrefuses unconfirmed values and saves confirmed ones verbatim, and re-opening the modal resets the confirmation, document-supplied secret values show in clear while user-entered ones are masked, and a duplicate-declared name follows the saved value.ImportServerJsonPanel.test.tsx: env rows, the Secret badge, Runtime control badges, therole="group"env list, the warning text and checkbox wiring, and the password field.envshape, and addedRuntimeControlEnvandRuntimeControlEnvAcknowledged. The badge and alert use the theme's AA-contrast variants (Badgestatus,Alertwarning), so the stories pass the a11y check.Gate
npm run formatthennpm run local:gate: green (exit 0). (run locally in the fork; public CI runs here)Screenshots
Captured from the dev server with a
server.jsondeclaringnpm_config_registry,NODE_OPTIONS(markedisSecret),API_KEY(isSecret, document default, so shown in clear), a user-typedTOKEN(masked) andREGION.import-preview-runtime-control-unconfirmed
import-preview-add-disabled-until-confirmed
import-preview-runtime-control-confirmed
🤖 Generated with Claude Code