@xns-cloud/relayer-mcp 0.11.1 → 0.12.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 +29 -6
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/src/lib/dockerUtil.js +88 -2
- package/src/templates/docker-compose.yml +15 -16
- package/src/tools/checkPrerequisites.js +346 -37
- package/src/tools/installRelayer.js +155 -37
package/README.md
CHANGED
|
@@ -10,10 +10,20 @@ MCP server for [XNS Relayer](https://xns.tech) — S3-compatible decentralized o
|
|
|
10
10
|
npx @xns-cloud/relayer-mcp@latest
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Pricing:** [$6.00 per TB
|
|
13
|
+
**Pricing:** [$6.00 per TB per month](https://xns.tech/pricing) — one rate, protection included, [$0 egress uncapped](https://xns.tech/pricing), [30-day minimum retention](https://xns.tech/pricing) with no separate early-delete fee.
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
16
16
|
|
|
17
|
+
On Ubuntu 24.04 or Debian 12, one command sets up everything:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -fsSL https://releases.scpri.me/relayer/install.sh | sh
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The script installs Docker Engine and the compose plugin, adds you to the `docker` group, starts the Relayer in `/opt/xns-relayer`, and waits for the dashboard at `http://localhost:8888`. If Claude Code is present, it also installs Node.js 20 when Node is missing or older and registers this MCP. Log out and back in afterwards so the `docker` group applies. On macOS or Windows it installs nothing and points you to Docker Desktop.
|
|
24
|
+
|
|
25
|
+
Without the script, the MCP needs:
|
|
26
|
+
|
|
17
27
|
- **Node.js 20+** — see [Installing Node.js 20](#installing-nodejs-20) if your distro ships an older version.
|
|
18
28
|
- **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
29
|
|
|
@@ -40,10 +50,18 @@ The Relayer runs as a Docker container and persists its data in a Docker volume.
|
|
|
40
50
|
|
|
41
51
|
## Install
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
On Ubuntu 24.04 or Debian 12, one command installs the Relayer and registers this MCP when Claude Code is present:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
curl -fsSL https://releases.scpri.me/relayer/install.sh | sh
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
To register the MCP by hand instead:
|
|
60
|
+
|
|
61
|
+
**Claude Code** (one command, if you registered nothing yet):
|
|
44
62
|
|
|
45
63
|
```bash
|
|
46
|
-
claude mcp add relayer -- npx @xns-cloud/relayer-mcp@latest
|
|
64
|
+
claude mcp add --scope user relayer -- npx @xns-cloud/relayer-mcp@latest
|
|
47
65
|
```
|
|
48
66
|
|
|
49
67
|
**Claude Desktop / any MCP client** — add to your `claude_desktop_config.json` (or equivalent):
|
|
@@ -78,10 +96,10 @@ No separate install step required — npx fetches the package on demand.
|
|
|
78
96
|
|
|
79
97
|
| # | Tool | Purpose |
|
|
80
98
|
|---|------|---------|
|
|
81
|
-
| 1 | `check_prerequisites` | Verify Docker (local or remote), ports (8888, 9000), an existing installation, disk, and network connectivity. |
|
|
99
|
+
| 1 | `check_prerequisites` | Verify Docker (local or remote), the compose plugin, Docker socket access (when it is denied, whether the `docker` group membership is missing or not yet live), ports (8888, 9000, 9443), an existing installation, free disk (10 GB on the Docker root and the install directory), and network connectivity. Each failure names the command that fixes it; ports held by a running `xns-relayer` pass. |
|
|
82
100
|
| 2 | `start_registration` | Get the browser sign-up URL for creating an XNS account — the agent never handles credentials. |
|
|
83
101
|
| 3 | `check_email_verified` | Poll email verification status (15s interval, 30-min timeout). |
|
|
84
|
-
| 4 | `install_relayer` | Fetch the canonical
|
|
102
|
+
| 4 | `install_relayer` | Fetch the canonical release channel bundle — relayer + Prometheus/Grafana monitoring stack (`https://releases.scpri.me/relayer/release/docker-compose.yml` and its `.env`, anonymous pull, no `docker login`) — add the ports to that `.env`, and start the containers. Falls back to a bundled service-parity copy if either fetch fails. A failure names its cause (port in use, image pull refused, Docker stopped, out of disk, Docker socket permission) and the fix. **Fresh installs only** — see [Fresh installs vs. existing deployments](#fresh-installs-vs-existing-deployments). The user authors nothing; `compose_url` is an optional override for custom installs. |
|
|
85
103
|
| 5 | `check_relayer_health` | Poll UI, S3, HostIO, and the monitoring sidecars (10s interval, 300s timeout). A missing monitoring stack reports as degraded without blocking the flow. Targets the Docker host automatically. |
|
|
86
104
|
| 6 | `start_claim` | Initiate a claim session — returns a URL for browser confirmation. |
|
|
87
105
|
| 7 | `check_claim_status` | Poll claim state (STATE_1 / STATE_2 / STATE_3). |
|
|
@@ -139,7 +157,12 @@ To install, run the MCP on the Docker host (Node.js 20 there, MCP client pointed
|
|
|
139
157
|
|---|---|---|
|
|
140
158
|
| MCP exits with "requires Node.js 20 or newer" | Distro Node is too old (Ubuntu apt ships Node 18) | [Installing Node.js 20](#installing-nodejs-20) |
|
|
141
159
|
| `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) |
|
|
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) |
|
|
160
|
+
| 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). After a failed `install_relayer`, remove the leftover container with `docker rm -f xns-relayer` before retrying |
|
|
161
|
+
| Port 9443 already in use | Another service on the Docker host holds the S3 HTTPS port the release compose publishes | Stop that service (`sudo ss -ltnp 'sport = :9443'` names it); `ui_port` / `s3_port` do not move 9443. Then `docker rm -f xns-relayer` and retry |
|
|
162
|
+
| Docker socket permission denied | You were added to the `docker` group after this session started, or not at all | `sudo usermod -aG docker $USER` if needed, then log out and back in |
|
|
163
|
+
| Docker is not running | The Docker daemon is stopped | `sudo systemctl start docker` |
|
|
164
|
+
| Not enough disk space | Under 10 GB free on the Docker root or the install directory | Free space there, then re-run |
|
|
165
|
+
| Image pull refused | `releases.scpri.me` unreachable, or a stale registry login | Check the connection; `docker logout releases.scpri.me` |
|
|
143
166
|
| 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
167
|
| `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
168
|
| `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 |
|
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.
|
|
5
|
+
"version": "0.12.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.
|
|
4
|
+
"version": "0.12.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",
|
package/src/lib/dockerUtil.js
CHANGED
|
@@ -56,6 +56,44 @@ function parseDockerEndpoint(endpoint) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// Docker failure causes, first match wins (permission denied before daemon
|
|
60
|
+
// stopped: a denied socket can also print "Is the docker daemon running?"; pull
|
|
61
|
+
// refused before port in use: a pull error may mention a port).
|
|
62
|
+
const FAILURE_PATTERNS = [
|
|
63
|
+
// Only a refused connection to the Docker API is a socket denial. Docker 28
|
|
64
|
+
// and older word it "...to the Docker daemon socket", Docker 29 "...to the
|
|
65
|
+
// docker API"; a bind-mount "permission denied" must not match.
|
|
66
|
+
{ key: 'permission_denied', pattern: /permission denied while trying to connect to the docker/i },
|
|
67
|
+
{ key: 'daemon_stopped', pattern: /cannot connect to the docker daemon|is the docker daemon running|failed to connect to the docker API/i },
|
|
68
|
+
{ key: 'out_of_disk', pattern: /no space left on device/i },
|
|
69
|
+
{ key: 'pull_refused', pattern: /pull access denied|requested access to the resource is denied|unauthorized|manifest unknown|failed to resolve reference/i },
|
|
70
|
+
{ key: 'port_in_use', pattern: /port is already allocated|address already in use/i },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
// The host side of a bind in Docker's text: "0.0.0.0:8888", "[::]:8888",
|
|
74
|
+
// "0.0.0.0:9000:172.18.0.2:9000/tcp" (the first address is the host's).
|
|
75
|
+
const BIND_HOST_PORT = /(?:\d{1,3}(?:\.\d{1,3}){3}|\[[0-9a-f:.]*\]):(\d{1,5})\b/i;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Classify a rejected docker() call into a known failure cause.
|
|
79
|
+
*
|
|
80
|
+
* Reads ONLY error.stderr (set by docker() below). error.message embeds the
|
|
81
|
+
* command line, so a compose path containing "8888" or "port" would otherwise
|
|
82
|
+
* be mistaken for that cause. The returned key never carries Docker's text.
|
|
83
|
+
*
|
|
84
|
+
* @param {Error|null|undefined} err - Rejection from docker()/composeUp()
|
|
85
|
+
* @returns {{key: string, port?: number|null}|null} null when nothing matches
|
|
86
|
+
*/
|
|
87
|
+
function classifyDockerFailure(err) {
|
|
88
|
+
const stderr = err?.stderr;
|
|
89
|
+
if (typeof stderr !== 'string' || stderr === '') return null;
|
|
90
|
+
const match = FAILURE_PATTERNS.find(({ pattern }) => pattern.test(stderr));
|
|
91
|
+
if (!match) return null;
|
|
92
|
+
if (match.key !== 'port_in_use') return { key: match.key };
|
|
93
|
+
const bind = BIND_HOST_PORT.exec(stderr);
|
|
94
|
+
return { key: match.key, port: bind ? Number(bind[1]) : null };
|
|
95
|
+
}
|
|
96
|
+
|
|
59
97
|
/**
|
|
60
98
|
* Docker utility — runs Docker CLI commands using execFile (no shell).
|
|
61
99
|
* Security non-negotiable: NEVER use exec() or spawn({ shell: true }).
|
|
@@ -148,6 +186,54 @@ function createDockerUtil(options = {}) {
|
|
|
148
186
|
}
|
|
149
187
|
}
|
|
150
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Host ports a container publishes (`docker port <name>`), e.g.
|
|
191
|
+
* "8888/tcp -> 0.0.0.0:8888" and "8888/tcp -> [::]:8888" give [8888].
|
|
192
|
+
*
|
|
193
|
+
* Best-effort like findContainer: an unreachable daemon or an unknown
|
|
194
|
+
* container gives [], so the caller's port check stands as it was.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} name - Exact container name
|
|
197
|
+
* @returns {Promise<number[]>} unique host ports, in output order
|
|
198
|
+
*/
|
|
199
|
+
async function containerHostPorts(name) {
|
|
200
|
+
try {
|
|
201
|
+
const { stdout } = await docker(['port', String(name)]);
|
|
202
|
+
const ports = stdout.split('\n')
|
|
203
|
+
.map((line) => /->\s*\S*:(\d{1,5})\s*$/.exec(line.trim()))
|
|
204
|
+
.filter(Boolean)
|
|
205
|
+
.map((m) => Number(m[1]));
|
|
206
|
+
return [...new Set(ports)];
|
|
207
|
+
} catch {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The Compose project a container belongs to, by exact name (the
|
|
214
|
+
* `com.docker.compose.project` label). Returns '' for a container with no
|
|
215
|
+
* label, and null when no such container exists or docker is unreachable.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} name - Exact container name
|
|
218
|
+
* @returns {Promise<string|null>}
|
|
219
|
+
*/
|
|
220
|
+
async function containerProject(name) {
|
|
221
|
+
try {
|
|
222
|
+
// The name leads the output so that a container always prints a
|
|
223
|
+
// non-empty line, whatever its label.
|
|
224
|
+
const { stdout } = await docker([
|
|
225
|
+
'inspect', '--type', 'container',
|
|
226
|
+
'-f', '{{.Name}}\t{{index .Config.Labels "com.docker.compose.project"}}',
|
|
227
|
+
String(name),
|
|
228
|
+
]);
|
|
229
|
+
const line = stdout.trim().split('\n').filter(Boolean)[0];
|
|
230
|
+
if (!line) return null;
|
|
231
|
+
return (line.split('\t')[1] || '').trim();
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
151
237
|
/**
|
|
152
238
|
* Resolve which machine the Docker daemon actually runs on.
|
|
153
239
|
*
|
|
@@ -173,7 +259,7 @@ function createDockerUtil(options = {}) {
|
|
|
173
259
|
}
|
|
174
260
|
}
|
|
175
261
|
|
|
176
|
-
return { docker, composeUp, isContainerRunning, findContainer, getDockerHost };
|
|
262
|
+
return { docker, composeUp, isContainerRunning, findContainer, containerHostPorts, containerProject, getDockerHost };
|
|
177
263
|
}
|
|
178
264
|
|
|
179
|
-
module.exports = { createDockerUtil, parseDockerEndpoint, redactEndpoint };
|
|
265
|
+
module.exports = { createDockerUtil, parseDockerEndpoint, redactEndpoint, classifyDockerFailure };
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
# Bundled by @xns-cloud/relayer-mcp — OFFLINE FALLBACK for the released install.
|
|
2
|
-
# Source of truth: the
|
|
3
|
-
# https://releases.scpri.me/relayer/
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# the parity.
|
|
2
|
+
# Source of truth: the release channel bundle on the XNS releases registry —
|
|
3
|
+
# https://releases.scpri.me/relayer/release/docker-compose.yml and the .env
|
|
4
|
+
# beside it; the release publisher ships both. install_relayer fetches those URLs by
|
|
5
|
+
# default and only writes this copy when either fetch fails, so this file MUST
|
|
6
|
+
# keep service parity with the channel bundle: relayer + the monitoring stack
|
|
7
|
+
# (Prometheus + Grafana + node-exporter) that powers the dashboards under
|
|
8
|
+
# Monitoring in the web UI. The jest contract tests enforce the parity.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
10
|
+
# Every Relayer image comes from releases.scpri.me — never a Docker Hub fleet
|
|
11
|
+
# tag, which is not a release channel. The one allowed upstream image is
|
|
12
12
|
# prom/node-exporter (public, multi-arch, version-pinned — matches the channel
|
|
13
|
-
# bundle; nothing to rebuild).
|
|
13
|
+
# bundle; nothing to rebuild). No service mounts the host's Docker socket.
|
|
14
14
|
#
|
|
15
|
-
#
|
|
16
|
-
# Relayer agentically. Flip these tags to :stable-latest at general release.
|
|
15
|
+
# Pinned to the release-latest tag, the channel standalone Relayer customers install.
|
|
17
16
|
#
|
|
18
17
|
# A first-time user never hand-writes this file or the .env — install_relayer
|
|
19
18
|
# writes both.
|
|
@@ -30,14 +29,14 @@
|
|
|
30
29
|
# Other differences from the channel compose, by design:
|
|
31
30
|
# - SMB ports 139/445 are intentionally NOT exposed: 445 is held by Windows
|
|
32
31
|
# SMB on consumer hosts and would fail the install. S3 onboarding uses :9000.
|
|
33
|
-
# - pull_policy: always so `docker compose up -d` fetches the current
|
|
32
|
+
# - pull_policy: always so `docker compose up -d` fetches the current release
|
|
34
33
|
# images without a separate `docker compose pull` step.
|
|
35
34
|
services:
|
|
36
35
|
xns:
|
|
37
36
|
# container_name is load-bearing: the baked-in prometheus.yml scrapes the
|
|
38
37
|
# relayer by this name, and the install preflight keys on it.
|
|
39
38
|
container_name: xns-relayer
|
|
40
|
-
image: releases.scpri.me/xns-relayer:
|
|
39
|
+
image: releases.scpri.me/xns-relayer:release-latest
|
|
41
40
|
pull_policy: always
|
|
42
41
|
restart: unless-stopped
|
|
43
42
|
privileged: true # samba / fuse / disk management (matches channel compose)
|
|
@@ -53,14 +52,14 @@ services:
|
|
|
53
52
|
# Not host-exposed: Grafana is reached only through the relayer's /grafana
|
|
54
53
|
# reverse proxy and the in-network Prometheus scrape.
|
|
55
54
|
prometheus:
|
|
56
|
-
image: releases.scpri.me/relayer-prometheus:
|
|
55
|
+
image: releases.scpri.me/relayer-prometheus:release-latest
|
|
57
56
|
pull_policy: always
|
|
58
57
|
restart: unless-stopped
|
|
59
58
|
volumes:
|
|
60
59
|
- prometheus_data:/prometheus
|
|
61
60
|
|
|
62
61
|
grafana:
|
|
63
|
-
image: releases.scpri.me/relayer-grafana:
|
|
62
|
+
image: releases.scpri.me/relayer-grafana:release-latest
|
|
64
63
|
pull_policy: always
|
|
65
64
|
restart: unless-stopped
|
|
66
65
|
environment:
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const net = require('net');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
4
6
|
const { createHttpClient } = require('../lib/httpClient');
|
|
5
|
-
const { createDockerUtil, redactEndpoint } = require('../lib/dockerUtil');
|
|
7
|
+
const { createDockerUtil, redactEndpoint, classifyDockerFailure } = require('../lib/dockerUtil');
|
|
6
8
|
const { environmentProbe: defaultEnvironmentProbe } = require('../lib/environmentProbe');
|
|
7
9
|
|
|
10
|
+
// The one-command install (installs Docker, the compose plugin and the Relayer).
|
|
11
|
+
const INSTALL_COMMAND = 'curl -fsSL https://releases.scpri.me/relayer/install.sh | sh';
|
|
12
|
+
|
|
13
|
+
// The container the install script and install_relayer start.
|
|
14
|
+
const RELAYER_CONTAINER = 'xns-relayer';
|
|
15
|
+
|
|
16
|
+
// The Compose project the install script and install_relayer start the stack
|
|
17
|
+
// under, and the two monitoring containers the release compose names outright
|
|
18
|
+
// (container_name). A container with one of these names that belongs to some
|
|
19
|
+
// other project makes `docker compose up` fail with a name conflict.
|
|
20
|
+
const RELAYER_PROJECT = 'xns-relayer';
|
|
21
|
+
const FIXED_CONTAINER_NAMES = ['prometheus', 'alertmanager'];
|
|
22
|
+
|
|
23
|
+
// install_relayer's default install_path; the install script uses the same dir.
|
|
24
|
+
const DEFAULT_INSTALL_DIR = '/opt/xns-relayer';
|
|
25
|
+
|
|
26
|
+
// 10 GB in decimal bytes: fails at 10*10^9 - 1, passes at 10*10^9.
|
|
27
|
+
const MIN_FREE_BYTES = 10 * 10 ** 9;
|
|
28
|
+
const BYTES_PER_GB = 10 ** 9;
|
|
29
|
+
|
|
30
|
+
const GROUP_NOTE = 'the Docker socket refuses this user until the docker group applies (see docker_group)';
|
|
31
|
+
|
|
8
32
|
/**
|
|
9
33
|
* Tool 1: check_prerequisites
|
|
10
34
|
* Reports docker, ports, disk, and connectivity in plain English.
|
|
@@ -29,17 +53,193 @@ function checkPort(port) {
|
|
|
29
53
|
});
|
|
30
54
|
}
|
|
31
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Free space as "9.99 GB", rounded DOWN so a figure just under the threshold
|
|
58
|
+
* never prints as "10.00 GB".
|
|
59
|
+
*/
|
|
60
|
+
function formatGb(bytes) {
|
|
61
|
+
return `${(Math.floor(bytes / (BYTES_PER_GB / 100)) / 100).toFixed(2)} GB`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* statfs the nearest existing ancestor of `target` (the install dir usually
|
|
66
|
+
* does not exist before the install). Only ENOENT walks up; any other error
|
|
67
|
+
* propagates so the caller reports the leg as unreadable, never as passed.
|
|
68
|
+
*
|
|
69
|
+
* @returns {Promise<{path: string, freeBytes: number}>}
|
|
70
|
+
*/
|
|
71
|
+
async function freeBytesAt(statfs, target) {
|
|
72
|
+
let current = path.resolve(target);
|
|
73
|
+
for (;;) {
|
|
74
|
+
try {
|
|
75
|
+
const stats = await statfs(current);
|
|
76
|
+
return { path: current, freeBytes: Number(stats.bavail) * Number(stats.bsize) };
|
|
77
|
+
} catch (err) {
|
|
78
|
+
const parent = path.dirname(current);
|
|
79
|
+
if (err?.code !== 'ENOENT' || parent === current) throw err;
|
|
80
|
+
current = parent;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* True when /etc/group's docker line lists the user. An unreadable file reads
|
|
87
|
+
* as "not listed", which names the add-group command (safe either way).
|
|
88
|
+
*/
|
|
89
|
+
async function isInDockerGroup(readFile, username) {
|
|
90
|
+
try {
|
|
91
|
+
const groupFile = await readFile('/etc/group', 'utf8');
|
|
92
|
+
const line = String(groupFile).split('\n').find((l) => l.startsWith('docker:'));
|
|
93
|
+
if (!line) return false;
|
|
94
|
+
const members = (line.split(':')[3] || '').split(',').map((m) => m.trim());
|
|
95
|
+
return members.includes(username);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error(`[check_prerequisites] could not read /etc/group: ${err.message}`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
32
102
|
module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
33
103
|
const docker = options.dockerUtil || createDockerUtil(options);
|
|
34
104
|
const http = options.httpClient || createHttpClient(options);
|
|
35
105
|
const _checkPort = options.checkPort || checkPort;
|
|
36
106
|
const _environmentProbe = options.environmentProbe || defaultEnvironmentProbe;
|
|
107
|
+
const _statfs = options.statfs || require('fs').promises.statfs;
|
|
108
|
+
const _readFile = options.fs?.readFile || require('fs').promises.readFile;
|
|
109
|
+
const _userInfo = options.userInfo || os.userInfo;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* install_relayer is fresh-install only; an existing xns-relayer container
|
|
113
|
+
* (running or stopped, any channel) would fail it with a name conflict.
|
|
114
|
+
* A RUNNING one (e.g. the one the install script started) is ready to use,
|
|
115
|
+
* so its remediation never says to stop or remove it.
|
|
116
|
+
*/
|
|
117
|
+
async function checkExistingInstall(dockerState) {
|
|
118
|
+
if (dockerState === 'denied') {
|
|
119
|
+
return { name: 'existing_install', passed: true, skipped: true, detail: `Existing-install check skipped — ${GROUP_NOTE}.` };
|
|
120
|
+
}
|
|
121
|
+
let existing;
|
|
122
|
+
try {
|
|
123
|
+
existing = await docker.findContainer(RELAYER_CONTAINER);
|
|
124
|
+
} catch {
|
|
125
|
+
return { name: 'existing_install', passed: true, detail: 'Existing-install check skipped (Docker not reachable)' };
|
|
126
|
+
}
|
|
127
|
+
if (!existing) {
|
|
128
|
+
return { name: 'existing_install', passed: true, detail: 'No existing xns-relayer container — ready for a fresh install' };
|
|
129
|
+
}
|
|
130
|
+
const detail = `An existing 'xns-relayer' container was found (status: ${existing.status}; image: ${existing.image}).`;
|
|
131
|
+
if (existing.running) {
|
|
132
|
+
return {
|
|
133
|
+
name: 'existing_install',
|
|
134
|
+
passed: true,
|
|
135
|
+
warning: true,
|
|
136
|
+
detail,
|
|
137
|
+
remediation: 'This Relayer is already installed and running, and install_relayer performs fresh installs only, so skip install_relayer and continue onboarding with check_relayer_health against it.',
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
name: 'existing_install',
|
|
142
|
+
passed: true,
|
|
143
|
+
warning: true,
|
|
144
|
+
detail,
|
|
145
|
+
remediation: 'install_relayer performs fresh installs only. To replace the existing deployment: docker stop xns-relayer && docker rm xns-relayer (data directory is preserved), then install. To keep it, skip install_relayer and continue onboarding against the existing deployment.',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The remote Docker host a failed `docker info` was aimed at, or null when
|
|
151
|
+
* the daemon is local or the host cannot be resolved.
|
|
152
|
+
*/
|
|
153
|
+
async function remoteHostOf() {
|
|
154
|
+
try {
|
|
155
|
+
const raw = await docker.getDockerHost();
|
|
156
|
+
const host = typeof raw?.host === 'string' ? raw.host.trim() : '';
|
|
157
|
+
if (!raw?.remote || host === '' || host === 'localhost') return null;
|
|
158
|
+
return { remote: true, host, endpoint: redactEndpoint(raw.endpoint) };
|
|
159
|
+
} catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Containers named prometheus/alertmanager that are not this Relayer's. */
|
|
165
|
+
async function checkFixedNames(dockerState, dockerHost) {
|
|
166
|
+
const name = 'fixed_container_names';
|
|
167
|
+
if (dockerState !== 'ok' || dockerHost.remote) {
|
|
168
|
+
return { name, passed: true, skipped: true, detail: 'Container-name check skipped — Docker is not readable on this machine.' };
|
|
169
|
+
}
|
|
170
|
+
const foreign = [];
|
|
171
|
+
for (const containerName of FIXED_CONTAINER_NAMES) {
|
|
172
|
+
const project = await docker.containerProject(containerName);
|
|
173
|
+
if (project !== null && project !== RELAYER_PROJECT) foreign.push(containerName);
|
|
174
|
+
}
|
|
175
|
+
if (foreign.length === 0) {
|
|
176
|
+
return { name, passed: true, detail: 'No other container is named prometheus or alertmanager' };
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
name,
|
|
180
|
+
passed: false,
|
|
181
|
+
detail: `A container named ${foreign.join(' and ')} already exists and is not part of the Relayer; the Relayer needs those names`,
|
|
182
|
+
remediation: `Rename it (docker rename ${foreign[0]} ${foreign[0]}-old) or remove it, then re-run check_prerequisites.`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** One filesystem leg of the disk check. */
|
|
187
|
+
async function diskLeg(which, target) {
|
|
188
|
+
try {
|
|
189
|
+
const { path: fsPath, freeBytes } = await freeBytesAt(_statfs, target);
|
|
190
|
+
return { which, path: fsPath, free_bytes: freeBytes, passed: freeBytes >= MIN_FREE_BYTES };
|
|
191
|
+
} catch (err) {
|
|
192
|
+
console.error(`[check_prerequisites] statfs ${target} failed: ${err.message}`);
|
|
193
|
+
return { which, path: target, passed: true, skipped: true, detail: `Free space on the ${which} could not be read` };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The Docker root leg: only for a local daemon whose `docker info` answered. */
|
|
198
|
+
async function dockerRootLeg(dockerState, dockerHost) {
|
|
199
|
+
const which = 'Docker root';
|
|
200
|
+
if (dockerHost.remote) {
|
|
201
|
+
return { which, passed: true, skipped: true, detail: `Docker root check skipped — the Docker daemon runs on ${dockerHost.host}, so its disk must be checked there` };
|
|
202
|
+
}
|
|
203
|
+
if (dockerState !== 'ok') {
|
|
204
|
+
return { which, passed: true, skipped: true, detail: 'Docker root check skipped — docker info is not readable' };
|
|
205
|
+
}
|
|
206
|
+
let rootDir = '';
|
|
207
|
+
try {
|
|
208
|
+
const { stdout } = await docker.docker(['info', '--format', '{{.DockerRootDir}}']);
|
|
209
|
+
rootDir = String(stdout).trim();
|
|
210
|
+
} catch (err) {
|
|
211
|
+
console.error(`[check_prerequisites] docker info DockerRootDir failed: ${err.message}`);
|
|
212
|
+
}
|
|
213
|
+
if (!path.isAbsolute(rootDir)) {
|
|
214
|
+
return { which, passed: true, skipped: true, detail: 'Docker root check skipped — docker info gave no Docker root directory' };
|
|
215
|
+
}
|
|
216
|
+
return diskLeg(which, rootDir);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function checkDisk(dockerState, dockerHost) {
|
|
220
|
+
const filesystems = [
|
|
221
|
+
await dockerRootLeg(dockerState, dockerHost),
|
|
222
|
+
await diskLeg('install dir', DEFAULT_INSTALL_DIR),
|
|
223
|
+
];
|
|
224
|
+
const short = filesystems.filter((f) => !f.passed);
|
|
225
|
+
if (short.length === 0) {
|
|
226
|
+
return { name: 'disk', passed: true, detail: 'At least 10 GB is free on the Docker root and the install dir', filesystems };
|
|
227
|
+
}
|
|
228
|
+
const where = short.map((f) => `${formatGb(f.free_bytes)} free on the ${f.which} (${f.path})`).join(' and ');
|
|
229
|
+
return {
|
|
230
|
+
name: 'disk',
|
|
231
|
+
passed: false,
|
|
232
|
+
detail: `Not enough disk space: ${where}; the Relayer needs at least 10 GB free on each`,
|
|
233
|
+
remediation: `Free up space until at least 10 GB is free on ${short.map((f) => `${f.path} (${f.which})`).join(' and ')}, then re-run check_prerequisites. Check with: df -h ${short.map((f) => f.path).join(' ')}`,
|
|
234
|
+
filesystems,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
37
237
|
|
|
38
238
|
server.registerTool(
|
|
39
239
|
'check_prerequisites',
|
|
40
240
|
{
|
|
41
241
|
title: 'check_prerequisites',
|
|
42
|
-
description: 'Check system prerequisites for XNS Relayer installation: Docker
|
|
242
|
+
description: 'Check system prerequisites for XNS Relayer installation: Docker installed and its daemon running (local or remote via DOCKER_HOST / ssh:// context), the Docker compose plugin, docker group access for this user, required ports (8888, 9000, 9443; a port held by the running xns-relayer container passes), no container from another project named prometheus or alertmanager, an existing xns-relayer installation, at least 10 GB free on the Docker root and the install directory, 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
243
|
inputSchema: {
|
|
44
244
|
/* no parameters */
|
|
45
245
|
},
|
|
@@ -58,6 +258,9 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
58
258
|
// on another machine and the local checks below must adapt.
|
|
59
259
|
const DEFAULT_DOCKER_HOST = { remote: false, host: 'localhost', endpoint: null };
|
|
60
260
|
let dockerHost = DEFAULT_DOCKER_HOST;
|
|
261
|
+
// 'ok' | 'missing' (no docker CLI) | 'stopped' (daemon unreachable) |
|
|
262
|
+
// 'denied' (socket refuses this user: the daemon runs).
|
|
263
|
+
let dockerState = 'ok';
|
|
61
264
|
try {
|
|
62
265
|
await docker.docker(['info', '--format', '{{.ServerVersion}}']);
|
|
63
266
|
const raw = await docker.getDockerHost();
|
|
@@ -79,13 +282,109 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
79
282
|
: 'Docker is running',
|
|
80
283
|
});
|
|
81
284
|
} catch (err) {
|
|
285
|
+
// Missing is decided by the spawn code, never by message text:
|
|
286
|
+
// a daemon error can say "no such file or directory" too.
|
|
287
|
+
const remote = err?.code === 'ENOENT' ? null : await remoteHostOf();
|
|
288
|
+
if (err?.code === 'ENOENT') {
|
|
289
|
+
dockerState = 'missing';
|
|
290
|
+
allPassed = false;
|
|
291
|
+
checks.push({
|
|
292
|
+
name: 'docker',
|
|
293
|
+
passed: false,
|
|
294
|
+
detail: 'Docker is not installed on this machine',
|
|
295
|
+
remediation: `Run the one-command install, which installs Docker, the compose plugin and the Relayer: ${INSTALL_COMMAND} (Ubuntu 24.04 or Debian 12). To install on a different persistent machine, run this MCP on that machine (a Docker host with Node.js 20) rather than pointing at it remotely.`,
|
|
296
|
+
});
|
|
297
|
+
} else if (remote) {
|
|
298
|
+
// DECISION: a failing `docker info` against an ssh:// or tcp://
|
|
299
|
+
// DOCKER_HOST is a problem with that host, not with this user's
|
|
300
|
+
// docker group, and the daemon-stopped command would be run on
|
|
301
|
+
// the wrong machine. Name the host; the remote checks that
|
|
302
|
+
// follow (install_file_location, ports skipped) then apply.
|
|
303
|
+
dockerState = 'stopped';
|
|
304
|
+
dockerHost = remote;
|
|
305
|
+
allPassed = false;
|
|
306
|
+
checks.push({
|
|
307
|
+
name: 'docker',
|
|
308
|
+
passed: false,
|
|
309
|
+
detail: `The Docker daemon on ${remote.host} (via ${remote.endpoint}) could not be reached`,
|
|
310
|
+
remediation: `Check the connection and that Docker is running on ${remote.host}, and that your user there can use it (docker group on ${remote.host}, not on this machine). Or unset DOCKER_HOST / switch to the default Docker context to use this machine.`,
|
|
311
|
+
});
|
|
312
|
+
} else if (classifyDockerFailure(err)?.key === 'permission_denied') {
|
|
313
|
+
// The daemon answered and refused this user: Docker is fine,
|
|
314
|
+
// the docker_group check below carries the one failure.
|
|
315
|
+
dockerState = 'denied';
|
|
316
|
+
checks.push({
|
|
317
|
+
name: 'docker',
|
|
318
|
+
passed: true,
|
|
319
|
+
detail: 'Docker is installed and its daemon is running, but the Docker socket refuses this user',
|
|
320
|
+
});
|
|
321
|
+
} else {
|
|
322
|
+
dockerState = 'stopped';
|
|
323
|
+
allPassed = false;
|
|
324
|
+
checks.push({
|
|
325
|
+
name: 'docker',
|
|
326
|
+
passed: false,
|
|
327
|
+
detail: 'Docker is installed, but the Docker daemon is not running',
|
|
328
|
+
remediation: 'Start the Docker daemon: sudo systemctl start docker',
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 1a. Compose plugin. `docker compose version` needs no daemon, so it
|
|
334
|
+
// runs when the daemon is down or the socket refuses; only a missing
|
|
335
|
+
// docker CLI skips it (Docker-missing is then the one failure).
|
|
336
|
+
if (dockerState === 'missing') {
|
|
337
|
+
checks.push({ name: 'docker_compose', passed: true, skipped: true, detail: 'Compose plugin check skipped — Docker is not installed (the one-command install adds both)' });
|
|
338
|
+
} else {
|
|
339
|
+
try {
|
|
340
|
+
await docker.docker(['compose', 'version']);
|
|
341
|
+
checks.push({ name: 'docker_compose', passed: true, detail: 'The Docker compose plugin is installed' });
|
|
342
|
+
} catch {
|
|
343
|
+
allPassed = false;
|
|
344
|
+
checks.push({
|
|
345
|
+
name: 'docker_compose',
|
|
346
|
+
passed: false,
|
|
347
|
+
detail: 'The Docker compose plugin is missing',
|
|
348
|
+
remediation: "Install it from Docker's apt repository: sudo apt-get install docker-compose-plugin",
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// 1b. docker group. Decided by `docker info` itself: only a denied
|
|
354
|
+
// socket is a group problem (root and rootless Docker answer without
|
|
355
|
+
// the group). /etc/group then tells "not added" from "added, but this
|
|
356
|
+
// session predates it".
|
|
357
|
+
if (dockerState === 'denied') {
|
|
82
358
|
allPassed = false;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
359
|
+
// os.userInfo() throws when the UID has no passwd entry (arbitrary-UID
|
|
360
|
+
// containers); fall back to $USER rather than failing the whole tool.
|
|
361
|
+
// With no name at all, '$USER' goes into the command as written:
|
|
362
|
+
// the user's own shell expands it.
|
|
363
|
+
let username = process.env.USER || '$USER';
|
|
364
|
+
try {
|
|
365
|
+
username = _userInfo().username || username;
|
|
366
|
+
} catch (err) {
|
|
367
|
+
console.error(`[check_prerequisites] userInfo failed: ${err.message}`);
|
|
368
|
+
}
|
|
369
|
+
if (await isInDockerGroup(_readFile, username)) {
|
|
370
|
+
checks.push({
|
|
371
|
+
name: 'docker_group',
|
|
372
|
+
passed: false,
|
|
373
|
+
detail: `${username} is in the docker group, but this session started before the group was added, so the Docker socket still refuses it`,
|
|
374
|
+
remediation: 'Your session predates the group change: log out and back in (or reboot), then re-run check_prerequisites. Nothing needs reinstalling.',
|
|
375
|
+
});
|
|
376
|
+
} else {
|
|
377
|
+
checks.push({
|
|
378
|
+
name: 'docker_group',
|
|
379
|
+
passed: false,
|
|
380
|
+
detail: `${username} is not in the docker group, so the Docker socket refuses it`,
|
|
381
|
+
remediation: `Add yourself to the docker group: sudo usermod -aG docker ${username} — then log out and back in and re-run check_prerequisites.`,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
} else if (dockerState === 'ok') {
|
|
385
|
+
checks.push({ name: 'docker_group', passed: true, detail: 'This user can reach the Docker daemon' });
|
|
386
|
+
} else {
|
|
387
|
+
checks.push({ name: 'docker_group', passed: true, skipped: true, detail: 'Docker group check skipped — the Docker daemon is not reachable' });
|
|
89
388
|
}
|
|
90
389
|
|
|
91
390
|
// 1b. install_relayer refuses when the daemon is on another machine
|
|
@@ -108,8 +407,31 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
108
407
|
const requiredPorts = [
|
|
109
408
|
{ port: 8888, name: 'port_8888', service: 'the Relayer UI', inUseRemediation: 'Port 8888 is required for the Relayer UI. Stop the service using this port, or install with a different port via install_relayer ui_port.' },
|
|
110
409
|
{ port: 9000, name: 'port_9000', service: 'the S3 gateway', inUseRemediation: 'Port 9000 is required for the S3 gateway. Stop the service using this port (common conflict: another S3-compatible service), or install with a different port via install_relayer s3_port.' },
|
|
410
|
+
// The release compose publishes the S3 HTTPS port too. install_relayer
|
|
411
|
+
// has no parameter for it, so the only fix is to free it.
|
|
412
|
+
{ port: 9443, name: 'port_9443', service: 'the S3 HTTPS port', inUseRemediation: 'Port 9443 is required for the S3 HTTPS port. Stop the service using this port; install_relayer ui_port and s3_port do not move it.' },
|
|
111
413
|
];
|
|
414
|
+
// The install script leaves its own xns-relayer holding 8888/9000.
|
|
415
|
+
// Those ports are "in use" by the Relayer itself: a pass, not a
|
|
416
|
+
// conflict. Looked up once, only when a bind-probe finds a port held.
|
|
417
|
+
let ownPorts = null;
|
|
418
|
+
const relayerHostPorts = async () => {
|
|
419
|
+
if (ownPorts) return ownPorts;
|
|
420
|
+
ownPorts = [];
|
|
421
|
+
const container = await docker.findContainer(RELAYER_CONTAINER);
|
|
422
|
+
if (container?.running) {
|
|
423
|
+
// containerHostPorts answers [] on any docker failure.
|
|
424
|
+
ownPorts = await docker.containerHostPorts(RELAYER_CONTAINER);
|
|
425
|
+
}
|
|
426
|
+
return ownPorts;
|
|
427
|
+
};
|
|
112
428
|
for (const { port, name, inUseRemediation } of requiredPorts) {
|
|
429
|
+
if (dockerState === 'denied') {
|
|
430
|
+
// Who holds the port cannot be read through a refused socket,
|
|
431
|
+
// and right after the install script it is our own Relayer.
|
|
432
|
+
checks.push({ name, passed: true, skipped: true, detail: `Port ${port} check skipped — ${GROUP_NOTE}.` });
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
113
435
|
if (dockerHost.remote) {
|
|
114
436
|
checks.push({
|
|
115
437
|
name,
|
|
@@ -123,6 +445,8 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
123
445
|
const available = await _checkPort(port);
|
|
124
446
|
if (available) {
|
|
125
447
|
checks.push({ name, passed: true, detail: `Port ${port} is available` });
|
|
448
|
+
} else if (dockerState === 'ok' && (await relayerHostPorts()).includes(port)) {
|
|
449
|
+
checks.push({ name, passed: true, detail: `Port ${port} is in use by the running ${RELAYER_CONTAINER} container (this Relayer), which is expected` });
|
|
126
450
|
} else {
|
|
127
451
|
allPassed = false;
|
|
128
452
|
checks.push({ name, passed: false, detail: `Port ${port} is already in use`, remediation: inUseRemediation });
|
|
@@ -133,25 +457,14 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
133
457
|
}
|
|
134
458
|
}
|
|
135
459
|
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
passed: true,
|
|
145
|
-
warning: true,
|
|
146
|
-
detail: `An existing 'xns-relayer' container was found (status: ${existing.status}; image: ${existing.image}).`,
|
|
147
|
-
remediation: 'install_relayer performs fresh installs only. To replace the existing deployment: docker stop xns-relayer && docker rm xns-relayer (data directory is preserved), then install. To keep it, skip install_relayer and continue onboarding against the running deployment.',
|
|
148
|
-
});
|
|
149
|
-
} else {
|
|
150
|
-
checks.push({ name: 'existing_install', passed: true, detail: 'No existing xns-relayer container — ready for a fresh install' });
|
|
151
|
-
}
|
|
152
|
-
} catch {
|
|
153
|
-
checks.push({ name: 'existing_install', passed: true, detail: 'Existing-install check skipped (Docker not reachable)' });
|
|
154
|
-
}
|
|
460
|
+
// 3a. The release compose fixes the names prometheus and alertmanager.
|
|
461
|
+
// A container of that name from another Compose project stops the install.
|
|
462
|
+
const fixedNames = await checkFixedNames(dockerState, dockerHost);
|
|
463
|
+
if (!fixedNames.passed) allPassed = false;
|
|
464
|
+
checks.push(fixedNames);
|
|
465
|
+
|
|
466
|
+
// 3b. Existing installation — warn early, here.
|
|
467
|
+
checks.push(await checkExistingInstall(dockerState));
|
|
155
468
|
|
|
156
469
|
// 3c. Ephemeral environment — finding, never a failure.
|
|
157
470
|
try {
|
|
@@ -176,21 +489,17 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
176
489
|
checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Ephemeral-environment check skipped (probe error)' });
|
|
177
490
|
}
|
|
178
491
|
|
|
179
|
-
// 4. Disk space
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
} catch {
|
|
185
|
-
// If docker system df fails but docker info succeeded, still note it
|
|
186
|
-
checks.push({ name: 'disk', passed: true, detail: 'Disk check skipped (Docker storage stats unavailable)' });
|
|
187
|
-
}
|
|
492
|
+
// 4. Disk space: at least 10 GB free on BOTH the Docker root (images
|
|
493
|
+
// land there; often its own volume) and the install dir's filesystem.
|
|
494
|
+
const diskCheck = await checkDisk(dockerState, dockerHost);
|
|
495
|
+
if (!diskCheck.passed) allPassed = false;
|
|
496
|
+
checks.push(diskCheck);
|
|
188
497
|
|
|
189
498
|
// 5-6. Network connectivity
|
|
190
499
|
const connectivityChecks = [
|
|
191
500
|
{ url: 'https://console.xns.tech/health', name: 'connectivity_console', host: 'console.xns.tech' },
|
|
192
501
|
{ url: 'https://auth.xns.tech/auth/realms/scprime/.well-known/openid-configuration', name: 'connectivity_auth', host: 'auth.xns.tech' },
|
|
193
|
-
// The registry install_relayer pulls from (
|
|
502
|
+
// The registry install_relayer pulls from (release channel, anonymous).
|
|
194
503
|
// /v2/ is the registry version probe — 200 without credentials.
|
|
195
504
|
{ url: 'https://releases.scpri.me/v2/', name: 'connectivity_registry', host: 'releases.scpri.me' },
|
|
196
505
|
];
|
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
const { z } = require('zod');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const net = require('net');
|
|
6
|
-
const { createDockerUtil, redactEndpoint } = require('../lib/dockerUtil');
|
|
6
|
+
const { createDockerUtil, redactEndpoint, classifyDockerFailure } = 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
|
|
|
10
|
+
// A ports list item that uses ${BIND_ADDRESS...}; a comment naming it does not count.
|
|
11
|
+
const PORTS_USE_BIND_ADDRESS = /^[ \t]*-[^#\n]*\$\{BIND_ADDRESS\b/m;
|
|
12
|
+
|
|
13
|
+
/** What the response says about bind_address, per compose source. */
|
|
14
|
+
function bindAddressApplied(source, bindAddress) {
|
|
15
|
+
if (source === 'bundled-fallback') {
|
|
16
|
+
return 'yes — the bundled fallback compose references BIND_ADDRESS in its port declarations';
|
|
17
|
+
}
|
|
18
|
+
if (source === 'channel' && bindAddress) {
|
|
19
|
+
return 'yes — the channel compose references BIND_ADDRESS in its port declarations (checked before install)';
|
|
20
|
+
}
|
|
21
|
+
if (source === 'channel') {
|
|
22
|
+
return 'not needed — no bind_address was set, so ports are published on all interfaces';
|
|
23
|
+
}
|
|
24
|
+
return 'unknown — the compose_url compose may or may not reference BIND_ADDRESS in its port declarations; this installer does not read that file';
|
|
25
|
+
}
|
|
26
|
+
|
|
10
27
|
// R5 input boundary: this value is written verbatim into the .env the installer
|
|
11
28
|
// authors, and Compose auto-loads that file. An unvalidated newline injects
|
|
12
29
|
// further KEY=VALUE lines — including a second UI_PORT, which wins last-value
|
|
@@ -31,21 +48,27 @@ function isValidBindAddress(value) {
|
|
|
31
48
|
return false;
|
|
32
49
|
}
|
|
33
50
|
|
|
34
|
-
// Canonical released install — the full
|
|
51
|
+
// Canonical released install — the full release channel bundle (relayer +
|
|
35
52
|
// monitoring stack), published on the XNS releases registry and served
|
|
36
|
-
// login-free. THE default install source.
|
|
37
|
-
|
|
53
|
+
// login-free. THE default install source. Its .env (COMPOSE_PROFILES and the
|
|
54
|
+
// rest of the release settings) sits beside it and is fetched on every run.
|
|
55
|
+
const CHANNEL_COMPOSE_URL = 'https://releases.scpri.me/relayer/release/docker-compose.yml';
|
|
56
|
+
const CHANNEL_ENV_FILE = '.env';
|
|
38
57
|
|
|
39
58
|
// Bundled OFFLINE FALLBACK template (ships in the npm package; package.json
|
|
40
|
-
// `files: ["src/"]` covers it). Written only when the channel
|
|
59
|
+
// `files: ["src/"]` covers it). Written only when the channel compose or .env
|
|
60
|
+
// fetch fails;
|
|
41
61
|
// kept service-parity with the channel bundle by the jest contract tests.
|
|
42
62
|
const TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'docker-compose.yml');
|
|
43
63
|
|
|
44
64
|
// container_name in the bundled compose. Docker container names are unique
|
|
45
65
|
// per daemon, so ANY existing container with this name — running or stopped,
|
|
46
|
-
//
|
|
66
|
+
// any channel — makes `docker compose up` fail with a name conflict.
|
|
47
67
|
const CONTAINER_NAME = 'xns-relayer';
|
|
48
68
|
|
|
69
|
+
// Owner read/write only for the .env this tool writes.
|
|
70
|
+
const ENV_FILE_MODE = 0o600;
|
|
71
|
+
|
|
49
72
|
// The machine running this MCP and the machine running the Docker daemon can
|
|
50
73
|
// differ (DOCKER_HOST=ssh://..., tcp://..., or an ssh Docker context). This tool
|
|
51
74
|
// writes docker-compose.yml and .env on THIS machine, while compose up runs on
|
|
@@ -84,6 +107,76 @@ function safeError(message, cause) {
|
|
|
84
107
|
return Object.assign(new Error(message, { cause }), { userSafe: true });
|
|
85
108
|
}
|
|
86
109
|
|
|
110
|
+
const DOCKER_GROUP_SENTENCE = 'The Docker socket refused this user, so nothing was written and nothing was started. Add the user to the docker group (sudo usermod -aG docker $USER), then log out and back in (or reboot) and run install_relayer again.';
|
|
111
|
+
|
|
112
|
+
// Fixed sentences per classified Docker failure (dockerUtil FAILURE_PATTERNS).
|
|
113
|
+
// They never quote Docker's text: that goes to the server log only.
|
|
114
|
+
// port_in_use is not here: its sentence depends on the port (portSentence).
|
|
115
|
+
const FAILURE_SENTENCES = {
|
|
116
|
+
permission_denied: DOCKER_GROUP_SENTENCE,
|
|
117
|
+
daemon_stopped: 'Docker is not running on this machine. Start it with sudo systemctl start docker, then run install_relayer again.',
|
|
118
|
+
out_of_disk: 'Docker ran out of disk space while pulling the Relayer images. Free disk space on the filesystem holding the Docker root (docker info --format {{.DockerRootDir}} shows where it is), then run install_relayer again.',
|
|
119
|
+
pull_refused: 'The Relayer images could not be pulled from releases.scpri.me. Check that this machine reaches https://releases.scpri.me and that no stale registry login is stored (docker logout releases.scpri.me), then run install_relayer again.',
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// The release compose also publishes the S3 HTTPS port. No install_relayer
|
|
123
|
+
// parameter moves it.
|
|
124
|
+
const S3_TLS_PORT = 9443;
|
|
125
|
+
|
|
126
|
+
// Port in use: name the port, the parameter that moves it, and the leftover
|
|
127
|
+
// Created container compose leaves behind, which a retry would collide with.
|
|
128
|
+
function portSentence({ port }, { ui_port, s3_port }) {
|
|
129
|
+
const retry = `remove the leftover container with docker rm -f ${CONTAINER_NAME} and run install_relayer again`;
|
|
130
|
+
// DECISION: no new parameter for the 9443 port. Appending S3_TLS_PORT to the
|
|
131
|
+
// .env would fix one install only (the channel .env is re-fetched each run)
|
|
132
|
+
// and the schema has no other per-port knob for a port the Relayer does not
|
|
133
|
+
// serve plain traffic on. The sentence says to free it.
|
|
134
|
+
if (port === S3_TLS_PORT) return `Port ${port} (the S3 HTTPS port) is already in use on this machine. Free it, ui_port and s3_port do not move it, then ${retry}.`;
|
|
135
|
+
if (port === ui_port) return `Port ${port} is already in use on this machine. Free it or pass a different ui_port, then ${retry}.`;
|
|
136
|
+
if (port === s3_port) return `Port ${port} is already in use on this machine. Free it or pass a different s3_port, then ${retry}.`;
|
|
137
|
+
return `A port this install publishes is already in use on this machine. Free it or pass a different ui_port / s3_port, then ${retry}.`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// The client-facing reason for a caught failure: this file's own message when
|
|
141
|
+
// marked userSafe, a fixed cause sentence when Docker's stderr names one, else
|
|
142
|
+
// the generic line.
|
|
143
|
+
function failureReason(err, ports) {
|
|
144
|
+
if (err.userSafe) return err.message;
|
|
145
|
+
const cause = classifyDockerFailure(err);
|
|
146
|
+
if (cause?.key === 'port_in_use') return portSentence(cause, ports);
|
|
147
|
+
if (cause) return FAILURE_SENTENCES[cause.key];
|
|
148
|
+
return 'See server log for detail.';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function errorResponse(error) {
|
|
152
|
+
return {
|
|
153
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error }) }],
|
|
154
|
+
isError: true,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* True when `docker info` is refused by the socket's permissions. Any other
|
|
160
|
+
* outcome (success, daemon down, a mock without docker()) returns false and
|
|
161
|
+
* the install carries on as before; the later step reports its own cause.
|
|
162
|
+
*/
|
|
163
|
+
async function socketDenied(docker) {
|
|
164
|
+
if (!docker || typeof docker.docker !== 'function') return false;
|
|
165
|
+
try {
|
|
166
|
+
await docker.docker(['info', '--format', '{{.ServerVersion}}']);
|
|
167
|
+
return false;
|
|
168
|
+
} catch (err) {
|
|
169
|
+
console.error(`[install_relayer] docker info preflight: ${err.message}`);
|
|
170
|
+
return classifyDockerFailure(err)?.key === 'permission_denied';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Append the three port lines to a fetched .env, keeping every fetched line.
|
|
175
|
+
function withPortLines(fetchedEnv, portLines) {
|
|
176
|
+
if (fetchedEnv === '' || fetchedEnv.endsWith('\n')) return `${fetchedEnv}${portLines}`;
|
|
177
|
+
return `${fetchedEnv}\n${portLines}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
87
180
|
/**
|
|
88
181
|
* Tool 4: install_relayer
|
|
89
182
|
* AC-12: confirms "containers starting"; no manual shell.
|
|
@@ -91,11 +184,12 @@ function safeError(message, cause) {
|
|
|
91
184
|
*
|
|
92
185
|
* A first-time user has never heard of a Relayer and cannot supply a compose
|
|
93
186
|
* file or a .env. So by default this tool authors both for them: it fetches
|
|
94
|
-
* the CANONICAL channel bundle (relayer + Prometheus + Grafana +
|
|
95
|
-
* — the monitoring stack powers the dashboards under Monitoring
|
|
96
|
-
* and
|
|
97
|
-
*
|
|
98
|
-
*
|
|
187
|
+
* the CANONICAL release channel bundle (relayer + Prometheus + Grafana +
|
|
188
|
+
* node-exporter — the monitoring stack powers the dashboards under Monitoring
|
|
189
|
+
* in the web UI) and its .env, then appends the two ports and the bind address
|
|
190
|
+
* to that .env. If either fetch fails (offline, registry hiccup), the bundled
|
|
191
|
+
* service-parity template and a .env of just those lines are the fallback —
|
|
192
|
+
* the install still completes and the response says it fell back.
|
|
99
193
|
*
|
|
100
194
|
* `compose_url` stays as an optional override for internal/custom installs;
|
|
101
195
|
* when given, the old download-a-URL behavior is preserved.
|
|
@@ -105,12 +199,14 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
105
199
|
const _execFile = options.execFile;
|
|
106
200
|
const fsp = options.fs || require('fs').promises;
|
|
107
201
|
const channelComposeUrl = options.channelComposeUrl || CHANNEL_COMPOSE_URL;
|
|
202
|
+
// The .env lives beside the compose it configures.
|
|
203
|
+
const channelEnvUrl = new URL(CHANNEL_ENV_FILE, channelComposeUrl).href;
|
|
108
204
|
|
|
109
205
|
server.registerTool(
|
|
110
206
|
'install_relayer',
|
|
111
207
|
{
|
|
112
208
|
title: 'install_relayer',
|
|
113
|
-
description: 'Install and start the XNS Relayer. By default fetches the canonical
|
|
209
|
+
description: 'Install and start the XNS Relayer. By default fetches the canonical release channel bundle — relayer + the Prometheus/Grafana monitoring stack — and its .env from releases.scpri.me (anonymous pull), appends the ports to that .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 either fetch fails. A failure names its cause (port in use, image pull refused, Docker stopped, out of disk, Docker socket permission) and the command that fixes it. 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. When bind_address is set and the channel compose does not reference BIND_ADDRESS, the tool installs the bundled compose instead (source bundled-fallback, with a reason), because the bundled one honors it. A compose_url override is fetched remotely and may not honor it. 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.',
|
|
114
210
|
inputSchema: {
|
|
115
211
|
install_path: z.string().optional().default('/opt/xns-relayer').describe('Directory to install the compose file into'),
|
|
116
212
|
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.'),
|
|
@@ -118,7 +214,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
118
214
|
compose_url: z.string().url().optional().describe('OPTIONAL override: URL to a custom docker-compose.yml. Omit for the normal released install. When provided, bind_address is passed to docker compose via env but the downloaded compose must use the BIND_ADDRESS variable in its port declarations for it to take effect.'),
|
|
119
215
|
// R5 input boundary — see isValidBindAddress above for why each
|
|
120
216
|
// documented address form is validated whole rather than by charset.
|
|
121
|
-
bind_address: z.string().max(255).refine(isValidBindAddress, BIND_ADDRESS_HELP).optional().default('').describe('Host network interface for Docker port publication. Default: empty string (all interfaces — reachable from any machine on the LAN). Set to "127.0.0.1" for loopback-only access, or a specific interface IP to restrict reachability. Accepted forms: empty, an IPv4 address, or a bracketed IPv6 address (e.g. "[::1]"). Hostnames are rejected — the Compose ports host component is an IP address. This value is passed to docker compose via env, and on the channel and bundled-fallback paths it is also written into the .env this installer authors (the compose_url override path writes no .env). It is honored in the bundled fallback compose (which uses BIND_ADDRESS in its port declarations). On the default channel
|
|
217
|
+
bind_address: z.string().max(255).refine(isValidBindAddress, BIND_ADDRESS_HELP).optional().default('').describe('Host network interface for Docker port publication. Default: empty string (all interfaces — reachable from any machine on the LAN). Set to "127.0.0.1" for loopback-only access, or a specific interface IP to restrict reachability. Accepted forms: empty, an IPv4 address, or a bracketed IPv6 address (e.g. "[::1]"). Hostnames are rejected — the Compose ports host component is an IP address. This value is passed to docker compose via env, and on the channel and bundled-fallback paths it is also written into the .env this installer authors (the compose_url override path writes no .env). It is honored in the bundled fallback compose (which uses BIND_ADDRESS in its port declarations). On the default path the installer checks the fetched channel compose for BIND_ADDRESS and uses the bundled fallback compose when it is absent. On the compose_url path the fetched compose must reference the BIND_ADDRESS variable in its port declarations for the setting to take effect — this installer cannot verify that.'),
|
|
122
218
|
ui_tls_enabled: z.boolean().optional().default(false).describe('Whether the admin UI should listen on HTTPS in addition to HTTP. Default: false (off — HTTP only). NOT WIRED in this version: accepted but has no effect until a future release ships the TLS listener. Cost when enabled: requires a TLS certificate and key provisioned on the host.'),
|
|
123
219
|
s3_tls_enabled: z.boolean().optional().default(false).describe('Whether the S3 gateway should listen on HTTPS in addition to HTTP. Default: false (off — HTTP only). NOT WIRED in this version: accepted but has no effect until a future release ships the TLS listener. Cost when enabled: requires a TLS certificate and key provisioned on the host; S3 clients must be configured to use the HTTPS endpoint.'),
|
|
124
220
|
},
|
|
@@ -154,6 +250,13 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
154
250
|
};
|
|
155
251
|
}
|
|
156
252
|
|
|
253
|
+
// A socket that refuses this user would make the existing-install
|
|
254
|
+
// lookup below read "no container" and the install fail later at
|
|
255
|
+
// compose up. Name the cause now, before anything is written.
|
|
256
|
+
if (await socketDenied(docker)) {
|
|
257
|
+
return errorResponse(`Relayer installation failed: ${DOCKER_GROUP_SENTENCE}`);
|
|
258
|
+
}
|
|
259
|
+
|
|
157
260
|
// Preflight: install_relayer is for FRESH installs only — it does
|
|
158
261
|
// not upgrade an existing deployment in place. An existing
|
|
159
262
|
// container (running or stopped, any channel) owns the name and
|
|
@@ -182,38 +285,63 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
182
285
|
});
|
|
183
286
|
});
|
|
184
287
|
|
|
185
|
-
const
|
|
186
|
-
execFileFn('curl', ['-fsSL', '-o',
|
|
187
|
-
if (err) return reject(safeError(
|
|
288
|
+
const download = (url, outPath, what) => new Promise((resolve, reject) => {
|
|
289
|
+
execFileFn('curl', ['-fsSL', '-o', outPath, url], { timeout: 60000 }, (err) => {
|
|
290
|
+
if (err) return reject(safeError(`Failed to download ${what}`, err));
|
|
188
291
|
resolve();
|
|
189
292
|
});
|
|
190
293
|
});
|
|
294
|
+
const fetchCompose = (url) => download(url, composePath, 'compose file');
|
|
191
295
|
|
|
192
296
|
const bindPrefix = bind_address ? `${bind_address}:` : '';
|
|
193
297
|
let envContents = null;
|
|
194
298
|
let source;
|
|
195
299
|
let note;
|
|
300
|
+
let reason;
|
|
196
301
|
if (compose_url) {
|
|
197
302
|
// Override path: download a custom compose (execFile, no shell).
|
|
198
303
|
await fetchCompose(compose_url);
|
|
199
304
|
source = 'compose_url';
|
|
200
305
|
} else {
|
|
201
|
-
// Default path: fetch the canonical
|
|
202
|
-
// monitoring stack)
|
|
203
|
-
//
|
|
204
|
-
//
|
|
306
|
+
// Default path: fetch the canonical release bundle (relayer +
|
|
307
|
+
// monitoring stack) and its .env fresh on every run, then
|
|
308
|
+
// append the port lines to the fetched .env. Fall back to the
|
|
309
|
+
// bundled service-parity template and a .env of just the port
|
|
310
|
+
// lines when either fetch (or reading the fetched .env) fails.
|
|
311
|
+
// Either way the user never writes a file.
|
|
312
|
+
const portLines = `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`;
|
|
205
313
|
try {
|
|
206
314
|
await fetchCompose(channelComposeUrl);
|
|
315
|
+
// DECISION: the release compose has no BIND_ADDRESS in its
|
|
316
|
+
// ports, so a bind_address would be silently ignored and the
|
|
317
|
+
// ports published on all interfaces. Use the bundled compose,
|
|
318
|
+
// which honors it, and say so.
|
|
319
|
+
if (bind_address && !PORTS_USE_BIND_ADDRESS.test(await fsp.readFile(composePath, 'utf8'))) {
|
|
320
|
+
throw Object.assign(new Error('channel compose does not reference BIND_ADDRESS'), { bindUnsupported: true });
|
|
321
|
+
}
|
|
322
|
+
await download(channelEnvUrl, envPath, 'release .env');
|
|
323
|
+
// curl creates the file with the default umask; close it before
|
|
324
|
+
// any later step can throw and leave it world-readable.
|
|
325
|
+
await fsp.chmod(envPath, ENV_FILE_MODE);
|
|
326
|
+
envContents = withPortLines(await fsp.readFile(envPath, 'utf8'), portLines);
|
|
207
327
|
source = 'channel';
|
|
208
328
|
} catch (fetchErr) {
|
|
209
329
|
const template = await fsp.readFile(TEMPLATE_PATH, 'utf8');
|
|
210
330
|
await fsp.writeFile(composePath, template);
|
|
331
|
+
envContents = portLines;
|
|
211
332
|
source = 'bundled-fallback';
|
|
212
|
-
console.error(`[install_relayer] channel bundle fetch failed: ${fetchErr.cause
|
|
213
|
-
|
|
333
|
+
console.error(`[install_relayer] channel bundle fetch failed: ${fetchErr.message}${fetchErr.cause ? `: ${fetchErr.cause.message}` : ''}`);
|
|
334
|
+
if (fetchErr.bindUnsupported) {
|
|
335
|
+
reason = 'The release channel compose does not support bind_address, so the bundled compose, which does, was used. Same services.';
|
|
336
|
+
} else {
|
|
337
|
+
reason = 'Channel bundle fetch failed.';
|
|
338
|
+
note = 'Channel bundle fetch failed — fell back to the bundled compose. Same services; re-running install later is not required.';
|
|
339
|
+
}
|
|
214
340
|
}
|
|
215
|
-
|
|
216
|
-
|
|
341
|
+
// The .env holds webhook/SMTP secrets: owner-only. The mode on
|
|
342
|
+
// writeFile covers a new file; chmod covers the one curl made.
|
|
343
|
+
await fsp.writeFile(envPath, envContents, { mode: ENV_FILE_MODE });
|
|
344
|
+
await fsp.chmod(envPath, ENV_FILE_MODE);
|
|
217
345
|
}
|
|
218
346
|
|
|
219
347
|
// Run docker compose up -d. cwd + env so ${UI_PORT}/${S3_PORT}
|
|
@@ -233,6 +361,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
233
361
|
compose_path: composePath,
|
|
234
362
|
install_path,
|
|
235
363
|
source,
|
|
364
|
+
...(reason ? { reason } : {}),
|
|
236
365
|
// D5/W5: state the binding at install time, out-of-band, so a
|
|
237
366
|
// refused connection is explainable later. Two statements, never
|
|
238
367
|
// merged (PRD §7): `composed_from` is what this installer asserts
|
|
@@ -247,9 +376,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
247
376
|
// behind (correct-or-absent, same rule as the port readout).
|
|
248
377
|
binding: {
|
|
249
378
|
bind_address: bind_address || '0.0.0.0 (all interfaces)',
|
|
250
|
-
bind_address_applied: source
|
|
251
|
-
? 'yes — the bundled fallback compose references BIND_ADDRESS in its port declarations'
|
|
252
|
-
: 'unknown — the fetched compose may or may not reference BIND_ADDRESS in its port declarations; this installer does not read the fetched file',
|
|
379
|
+
bind_address_applied: bindAddressApplied(source, bind_address),
|
|
253
380
|
ui: { host_port: ui_port, container_port: compose_url ? null : 8888 },
|
|
254
381
|
s3: { host_port: s3_port, container_port: compose_url ? null : 9000 },
|
|
255
382
|
composed_from: compose_url
|
|
@@ -267,16 +394,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
267
394
|
};
|
|
268
395
|
} catch (err) {
|
|
269
396
|
console.error(`[install_relayer] ${err.message}${err.cause ? `: ${err.cause.message}` : ''}`);
|
|
270
|
-
return {
|
|
271
|
-
content: [{
|
|
272
|
-
type: 'text',
|
|
273
|
-
text: JSON.stringify({
|
|
274
|
-
success: false,
|
|
275
|
-
error: `Relayer installation failed: ${err.userSafe ? err.message : 'See server log for detail.'}`,
|
|
276
|
-
}),
|
|
277
|
-
}],
|
|
278
|
-
isError: true,
|
|
279
|
-
};
|
|
397
|
+
return errorResponse(`Relayer installation failed: ${failureReason(err, { ui_port, s3_port })}`);
|
|
280
398
|
}
|
|
281
399
|
},
|
|
282
400
|
);
|