@xns-cloud/relayer-mcp 0.10.1 → 0.11.0

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/README.md CHANGED
@@ -15,7 +15,7 @@ npx @xns-cloud/relayer-mcp@latest
15
15
  ## Requirements
16
16
 
17
17
  - **Node.js 20+** — see [Installing Node.js 20](#installing-nodejs-20) if your distro ships an older version.
18
- - **Docker Engine** — on the same machine, or on a remote host via a Docker context (see [Remote Docker hosts](#remote-docker-hosts)).
18
+ - **Docker Engine** — on the same machine that runs the MCP. `install_relayer` refuses when the Docker daemon is on another machine (see [Remote Docker hosts](#remote-docker-hosts)).
19
19
 
20
20
  ### Installing Node.js 20
21
21
 
@@ -36,14 +36,7 @@ If you start the MCP on an older Node, it exits immediately with this same guida
36
36
 
37
37
  The Relayer runs as a Docker container and persists its data in a Docker volume. If the MCP is running inside an ephemeral environment (a sandbox container, a CI runner, or a throwaway VM), any installation performed there will be lost when that environment exits. `check_prerequisites` detects this automatically and reports it as a warning with a concrete next step — it never blocks the flow.
38
38
 
39
- **If your environment is ephemeral**, install on a persistent Docker host instead. The easiest path from an ephemeral sandbox is an SSH Docker context:
40
-
41
- ```bash
42
- docker context create relayer --docker "host=ssh://user@persistent-host"
43
- docker context use relayer
44
- ```
45
-
46
- The MCP then drives the install on the persistent host through the SSH context. Alternatively, hand the install step to a human operator on the target machine and continue onboarding from `check_relayer_health` onwards.
39
+ **If your environment is ephemeral**, run the MCP on a persistent Docker host instead (install Node.js 20 there and point your MCP client at it). Alternatively, hand the install step to a human operator on the target machine and continue onboarding from `check_relayer_health` onwards.
47
40
 
48
41
  ## Install
49
42
 
@@ -134,22 +127,11 @@ then run `install_relayer` again. To keep the existing deployment, skip `install
134
127
 
135
128
  ## Remote Docker hosts
136
129
 
137
- Claude Code doesn't have to run on the Docker machine. If you run it on a management node or jump host, point the Docker CLI at the remote server with an SSH context:
138
-
139
- ```bash
140
- docker context create relayer --docker "host=ssh://user@docker-box"
141
- docker context use relayer
142
- ```
143
-
144
- (Requires the `docker` CLI on the management node — the [static binary](https://docs.docker.com/engine/install/binaries/) is enough — and SSH key access to the Docker host.)
145
-
146
- The MCP detects this automatically (it honors `DOCKER_HOST` and the active Docker context):
130
+ `install_relayer` writes `docker-compose.yml` and `.env` on the machine running the MCP, then runs `docker compose up` against whichever daemon the Docker CLI points at. When that daemon is on another machine (`DOCKER_HOST=ssh://…` or `tcp://…`, or an SSH Docker context), it refuses before writing or starting anything, and the error names the Docker host.
147
131
 
148
- - `install_relayer` runs `docker compose` against the remote daemon.
149
- - `check_relayer_health` and `verify_storage` probe the **remote host's** ports 8888/9000 instead of localhost — make sure those are reachable from the management node.
150
- - `check_prerequisites` skips the local port-availability probes (the containers bind ports on the remote host) and reports them as skipped with instructions.
132
+ To install, run the MCP on the Docker host (Node.js 20 there, MCP client pointed at it) and run `install_relayer` again. Or unset `DOCKER_HOST` / switch to the default Docker context to install on the machine running the MCP.
151
133
 
152
- `check_relayer_health` accepts a `host` override, and `verify_storage` an `endpoint` override, for setups the auto-detection can't see (port forwards, NAT).
134
+ `check_prerequisites` reports the same condition as a failed `install_file_location` check. Health checks still work against a remote daemon: the MCP honors `DOCKER_HOST` and the active Docker context, `check_relayer_health` and `verify_storage` probe the remote host's ports 8888/9000 instead of localhost, and `check_prerequisites` skips the local port probes. `check_relayer_health` accepts a `host` override, and `verify_storage` an `endpoint` override, for setups the auto-detection can't see (port forwards, NAT).
153
135
 
154
136
  ## Troubleshooting
155
137
 
@@ -159,6 +141,8 @@ The MCP detects this automatically (it honors `DOCKER_HOST` and the active Docke
159
141
  | `install_relayer` reports an existing `xns-relayer` container | A previous deployment (any channel) owns the container name | [Fresh installs vs. existing deployments](#fresh-installs-vs-existing-deployments) |
160
142
  | Port 8888/9000 already in use | Another service on the Docker host (another S3-compatible service squatting 9000) | Stop it, or install with custom ports: `install_relayer` `ui_port` / `s3_port` (health checks accept the same) |
161
143
  | Health checks fail but containers run on a remote Docker host | Ports 8888/9000 not reachable from the management node | Open them, or pass `host` / `endpoint` overrides |
144
+ | `install_relayer` fails with "The Docker daemon is on <host>, not this machine" | `DOCKER_HOST` or an SSH/TCP Docker context points at another machine, and the install files would be written here instead | Run the MCP on that host and re-run, or unset `DOCKER_HOST` / use the default Docker context ([Remote Docker hosts](#remote-docker-hosts)) |
145
+ | `install_relayer` fails with "Failed to create directory …" | The install path needs root on the machine running the MCP (common on macOS/Windows workstations for paths under `/opt`), or a regular file sits at or along it | Pass a writable `install_path`; the exact OS error is in the MCP server's stderr log |
162
146
 
163
147
  ## Authentication
164
148
 
package/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "manifest_version": "0.3",
3
3
  "name": "relayer-mcp",
4
4
  "display_name": "XNS Relayer",
5
- "version": "0.10.1",
5
+ "version": "0.11.0",
6
6
  "description": "Set up and manage a self-hosted XNS Relayer — S3-compatible object storage — conversationally.",
7
7
  "long_description": "XNS Relayer is S3-compatible object storage you host yourself: $0 egress, uncapped, on hardware you control. This extension gives Claude 15 tools that walk the whole lifecycle — check prerequisites, register an XNS account, install the Relayer via Docker Compose, claim it to your account, choose which hosts store your data (VPD), verify an S3 round trip, provision CLI credentials, then handle day-2 work: settings, service restarts, and configuration backups.\n\nThe server runs locally on your machine and talks to your Relayer over loopback or your private network only — connections to public addresses are refused by design. Sign-in happens in your browser against XNS's identity service; the agent never sees your password.",
8
8
  "author": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xns-cloud/relayer-mcp",
3
3
  "mcpName": "tech.xns/relayer",
4
- "version": "0.10.1",
4
+ "version": "0.11.0",
5
5
  "description": "MCP server for XNS Relayer onboarding and day-2 management — drives Relayer setup, settings, and backups conversationally over stdio, npx-ready",
6
6
  "author": "SCP Corp",
7
7
  "license": "Apache-2.0",
@@ -1,13 +1,39 @@
1
1
  'use strict';
2
2
 
3
+ const net = require('net');
3
4
  const { execFile: nodeExecFile } = require('child_process');
4
5
 
6
+ // Every loopback spelling a Docker endpoint can carry: localhost, the whole
7
+ // 127/8 block, the 0.0.0.0 / [::] wildcards, [::1], and IPv4-mapped 127/8
8
+ // ([::ffff:127.0.0.1], which URL normalizes to [::ffff:7f00:1]).
9
+ function isLoopbackHost(name) {
10
+ if (['localhost', '0.0.0.0', '[::1]', '[::]'].includes(name)) return true;
11
+ if (net.isIPv4(name)) return name.startsWith('127.');
12
+ const mapped = /^\[::ffff:([0-9a-f]{1,4}):[0-9a-f]{1,4}\]$/.exec(name);
13
+ return Boolean(mapped) && (parseInt(mapped[1], 16) >> 8) === 127;
14
+ }
15
+
16
+ /**
17
+ * Replace the password in an endpoint URL's userinfo with ***. An ssh:// or
18
+ * tcp:// DOCKER_HOST can carry one, and tools echo the endpoint back to the
19
+ * client. The password runs to the LAST '@' before the path, query or
20
+ * fragment, as URL parsers (and Docker's own) read it, so a password
21
+ * containing '@' is fully masked and an '@' after the authority is left alone.
22
+ *
23
+ * @param {string|null|undefined} endpoint
24
+ * @returns {string|null}
25
+ */
26
+ function redactEndpoint(endpoint) {
27
+ if (typeof endpoint !== 'string') return endpoint ?? null;
28
+ return endpoint.replace(/^([a-z][a-z0-9+.-]*:\/\/[^:@/?#]*):[^/?#]*@/i, '$1:***@');
29
+ }
30
+
5
31
  /**
6
32
  * Parse a Docker endpoint URL into { remote, host }.
7
33
  *
8
34
  * unix:// and npipe:// sockets are local by definition. ssh:// and tcp://
9
35
  * point at another machine — unless the hostname is loopback. Anything
10
- * unparseable falls back to local, matching pre-context behaviour.
36
+ * unparseable falls back to local, matching pre-context behavior.
11
37
  *
12
38
  * @param {string} endpoint - e.g. 'unix:///var/run/docker.sock', 'ssh://user@host'
13
39
  * @returns {{remote: boolean, host: string}}
@@ -18,8 +44,12 @@ function parseDockerEndpoint(endpoint) {
18
44
  if (endpoint.startsWith('unix://') || endpoint.startsWith('npipe://')) return local;
19
45
  try {
20
46
  const { hostname } = new URL(endpoint);
21
- // URL.hostname keeps IPv6 brackets: 'tcp://[::1]:2375' → '[::1]'
22
- if (!hostname || ['localhost', '127.0.0.1', '[::1]'].includes(hostname)) return local;
47
+ // URL.hostname keeps IPv6 brackets ('tcp://[::1]:2375' → '[::1]') and
48
+ // does not lowercase tcp:// or ssh:// hosts, so compare lowercased.
49
+ // install_relayer refuses a remote daemon, so every loopback form —
50
+ // the whole 127/8 block, the 0.0.0.0 / [::] wildcards — must read local.
51
+ const name = hostname.toLowerCase();
52
+ if (!name || isLoopbackHost(name)) return local;
23
53
  return { remote: true, host: hostname };
24
54
  } catch {
25
55
  return local;
@@ -146,4 +176,4 @@ function createDockerUtil(options = {}) {
146
176
  return { docker, composeUp, isContainerRunning, findContainer, getDockerHost };
147
177
  }
148
178
 
149
- module.exports = { createDockerUtil, parseDockerEndpoint };
179
+ module.exports = { createDockerUtil, parseDockerEndpoint, redactEndpoint };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const net = require('net');
4
4
  const { createHttpClient } = require('../lib/httpClient');
5
- const { createDockerUtil } = require('../lib/dockerUtil');
5
+ const { createDockerUtil, redactEndpoint } = require('../lib/dockerUtil');
6
6
  const { environmentProbe: defaultEnvironmentProbe } = require('../lib/environmentProbe');
7
7
 
8
8
  /**
@@ -39,7 +39,7 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
39
39
  'check_prerequisites',
40
40
  {
41
41
  title: 'check_prerequisites',
42
- description: 'Check system prerequisites for XNS Relayer installation: Docker availability (local or remote via DOCKER_HOST / ssh:// context), required ports (8888, 9000), an existing xns-relayer installation, disk space, and network connectivity to console.xns.tech and auth.xns.tech. Run this first before any other relayer tool.',
42
+ description: 'Check system prerequisites for XNS Relayer installation: Docker availability (local or remote via DOCKER_HOST / ssh:// context), required ports (8888, 9000), an existing xns-relayer installation, disk space, and network connectivity to console.xns.tech and auth.xns.tech. Also fails the check when the Docker daemon is on another machine (install_file_location), because install_relayer refuses in that case; run the MCP on the Docker host instead. Run this first before any other relayer tool.',
43
43
  inputSchema: {
44
44
  /* no parameters */
45
45
  },
@@ -69,7 +69,7 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
69
69
  dockerHost = {
70
70
  remote: isRemote,
71
71
  host: isRemote ? remoteHost : 'localhost',
72
- endpoint: raw?.endpoint ?? null,
72
+ endpoint: redactEndpoint(raw?.endpoint), // echoed in the docker check detail
73
73
  };
74
74
  checks.push({
75
75
  name: 'docker',
@@ -84,7 +84,20 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
84
84
  name: 'docker',
85
85
  passed: false,
86
86
  detail: 'Docker is not available or not running',
87
- remediation: 'Install Docker Engine (https://docs.docker.com/engine/install/) and ensure the Docker daemon is running. On Linux: sudo systemctl start docker. Remote daemon: create an SSH context — docker context create relayer --docker "host=ssh://user@host" && docker context use relayer',
87
+ remediation: 'Install Docker Engine (https://docs.docker.com/engine/install/) and ensure the Docker daemon is running. On Linux: sudo systemctl start docker. To install on a persistent machine, run this MCP on that machine (a Docker host with Node.js 20) rather than pointing at it remotely.',
88
+ });
89
+ }
90
+
91
+ // 1b. install_relayer refuses when the daemon is on another machine
92
+ // (it writes docker-compose.yml and .env on THIS machine). Fail here
93
+ // so a passing check is never followed by a refused install.
94
+ if (dockerHost.remote) {
95
+ allPassed = false;
96
+ checks.push({
97
+ name: 'install_file_location',
98
+ passed: false,
99
+ detail: `The Docker daemon is on ${dockerHost.host}, not this machine. install_relayer will refuse: it writes docker-compose.yml and .env on this machine, not on ${dockerHost.host}.`,
100
+ remediation: `Run the MCP on ${dockerHost.host} (install Node.js 20 there and point your MCP client at it), then run check_prerequisites and install_relayer from there. Or unset DOCKER_HOST / switch to the default Docker context to install on this machine.`,
88
101
  });
89
102
  }
90
103
 
@@ -153,8 +166,8 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
153
166
  ? `This environment appears to be ephemeral (${probe.signals.join('; ')}), but Docker targets a remote host (${dockerHost.host}). Persistence depends on the remote Docker host.`
154
167
  : `This environment appears to be ephemeral (${probe.signals.join('; ')}). A Relayer installed here will be lost when the container exits.`,
155
168
  remediation: remoteDocker
156
- ? 'The Relayer will be installed on the remote Docker host. Verify that host has persistent storage.'
157
- : 'Install on a persistent Docker host instead. If you are running from a sandbox or CI, use an SSH Docker context to target a persistent machine: docker context create relayer --docker "host=ssh://user@host" && docker context use relayer',
169
+ ? `install_relayer will refuse while Docker targets ${dockerHost.host}. Run the MCP on ${dockerHost.host} (a persistent Docker host) instead of from this ephemeral environment.`
170
+ : 'Install on a persistent Docker host instead. If you are running from a sandbox or CI, run the MCP on a persistent Docker host rather than here.',
158
171
  });
159
172
  } else {
160
173
  checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Environment appears persistent — install will survive restarts' });
@@ -3,7 +3,7 @@
3
3
  const { z } = require('zod');
4
4
  const path = require('path');
5
5
  const net = require('net');
6
- const { createDockerUtil } = require('../lib/dockerUtil');
6
+ const { createDockerUtil, redactEndpoint } = require('../lib/dockerUtil');
7
7
 
8
8
  const BIND_ADDRESS_HELP = 'bind_address must be empty (all interfaces), an IPv4 address (e.g. "127.0.0.1"), or a bracketed IPv6 address (e.g. "[::1]") — the Compose ports host component is an IP address, not a hostname';
9
9
 
@@ -46,6 +46,44 @@ const TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'docker-compose.ym
46
46
  // alpha channel or beta — makes `docker compose up` fail with a name conflict.
47
47
  const CONTAINER_NAME = 'xns-relayer';
48
48
 
49
+ // The machine running this MCP and the machine running the Docker daemon can
50
+ // differ (DOCKER_HOST=ssh://..., tcp://..., or an ssh Docker context). This tool
51
+ // writes docker-compose.yml and .env on THIS machine, while compose up runs on
52
+ // the Docker host, so with a remote daemon it refuses before writing anything.
53
+ const LOCAL_DOCKER_HOST = Object.freeze({ remote: false, host: 'localhost', endpoint: null });
54
+
55
+ /**
56
+ * Resolve which machine the Docker daemon runs on, defensively.
57
+ *
58
+ * The result gates the install: a remote daemon makes install_relayer refuse.
59
+ * A detection failure (missing helper, throwing helper) or incomplete metadata
60
+ * ("remote" without a nameable host) still falls back to local and installs,
61
+ * because refusing on a machine we cannot name would block installs on a guess
62
+ * and give the user nothing to act on.
63
+ */
64
+ async function resolveDockerHost(docker) {
65
+ if (!docker || typeof docker.getDockerHost !== 'function') return LOCAL_DOCKER_HOST;
66
+ try {
67
+ const raw = await docker.getDockerHost();
68
+ const host = typeof raw?.host === 'string' ? raw.host.trim() : '';
69
+ const endpoint = raw?.endpoint ?? null;
70
+ // Report the endpoint even when local — check_prerequisites does, and a
71
+ // response saying "local" with no endpoint reads like detection failed.
72
+ if (!raw?.remote || host === '' || host === 'localhost') return { ...LOCAL_DOCKER_HOST, endpoint };
73
+ return { remote: true, host, endpoint };
74
+ } catch {
75
+ return LOCAL_DOCKER_HOST;
76
+ }
77
+ }
78
+
79
+ // Caught error text never goes back to the MCP client (.coderabbit.yaml path
80
+ // rule): execFile and OS messages can carry paths and system detail. A failure
81
+ // this file raises is marked userSafe (same convention as verifyStorage.js) and
82
+ // its cause is logged to stderr.
83
+ function safeError(message, cause) {
84
+ return Object.assign(new Error(message, { cause }), { userSafe: true });
85
+ }
86
+
49
87
  /**
50
88
  * Tool 4: install_relayer
51
89
  * AC-12: confirms "containers starting"; no manual shell.
@@ -60,7 +98,7 @@ const CONTAINER_NAME = 'xns-relayer';
60
98
  * install still completes and the response says it fell back.
61
99
  *
62
100
  * `compose_url` stays as an optional override for internal/custom installs;
63
- * when given, the old download-a-URL behaviour is preserved.
101
+ * when given, the old download-a-URL behavior is preserved.
64
102
  */
65
103
  module.exports = function registerInstallRelayer(server, options = {}) {
66
104
  const docker = options.dockerUtil || createDockerUtil(options);
@@ -72,7 +110,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
72
110
  'install_relayer',
73
111
  {
74
112
  title: 'install_relayer',
75
- description: 'Install and start the XNS Relayer. By default fetches the canonical beta channel bundle — relayer + the Prometheus/Grafana monitoring stack — from releases.scpri.me (anonymous pull) and writes a .env, then runs docker compose up -d — the user does NOT need to author any file. Falls back to a bundled copy of the bundle if the fetch fails. Pass compose_url only to override with a custom compose.\n\nExposure decisions on this surface:\n\n1. BINDING — bind_address controls which host network interface Docker publishes ports on. Default: empty (all interfaces — the dashboard answers from any machine on the LAN with zero configuration). Set to "127.0.0.1" for loopback-only, or a specific interface IP. The value is passed to docker compose via env as BIND_ADDRESS; it takes effect only if the compose file used for the install references BIND_ADDRESS in its port declarations. The bundled fallback compose does; the channel compose and any compose_url override are fetched remotely and may not. The prerequisite check (check_prerequisites) probes port availability by binding 0.0.0.0 regardless of this setting.\n\n2. UI TLS — ui_tls_enabled describes whether the admin UI listens on HTTPS in addition to HTTP. Default: false (off). This switch is described here for decision visibility; it is NOT wired to behavior in this version — setting it to true is accepted but has no effect until a future release ships the listener. Cost when enabled: requires a TLS certificate and key provisioned on the host.\n\n3. S3 TLS — s3_tls_enabled describes whether the S3 gateway listens on HTTPS in addition to HTTP. Default: false (off). This switch is described here for decision visibility; it is NOT wired to behavior in this version — setting it to true is accepted but has no effect until a future release ships the listener. Cost when enabled: requires a TLS certificate and key provisioned on the host; S3 clients must be configured to use the HTTPS endpoint.',
113
+ description: 'Install and start the XNS Relayer. By default fetches the canonical beta channel bundle — relayer + the Prometheus/Grafana monitoring stack — from releases.scpri.me (anonymous pull) and writes a .env, then runs docker compose up -d — the user does NOT need to author any file. Falls back to a bundled copy of the bundle if the fetch fails. Pass compose_url only to override with a custom compose.\n\nIMPORTANT — two machines: this tool writes docker-compose.yml and .env on the machine running the MCP, then starts the containers on whichever machine the Docker daemon is on. When DOCKER_HOST or an ssh:// Docker context points at a daemon on another machine, the tool refuses: it writes nothing and starts nothing, and returns an error naming the Docker host. Run the MCP on the Docker host (Node.js 20 there) and install from there.\n\nExposure decisions on this surface:\n\n1. BINDING — bind_address controls which host network interface Docker publishes ports on. Default: empty (all interfaces — the dashboard answers from any machine on the LAN with zero configuration). Set to "127.0.0.1" for loopback-only, or a specific interface IP. The value is passed to docker compose via env as BIND_ADDRESS; it takes effect only if the compose file used for the install references BIND_ADDRESS in its port declarations. The bundled fallback compose does; the channel compose and any compose_url override are fetched remotely and may not. The prerequisite check (check_prerequisites) probes port availability by binding 0.0.0.0 regardless of this setting.\n\n2. UI TLS — ui_tls_enabled describes whether the admin UI listens on HTTPS in addition to HTTP. Default: false (off). This switch is described here for decision visibility; it is NOT wired to behavior in this version — setting it to true is accepted but has no effect until a future release ships the listener. Cost when enabled: requires a TLS certificate and key provisioned on the host.\n\n3. S3 TLS — s3_tls_enabled describes whether the S3 gateway listens on HTTPS in addition to HTTP. Default: false (off). This switch is described here for decision visibility; it is NOT wired to behavior in this version — setting it to true is accepted but has no effect until a future release ships the listener. Cost when enabled: requires a TLS certificate and key provisioned on the host; S3 clients must be configured to use the HTTPS endpoint.',
76
114
  inputSchema: {
77
115
  install_path: z.string().optional().default('/opt/xns-relayer').describe('Directory to install the compose file into'),
78
116
  ui_port: z.number().int().min(1).max(65535).optional().default(8888).describe('Host port for the Relayer admin/customer UI (container 8888). Docker publishes this port on the interface chosen by bind_address.'),
@@ -97,6 +135,25 @@ module.exports = function registerInstallRelayer(server, options = {}) {
97
135
  const composePath = path.join(install_path, 'docker-compose.yml');
98
136
  const envPath = path.join(install_path, '.env');
99
137
 
138
+ // Gate first: before any lookup, mkdir, download or write. The
139
+ // files would land on this machine, not on the Docker host.
140
+ const dockerHost = await resolveDockerHost(docker);
141
+ if (dockerHost.remote) {
142
+ return {
143
+ content: [{
144
+ type: 'text',
145
+ text: JSON.stringify({
146
+ success: false,
147
+ error: `The Docker daemon is on ${dockerHost.host}, not this machine. install_relayer would write docker-compose.yml and .env on this machine instead of on ${dockerHost.host}, so nothing was written and nothing was started.`,
148
+ docker_host: dockerHost.host,
149
+ docker_endpoint: redactEndpoint(dockerHost.endpoint),
150
+ remediation: `Run the MCP on ${dockerHost.host} (install Node.js 20 there and point your MCP client at it), then run install_relayer again. Or, to install on this machine, unset DOCKER_HOST or switch to the default Docker context.`,
151
+ }, null, 2),
152
+ }],
153
+ isError: true,
154
+ };
155
+ }
156
+
100
157
  // Preflight: install_relayer is for FRESH installs only — it does
101
158
  // not upgrade an existing deployment in place. An existing
102
159
  // container (running or stopped, any channel) owns the name and
@@ -120,19 +177,20 @@ module.exports = function registerInstallRelayer(server, options = {}) {
120
177
  // Create install directory (execFile, no shell)
121
178
  await new Promise((resolve, reject) => {
122
179
  execFileFn('mkdir', ['-p', install_path], {}, (err) => {
123
- if (err) return reject(new Error(`Failed to create directory ${install_path}: ${err.message}`));
180
+ if (err) return reject(safeError(`Failed to create directory ${install_path} — check that the path is writable on this machine and no file sits at or along it`, err));
124
181
  resolve();
125
182
  });
126
183
  });
127
184
 
128
185
  const fetchCompose = (url) => new Promise((resolve, reject) => {
129
186
  execFileFn('curl', ['-fsSL', '-o', composePath, url], { timeout: 60000 }, (err) => {
130
- if (err) return reject(new Error(`Failed to download compose file: ${err.message}`));
187
+ if (err) return reject(safeError('Failed to download compose file', err));
131
188
  resolve();
132
189
  });
133
190
  });
134
191
 
135
192
  const bindPrefix = bind_address ? `${bind_address}:` : '';
193
+ let envContents = null;
136
194
  let source;
137
195
  let note;
138
196
  if (compose_url) {
@@ -151,9 +209,11 @@ module.exports = function registerInstallRelayer(server, options = {}) {
151
209
  const template = await fsp.readFile(TEMPLATE_PATH, 'utf8');
152
210
  await fsp.writeFile(composePath, template);
153
211
  source = 'bundled-fallback';
154
- note = `Channel bundle fetch failed (${fetchErr.message}) — fell back to the bundled compose. Same services; re-running install later is not required.`;
212
+ console.error(`[install_relayer] channel bundle fetch failed: ${fetchErr.cause?.message ?? fetchErr.message}`);
213
+ note = 'Channel bundle fetch failed — fell back to the bundled compose. Same services; re-running install later is not required.';
155
214
  }
156
- await fsp.writeFile(envPath, `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`);
215
+ envContents = `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`;
216
+ await fsp.writeFile(envPath, envContents);
157
217
  }
158
218
 
159
219
  // Run docker compose up -d. cwd + env so ${UI_PORT}/${S3_PORT}
@@ -206,12 +266,13 @@ module.exports = function registerInstallRelayer(server, options = {}) {
206
266
  }],
207
267
  };
208
268
  } catch (err) {
269
+ console.error(`[install_relayer] ${err.message}${err.cause ? `: ${err.cause.message}` : ''}`);
209
270
  return {
210
271
  content: [{
211
272
  type: 'text',
212
273
  text: JSON.stringify({
213
274
  success: false,
214
- error: `Relayer installation failed: ${err.message}`,
275
+ error: `Relayer installation failed: ${err.userSafe ? err.message : 'See server log for detail.'}`,
215
276
  }),
216
277
  }],
217
278
  isError: true,