mcp-ssh-manager 4.3.5 → 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/Formula/ssh-manager.rb +2 -2
- package/README.md +11 -5
- package/cli/vault.js +5 -2
- package/desktop/electron/package-lock.json +2 -2
- package/desktop/electron/package.json +1 -1
- package/docs/MIGRATION.md +20 -2
- package/package.json +3 -2
- package/server.json +2 -2
- package/src/config-paths.js +83 -12
- package/src/index.js +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.3.6] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
**A security release: upgrade if an agent runs in a project folder you did not write.**
|
|
13
|
+
The `.env` of the folder an MCP client was started in could define a server whose
|
|
14
|
+
`PROXYCOMMAND` runs a command on your machine when a tool connects to it
|
|
15
|
+
([GHSA-wxcj-q5hp-wjrw](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-wxcj-q5hp-wjrw),
|
|
16
|
+
high). Every release from 3.3.0, where `PROXYCOMMAND` was added, is affected.
|
|
17
|
+
**One thing behaves differently on purpose:** that `.env` is no longer read unless you
|
|
18
|
+
placed it or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` (details below). Servers in
|
|
19
|
+
`~/.ssh-manager/.env`, in a file named by `SSH_ENV_PATH` or `SSH_MANAGER_ENV`, in the
|
|
20
|
+
vault or in the process environment are not affected. Nothing else changes (the release
|
|
21
|
+
pipeline upgrades 3.8.5, 3.8.6, 3.8.7, every 4.0.x, 4.1.0, 4.2.0, 4.3.0, 4.3.1, 4.3.2, 4.3.3,
|
|
22
|
+
4.3.4 and 4.3.5 from the registry to this version and back).
|
|
23
|
+
|
|
24
|
+
The Windows installer is still **not Authenticode-signed**, for the same reason
|
|
25
|
+
as 4.0.0: Windows shows *"Windows protected your PC"*, *More info → Run anyway*,
|
|
26
|
+
and `ssh-manager app` checks the installer against the SHA-256 in
|
|
27
|
+
`release-manifest-win32.json`. macOS builds are signed and notarized.
|
|
28
|
+
|
|
29
|
+
### Security
|
|
30
|
+
|
|
31
|
+
- **A project's `.env` could run a command on this machine**
|
|
32
|
+
([GHSA-wxcj-q5hp-wjrw](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-wxcj-q5hp-wjrw),
|
|
33
|
+
reported by Pythame). The engine read the `.env` of its working directory, which is
|
|
34
|
+
whatever project the MCP client was started in, when `~/.ssh-manager/.env` did not
|
|
35
|
+
exist. That file can define a server with `SSH_SERVER_<NAME>_PROXYCOMMAND`, or point
|
|
36
|
+
`SSH_CONFIG_PATH` at a TOML with a `proxy_command`, and the engine runs that command
|
|
37
|
+
through the shell when a tool connects to the server: before any SSH banner, whatever
|
|
38
|
+
the server's mode or approval, and even when the connection then fails. A repository
|
|
39
|
+
with such a file was enough. Every release from 3.3.0, where `PROXYCOMMAND` was
|
|
40
|
+
added, is affected.
|
|
41
|
+
**One thing behaves differently on purpose:** the `.env` of the working directory is
|
|
42
|
+
no longer read, unless it is also a file you placed (`~/.ssh-manager/.env`, your
|
|
43
|
+
home's `.env`, or the install directory's, which is what a run from a checkout
|
|
44
|
+
reads) or the environment of the MCP server says `SSH_MANAGER_TRUST_PROJECT_ENV=1`.
|
|
45
|
+
A project file cannot grant that itself, and a file it names through
|
|
46
|
+
`SSH_CONFIG_PATH` is not read either. When a project `.env` that defines servers is
|
|
47
|
+
left unread, the engine says so at startup, in `ssh_list_servers` and in "server not
|
|
48
|
+
found", with the three ways to have it read: move it to `~/.ssh-manager/.env`, name
|
|
49
|
+
it with `SSH_ENV_PATH`, or set the variable (in the `env` block of the MCP client's
|
|
50
|
+
configuration, where the client's own approval of a project server applies). With a
|
|
51
|
+
file in `~/.ssh-manager/.env`, `SSH_ENV_PATH` or `SSH_MANAGER_ENV`, nothing changes.
|
|
52
|
+
Two details that come with it: a project `.env` no longer hides your home `.env`, and
|
|
53
|
+
a `.env` written into the project while the engine runs is not picked up.
|
|
54
|
+
|
|
10
55
|
## [4.3.5] - 2026-11-25
|
|
11
56
|
|
|
12
57
|
**A security release: upgrade if a server uses `restricted` or `readonly` mode.** A
|
package/Formula/ssh-manager.rb
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
class SshManager < Formula
|
|
14
14
|
desc "SSH server management for AI agents, with approval and audit"
|
|
15
15
|
homepage "https://github.com/bvisible/mcp-ssh-manager"
|
|
16
|
-
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.3.
|
|
17
|
-
sha256 "
|
|
16
|
+
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.3.5.tgz"
|
|
17
|
+
sha256 "43c0c08251bf15ebb3407e5371f26a065641c820eb9347f972408c03f8508aa7"
|
|
18
18
|
license "MIT"
|
|
19
19
|
|
|
20
20
|
depends_on "node"
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
[](https://github.com/bvisible/mcp-ssh-manager/releases/latest)
|
|
26
26
|
[](https://github.com/bvisible/mcp-ssh-manager/stargazers)
|
|
27
27
|
[](https://mcptoplist.com/server/io.github.bvisible%2Fmcp-ssh-manager)
|
|
28
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.6)
|
|
29
29
|
[](https://claude.ai/code)
|
|
30
30
|
[](https://openai.com/codex)
|
|
31
31
|
[](https://modelcontextprotocol.io)
|
|
@@ -58,9 +58,9 @@ An MCP SSH server is the most dangerous tool you can hand an agent: a shell on m
|
|
|
58
58
|
|
|
59
59
|
## Choose your workspace
|
|
60
60
|
|
|
61
|
-
**Desktop application (`4.3.
|
|
61
|
+
**Desktop application (`4.3.6`):** one installation with its own runtime,
|
|
62
62
|
terminal, file browser and server settings. No separate Node.js or npm
|
|
63
|
-
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.
|
|
63
|
+
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.6):
|
|
64
64
|
|
|
65
65
|
| Platform | File | Signature |
|
|
66
66
|
|---|---|---|
|
|
@@ -68,7 +68,7 @@ installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases
|
|
|
68
68
|
| Windows x64 / arm64 | `…-setup.exe` | **Not code-signed yet.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
|
|
69
69
|
| Linux x64 | `.deb`, `.AppImage` | Unsigned, as Linux packages usually are |
|
|
70
70
|
|
|
71
|
-
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.3.
|
|
71
|
+
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.3.6,
|
|
72
72
|
and the V4 engine runs without an interface, from your existing `.env`, TOML or
|
|
73
73
|
process variables — no automatic import, no forced wizard, no approval prompt
|
|
74
74
|
unless you enable one per server. The one behaviour that tightens is **SSH
|
|
@@ -526,6 +526,8 @@ file people email each other and commit by accident.
|
|
|
526
526
|
|
|
527
527
|
Two interchangeable formats, read by the same loader: `.env` is the usual choice with Claude Code, TOML with Codex (from `SSH_CONFIG_PATH`, or `~/.codex/ssh-config.toml`). Both can coexist — the loader merges them.
|
|
528
528
|
|
|
529
|
+
The `.env` is `~/.ssh-manager/.env`, or the file `SSH_ENV_PATH` names. One that only sits in the project folder your agent was started in is **not** read (a server entry can run a command on your machine): move it, name it, or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` — see [docs/MIGRATION.md](docs/MIGRATION.md#which-env-is-read).
|
|
530
|
+
|
|
529
531
|
```env
|
|
530
532
|
SSH_SERVER_[NAME]_HOST=hostname_or_ip
|
|
531
533
|
SSH_SERVER_[NAME]_USER=username
|
|
@@ -720,7 +722,11 @@ The hero animation ships twice, light and dark, swapped by `<picture>` on `prefe
|
|
|
720
722
|
|
|
721
723
|
## What's new
|
|
722
724
|
|
|
723
|
-
**[4.3.
|
|
725
|
+
**[4.3.6](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.6) — a security fix: a project folder's `.env` could run a command on your machine.** The `.env` of the folder an MCP client was started in could define a server whose `PROXYCOMMAND` ran when a tool connected to it, before any SSH login and whatever the server's mode. That `.env` is no longer read unless you placed it (`~/.ssh-manager/.env`, your home's, the install folder's) or set `SSH_MANAGER_TRUST_PROJECT_ENV=1` in the environment of the engine; the engine says which file it left unread. If your servers were in a `.env` next to the project, move it to `~/.ssh-manager/.env` or name it with `SSH_ENV_PATH`. Reported by @Pythame (GHSA-wxcj-q5hp-wjrw). See the [CHANGELOG](CHANGELOG.md#436---2026-11-25).
|
|
726
|
+
|
|
727
|
+
**[4.3.5](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.5) — a security fix: `restricted` and `readonly` modes could be made to run a command their patterns deny.** A shell rewrites a word before it runs it (`r""m`, `r\m` and `r${x}m` are all `rm`), and the patterns were tested on the text as typed, so a denied command could ride behind an allowed launcher such as `find -exec` or `xargs`. Every command is now also tested as the shell reads it. If you use `restricted` or `readonly` mode, upgrade. Reported by @Pythame (GHSA-4fp4-fggm-cf5c). See the [CHANGELOG](CHANGELOG.md#435---2026-11-25).
|
|
728
|
+
|
|
729
|
+
**[4.3.4](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.4) — a security fix: `ssh_download` could write any file on your machine, even from a `readonly` server.** An agent that could not run a command on a `readonly` or `restricted` server could still have a file it had put on the server downloaded over `~/.zshrc` or into `~/.ssh/authorized_keys`. The local side of a transfer now has a transfer root: `readonly` and `restricted` servers download into `~/.ssh-manager/transfers`, and any server can name its own folder with `TRANSFER_ROOT`. If you download from such a server to a folder of your own, set `TRANSFER_ROOT` to it. (GHSA-2v9g-gm8g-mxgj) See the [CHANGELOG](CHANGELOG.md#434---2026-11-23).
|
|
724
730
|
|
|
725
731
|
**[4.3.3](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.3) — a security fix: `restricted` mode could be made to run a command its allowlist never saw.** A comment, a here-document, an ANSI-C quote (`$'…'`) or a parenthesis could hide a command from the check while the shell ran it. The allowlist now reads comments as comments and refuses those constructs, with a reason. Servers in `readonly` mode and servers without a mode are unaffected; if you use `restricted` mode, upgrade. Reported by @Fastyyy123 (GHSA-86xm-rv3h-r4f2). See the [CHANGELOG](CHANGELOG.md#433---2026-11-21).
|
|
726
732
|
|
package/cli/vault.js
CHANGED
|
@@ -19,7 +19,7 @@ import { writeRecoveryFile, readRecoveryFile, describeRecoveryFile } from '../sr
|
|
|
19
19
|
import { SecretStore, defaultVaultPath, SECRET_FIELDS } from '../src/secret-store.js';
|
|
20
20
|
import { defaultSocketPath, isControlPlaneListening, VALID_APPROVAL_MODES } from '../src/approval.js';
|
|
21
21
|
import { ConfigLoader } from '../src/config-loader.js';
|
|
22
|
-
import {
|
|
22
|
+
import { envFileChoice } from '../src/config-paths.js';
|
|
23
23
|
import { GREEN, YELLOW, RED, DIM, RESET } from './style.js';
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -282,7 +282,8 @@ async function cmdRemove(store, name) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
async function cmdImport(store, fromPath) {
|
|
285
|
-
const
|
|
285
|
+
const choice = fromPath ? null : envFileChoice();
|
|
286
|
+
const envPath = fromPath || choice.path;
|
|
286
287
|
if (fromPath && !fs.existsSync(fromPath)) {
|
|
287
288
|
console.error(`${RED}No configuration found at ${fromPath}${RESET}`);
|
|
288
289
|
process.exit(1);
|
|
@@ -298,6 +299,8 @@ async function cmdImport(store, fromPath) {
|
|
|
298
299
|
|
|
299
300
|
if (servers.size === 0) {
|
|
300
301
|
console.log(`${YELLOW}No servers found in the configuration.${RESET}`);
|
|
302
|
+
// A .env in this folder is read only when named: a project file is not trusted by default.
|
|
303
|
+
if (choice?.skippedProject) console.log(`${YELLOW}${choice.skippedProject} was not read; to import it, name it.${RESET}`);
|
|
301
304
|
console.log(`${DIM}Point at a file with: ssh-manager vault import --from /path/to/.env (or .toml)${RESET}`);
|
|
302
305
|
return;
|
|
303
306
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-manager-desktop",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "ssh-manager-desktop",
|
|
9
|
-
"version": "4.3.
|
|
9
|
+
"version": "4.3.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"electron-updater": "^6.8.9",
|
package/docs/MIGRATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Upgrading from 3.8 to 4.0
|
|
2
2
|
|
|
3
|
-
**4.0 is released, on npm and as a desktop application**; the latest is 4.3.
|
|
3
|
+
**4.0 is released, on npm and as a desktop application**; the latest is 4.3.6 ([release](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.3.6)).
|
|
4
4
|
The last 3.8 release is 3.8.7, for anyone who pins the 3.8 line.
|
|
5
5
|
|
|
6
6
|
The upgrade path preserves headless npm/CLI use. The application, vault import
|
|
@@ -316,10 +316,28 @@ it; the engine never starts one.
|
|
|
316
316
|
`SSH_MANAGER_ENV` — the CLI's variable, which 3.8.x's engine never read. A
|
|
317
317
|
profile that still exports `SSH_MANAGER_ENV` towards a file that no longer
|
|
318
318
|
exists is skipped with a warning, so the usual discovery (`~/.ssh-manager/.env`,
|
|
319
|
-
then
|
|
319
|
+
then your home, then the install directory) applies. A missing
|
|
320
320
|
file named by `SSH_ENV_PATH` stays the choice and is reported at startup, in
|
|
321
321
|
`ssh_list_servers` and in "server not found".
|
|
322
322
|
|
|
323
|
+
Up to 4.3.5 the discovery also read the `.env` of the working directory, second
|
|
324
|
+
in the list. That is the project the MCP client was started in, and a server
|
|
325
|
+
entry can carry a command that runs on your machine when it connects
|
|
326
|
+
(`PROXYCOMMAND`, or a `proxy_command` in a TOML), so it is no longer read unless
|
|
327
|
+
it is a file you placed or you say so
|
|
328
|
+
([GHSA-wxcj-q5hp-wjrw](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-wxcj-q5hp-wjrw)).
|
|
329
|
+
If your servers were in a `.env` next to the project, do one of:
|
|
330
|
+
|
|
331
|
+
- move it to `~/.ssh-manager/.env` (the place `llms-install.md` and the CLI use);
|
|
332
|
+
- name it: `SSH_ENV_PATH=/path/to/.env` in the `env` block of the MCP client;
|
|
333
|
+
- trust the project's file: `SSH_MANAGER_TRUST_PROJECT_ENV=1` in the same block.
|
|
334
|
+
It is read from the environment of the engine only; a `.env` cannot set it.
|
|
335
|
+
|
|
336
|
+
The engine says which file it left unread: in the log at startup, in
|
|
337
|
+
`ssh_list_servers` and in "server not found". The `.env` of the install
|
|
338
|
+
directory, which is what runs from a checkout read, and your home's, are read
|
|
339
|
+
as before.
|
|
340
|
+
|
|
323
341
|
## Rolling back to 3.8.7
|
|
324
342
|
|
|
325
343
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.6",
|
|
4
4
|
"mcpName": "io.github.bvisible/mcp-ssh-manager",
|
|
5
5
|
"description": "MCP server for SSH: let AI agents (Claude Code, Codex, any MCP client) run commands, transfer files and manage servers over SSH, with human approval, an encrypted vault and a live audit trail.",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
15
15
|
"configure": "python tools/server-manager.py",
|
|
16
16
|
"test-connection": "python tools/test-connection.py",
|
|
17
|
-
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:vault && npm run test:recovery && npm run test:upgrade && npm run test:notify && npm run test:commands && npm run test:commandlog && npm run test:portability && npm run test:approval && npm run test:controlplane && npm run test:terminal && npm run test:files && npm run test:livestream && npm run test:livefailure && npm run test:transferpaths && npm run test:skills && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:shellsegments && npm run test:policynames && npm run test:auditsuccess && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:agentkey && npm run test:certpath && npm run test:agentannounce && npm run test:autherrors && npm run test:envchoice && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:quoteprops && npm run test:backupinjection && npm run test:dbrowcount && npm run test:dbclientcmds && npm run test:migration && npm run test:security && npm run test:hostkeys && npm run test:proxy && npm run test:working-directory && npm run test:groups-persistence && npm run test:release && npm run test:cli-experience && npm run test:desktop-install && npm run test:agent-clients && npm run test:appupdate && npm run test:preview && npm run test:desktop-smoke && npm run test:local-shell && npm run test:cli-edit && npm run test:timeoutwrap && npm run test:downloadstats && npm run test:remotetunnel && npm run test:connsharing && npm run test:auditcoverage && npm run test:background && npm run test:quietstderr && npm run test:sshguard && npm run test:locale && npm run test:langtool && npm run test:healthdisks && npm run test:backupintegrity && npm run test:clienvlines && npm run test:clicodex",
|
|
17
|
+
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:vault && npm run test:recovery && npm run test:upgrade && npm run test:notify && npm run test:commands && npm run test:commandlog && npm run test:portability && npm run test:approval && npm run test:controlplane && npm run test:terminal && npm run test:files && npm run test:livestream && npm run test:livefailure && npm run test:transferpaths && npm run test:skills && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:shellsegments && npm run test:policynames && npm run test:auditsuccess && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:agentkey && npm run test:certpath && npm run test:agentannounce && npm run test:autherrors && npm run test:envchoice && npm run test:projectenv && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:quoteprops && npm run test:backupinjection && npm run test:dbrowcount && npm run test:dbclientcmds && npm run test:migration && npm run test:security && npm run test:hostkeys && npm run test:proxy && npm run test:working-directory && npm run test:groups-persistence && npm run test:release && npm run test:cli-experience && npm run test:desktop-install && npm run test:agent-clients && npm run test:appupdate && npm run test:preview && npm run test:desktop-smoke && npm run test:local-shell && npm run test:cli-edit && npm run test:timeoutwrap && npm run test:downloadstats && npm run test:remotetunnel && npm run test:connsharing && npm run test:auditcoverage && npm run test:background && npm run test:quietstderr && npm run test:sshguard && npm run test:locale && npm run test:langtool && npm run test:healthdisks && npm run test:backupintegrity && npm run test:clienvlines && npm run test:clicodex",
|
|
18
18
|
"test:lockfile": "node tests/test-lockfile.js",
|
|
19
19
|
"test:sudostdin": "node tests/test-sudo-stdin.js",
|
|
20
20
|
"test:vault": "node tests/test-secret-store.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"test:agentannounce": "node tests/test-agent-announce.js",
|
|
43
43
|
"test:autherrors": "node tests/test-auth-errors.js",
|
|
44
44
|
"test:envchoice": "node tests/test-env-file-choice.js",
|
|
45
|
+
"test:projectenv": "node tests/test-project-env-trust.js",
|
|
45
46
|
"test:lifecycle": "node tests/test-lifecycle.js",
|
|
46
47
|
"test:tunnel": "node tests/test-tunnel-listen.js",
|
|
47
48
|
"test:sync": "node tests/test-sync-stats.js",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/bvisible/mcp-ssh-manager",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "4.3.
|
|
9
|
+
"version": "4.3.6",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "mcp-ssh-manager",
|
|
14
|
-
"version": "4.3.
|
|
14
|
+
"version": "4.3.6",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
package/src/config-paths.js
CHANGED
|
@@ -31,6 +31,33 @@ export function expandHomePath(value) {
|
|
|
31
31
|
return text;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/** @param {unknown} value */
|
|
35
|
+
function isOn(value) {
|
|
36
|
+
return /^(1|true|yes|on)$/i.test(String(value ?? '').trim());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* True when both names lead to the same file, links followed. A file that does
|
|
41
|
+
* not exist is the same as nothing.
|
|
42
|
+
* @param {string} first
|
|
43
|
+
* @param {string} second
|
|
44
|
+
*/
|
|
45
|
+
function sameFile(first, second) {
|
|
46
|
+
try { return fs.realpathSync(first) === fs.realpathSync(second); } catch { return false; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* True when a .env sets up the SSH manager: a server, or a TOML to read. Any
|
|
51
|
+
* repository has a .env of its own, so only one that does is worth a word.
|
|
52
|
+
* @param {string} file
|
|
53
|
+
*/
|
|
54
|
+
function configuresServers(file) {
|
|
55
|
+
try {
|
|
56
|
+
return Object.keys(dotenv.parse(fs.readFileSync(file)))
|
|
57
|
+
.some(key => key === 'SSH_CONFIG_PATH' || /^SSH_SERVER_[A-Z0-9_]+_HOST$/.test(key));
|
|
58
|
+
} catch { return false; }
|
|
59
|
+
}
|
|
60
|
+
|
|
34
61
|
/**
|
|
35
62
|
* Which .env the engine reads, and why.
|
|
36
63
|
*
|
|
@@ -45,32 +72,60 @@ export function expandHomePath(value) {
|
|
|
45
72
|
* the variable, and reported in `ignored`. SSH_ENV_PATH was always the
|
|
46
73
|
* engine's own override: a missing file there stays the choice, reported as
|
|
47
74
|
* `missing`, so nothing is silently read in place of what was asked for.
|
|
75
|
+
*
|
|
76
|
+
* The `.env` of the working directory is the one file in the list that nobody
|
|
77
|
+
* chose: it belongs to whatever project the MCP client was started in. A
|
|
78
|
+
* server entry can carry a command that runs on this machine when it connects
|
|
79
|
+
* (PROXYCOMMAND, or one in the TOML that SSH_CONFIG_PATH points to), so a
|
|
80
|
+
* repository that ships a `.env` could make the engine run its commands, with
|
|
81
|
+
* no SSH host and no approval involved. That file is therefore read only when
|
|
82
|
+
* it is also the file the user placed (the manager home, the home directory or
|
|
83
|
+
* the install directory, which is the case when the engine runs from a
|
|
84
|
+
* checkout), or when the process environment says SSH_MANAGER_TRUST_PROJECT_ENV.
|
|
85
|
+
* It is never read from a file: the project's own `.env` cannot vouch for itself.
|
|
86
|
+
* Otherwise it is left unread and named in `skippedProject`, and where a file is
|
|
87
|
+
* wanted but none exists the manager home is used, so that a `.env` an agent
|
|
88
|
+
* writes into the project later is not picked up by a running engine either.
|
|
48
89
|
* @param {{ projectRoot?: string }} [options]
|
|
49
90
|
* @returns {{path: string, variable: string|null, missing: boolean,
|
|
50
|
-
* ignored: {variable: string, path: string}|null}}
|
|
91
|
+
* ignored: {variable: string, path: string}|null, skippedProject: string|null}}
|
|
51
92
|
*/
|
|
52
93
|
export function envFileChoice({
|
|
53
94
|
projectRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
|
|
54
95
|
} = {}) {
|
|
55
96
|
if (process.env.SSH_ENV_PATH) {
|
|
56
97
|
const file = process.env.SSH_ENV_PATH;
|
|
57
|
-
return { path: file, variable: 'SSH_ENV_PATH', missing: !fs.existsSync(file), ignored: null };
|
|
98
|
+
return { path: file, variable: 'SSH_ENV_PATH', missing: !fs.existsSync(file), ignored: null, skippedProject: null };
|
|
58
99
|
}
|
|
59
100
|
let ignored = null;
|
|
60
101
|
if (process.env.SSH_MANAGER_ENV) {
|
|
61
102
|
const file = process.env.SSH_MANAGER_ENV;
|
|
62
|
-
if (fs.existsSync(file))
|
|
103
|
+
if (fs.existsSync(file)) {
|
|
104
|
+
return { path: file, variable: 'SSH_MANAGER_ENV', missing: false, ignored: null, skippedProject: null };
|
|
105
|
+
}
|
|
63
106
|
ignored = { variable: 'SSH_MANAGER_ENV', path: file };
|
|
64
107
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
108
|
+
const managerEnv = path.join(managerHome(), '.env');
|
|
109
|
+
const homeEnv = path.join(os.homedir(), '.env');
|
|
110
|
+
const installEnv = path.join(projectRoot, '.env');
|
|
111
|
+
const projectEnv = path.join(process.cwd(), '.env');
|
|
112
|
+
const trustProject = isOn(process.env.SSH_MANAGER_TRUST_PROJECT_ENV)
|
|
113
|
+
|| [managerEnv, homeEnv, installEnv].some(file => sameFile(file, projectEnv));
|
|
114
|
+
const candidates = [managerEnv, ...(trustProject ? [projectEnv] : []), homeEnv, installEnv];
|
|
71
115
|
const found = candidates.find(candidate => fs.existsSync(candidate));
|
|
116
|
+
// Said only when it would have been read before: with a file in the manager home
|
|
117
|
+
// the project's was never looked at, and a project .env that sets up no server
|
|
118
|
+
// (most of them) has nothing to be missed.
|
|
119
|
+
const skippedProject = !trustProject && !fs.existsSync(managerEnv) && configuresServers(projectEnv)
|
|
120
|
+
? projectEnv : null;
|
|
72
121
|
// No file at all is a valid setup (servers from the environment or TOML).
|
|
73
|
-
return {
|
|
122
|
+
return {
|
|
123
|
+
path: found || (trustProject ? projectEnv : managerEnv),
|
|
124
|
+
variable: null,
|
|
125
|
+
missing: false,
|
|
126
|
+
ignored,
|
|
127
|
+
skippedProject
|
|
128
|
+
};
|
|
74
129
|
}
|
|
75
130
|
|
|
76
131
|
/**
|
|
@@ -92,10 +147,26 @@ export function envFileProblem(choice) {
|
|
|
92
147
|
if (choice.missing) {
|
|
93
148
|
return `${choice.variable} names ${choice.path}, which does not exist: no server is loaded from a .env file`;
|
|
94
149
|
}
|
|
150
|
+
const problems = [];
|
|
95
151
|
if (choice.ignored) {
|
|
96
|
-
|
|
152
|
+
problems.push(`${choice.ignored.variable} names ${choice.ignored.path}, which does not exist; using ${choice.path} instead`);
|
|
97
153
|
}
|
|
98
|
-
|
|
154
|
+
if (choice.skippedProject) {
|
|
155
|
+
problems.push(projectEnvNotice(choice.skippedProject));
|
|
156
|
+
}
|
|
157
|
+
return problems.length ? problems.join('; ') : null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* What to tell the operator when the .env of the working directory was left
|
|
162
|
+
* unread, and the three ways to have it read.
|
|
163
|
+
* @param {string} file
|
|
164
|
+
* @returns {string}
|
|
165
|
+
*/
|
|
166
|
+
export function projectEnvNotice(file) {
|
|
167
|
+
return `${file} was not read: a project file is not trusted to start commands on this machine. `
|
|
168
|
+
+ `Move it to ${path.join(managerHome(), '.env')}, name it with SSH_ENV_PATH, `
|
|
169
|
+
+ 'or set SSH_MANAGER_TRUST_PROJECT_ENV=1 in the environment of the MCP server';
|
|
99
170
|
}
|
|
100
171
|
|
|
101
172
|
/** Read file-selected TOML settings just as the MCP entry point does.
|
package/src/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import crypto from 'node:crypto';
|
|
14
14
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
15
15
|
import { isDeepStrictEqual } from 'node:util';
|
|
16
|
-
import { envFileChoice, envFileProblem, expandHomePath } from './config-paths.js';
|
|
16
|
+
import { envFileChoice, envFileProblem, expandHomePath, projectEnvNotice } from './config-paths.js';
|
|
17
17
|
import { fileURLToPath } from 'url';
|
|
18
18
|
import { ServerConfigManager } from './server-config-manager.js';
|
|
19
19
|
import {
|
|
@@ -272,7 +272,8 @@ async function getServerConfig(serverName) {
|
|
|
272
272
|
const servers = await loadServerConfig();
|
|
273
273
|
const name = serverName && resolveServerName(String(serverName), servers);
|
|
274
274
|
if (!name) {
|
|
275
|
-
|
|
275
|
+
// A project .env left unread is named even when other servers loaded: the one asked for may be in it.
|
|
276
|
+
throw new Error(`Server "${serverName}" not found${envProblem && (!Object.keys(servers).length || envChoice.skippedProject) ? ` (${envProblem})` : ''}`);
|
|
276
277
|
}
|
|
277
278
|
return servers[name];
|
|
278
279
|
}
|
|
@@ -2419,6 +2420,7 @@ registerToolConditional(
|
|
|
2419
2420
|
];
|
|
2420
2421
|
// The list stays the first item, unchanged, for anything that parses it.
|
|
2421
2422
|
if (envProblem && !serverInfo.length) content.push({ type: 'text', text: `No server loaded: ${envProblem}.` });
|
|
2423
|
+
else if (envChoice.skippedProject) content.push({ type: 'text', text: `Note: ${projectEnvNotice(envChoice.skippedProject)}.` });
|
|
2422
2424
|
return { content };
|
|
2423
2425
|
}
|
|
2424
2426
|
);
|