@xns-cloud/relayer-mcp 0.10.0 → 0.10.2
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 +63 -0
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/src/tools/checkPrerequisites.js +22 -2
- package/src/tools/installRelayer.js +129 -4
package/README.md
CHANGED
|
@@ -45,6 +45,66 @@ docker context use relayer
|
|
|
45
45
|
|
|
46
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.
|
|
47
47
|
|
|
48
|
+
**Know the tradeoff before you take this path.** With an SSH context the containers start on the remote host and the data lives in Docker volumes there, but `install_relayer` writes `docker-compose.yml` and `.env` on the machine running the MCP — not on the Docker host. That is fine for the install and fine for your data; it is not fine for day 2. Restarting, changing ports, and upgrading from the Docker host all need a compose file that host does not have. From an ephemeral sandbox it is worse: the only copy of those files exits with the sandbox, leaving a running Relayer nobody can administer.
|
|
49
|
+
|
|
50
|
+
`check_prerequisites` warns about this before anything is written, and `install_relayer` returns an `action_required` field plus a `move_files` block carrying the source machine and path, the destination machine and path, the Docker endpoint it detected, where the compose file came from, and the contents of the env file it wrote. Either run the MCP on the Docker host, or [move the install directory across](#moving-the-install-files-to-the-docker-host) as soon as the install finishes.
|
|
51
|
+
|
|
52
|
+
### Moving the install files to the Docker host
|
|
53
|
+
|
|
54
|
+
The MCP does **not** generate a copy command for you. Getting one right means guessing your scp version, shell, ssh port, bastion, sudo policy and path, and a wrong command that looks right is worse than no command. Below are three worked examples covering the common shapes — take the one that matches your setup and substitute the values from `move_files`.
|
|
55
|
+
|
|
56
|
+
Three things to know before you adapt any of them:
|
|
57
|
+
|
|
58
|
+
- **Keep the same directory name on both machines.** Compose takes the project name from the directory it runs in, and volume names are prefixed with it. Land the files in `/srv/relayer` instead of `/opt/xns-relayer` and `docker compose` there is a *different project*: it will not see the running containers, and `docker compose up` would create a second set of empty volumes and then fail, because `container_name: xns-relayer` is pinned in the compose file and that name is already taken. You get a `409 Conflict` rather than a working Relayer, plus stray empty volumes to clean up. Use the last path segment from `move_files.destination_path`. Keeping the whole path identical is safest — a compose file that binds a relative host path resolves it against the project directory.
|
|
59
|
+
- **Copy to the parent directory.** `scp -r /opt/xns-relayer host:/opt/xns-relayer` copies *into* an existing target, leaving the files at `/opt/xns-relayer/xns-relayer/` where `docker compose` will not find them.
|
|
60
|
+
- **`/opt` needs root.** If your ssh user cannot write the destination, create it first — `scp` will not create a missing parent.
|
|
61
|
+
|
|
62
|
+
**1 — SSH Docker context, default path.** The common case.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
ssh -t user@docker-box 'sudo install -d -o $USER /opt/xns-relayer'
|
|
66
|
+
scp -r /opt/xns-relayer user@docker-box:/opt
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**2 — Non-standard ssh port, or the Docker host behind a bastion.** Note `ssh` takes `-p` for the port and `scp` takes `-P`; `-J` is the jump host.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
ssh -t -p 2222 user@docker-box 'sudo install -d -o $USER /opt/xns-relayer'
|
|
73
|
+
scp -P 2222 -r /opt/xns-relayer user@docker-box:/opt
|
|
74
|
+
|
|
75
|
+
# via a bastion — the prepare step needs the same -J
|
|
76
|
+
ssh -t -J user@bastion user@docker-box 'sudo install -d -o $USER /opt/xns-relayer'
|
|
77
|
+
scp -J user@bastion -r /opt/xns-relayer user@docker-box:/opt
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**3 — No ssh route from this machine.** A `tcp://` Docker context, a key only the Docker CLI can use, or a locked-down sandbox. There are only two small files, so recreate them on the Docker host by hand.
|
|
81
|
+
|
|
82
|
+
Check `move_files.compose_source` in the response first — it tells you where your compose file came from, and the three cases need different handling:
|
|
83
|
+
|
|
84
|
+
| `compose_source` | Where to get `docker-compose.yml` |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `channel` | `curl -fsSLO <compose_url>`, using the URL from `move_files.compose_url` |
|
|
87
|
+
| `bundled-fallback` | It came from inside the npm package on the MCP machine, not from a URL. Copy that one file across by any means you have — a clipboard paste is fine, it is a few dozen lines. |
|
|
88
|
+
| `compose_url` | Your own custom compose, from wherever you supplied it. |
|
|
89
|
+
|
|
90
|
+
Then, in a directory whose **last path segment matches** `move_files.destination_path`:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# on the Docker host
|
|
94
|
+
sudo install -d -o $USER /opt/xns-relayer
|
|
95
|
+
cd /opt/xns-relayer
|
|
96
|
+
# put docker-compose.yml here per the table above, then write the env file:
|
|
97
|
+
printf 'UI_PORT=8888\nS3_PORT=9000\nBIND_ADDRESS=\n' > .env
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use the values from `move_files.env_contents`, not the defaults above, if you installed with custom ports or a bind address. If `env_contents` is `null` the install wrote no env file (the `compose_url` path) — your compose file supplies its own values, or you export them before `docker compose up`.
|
|
101
|
+
|
|
102
|
+
Verify from the Docker host afterwards — this should list the running services rather than an error about a missing configuration file, and should show the containers that are *already up*, not propose new ones:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
cd /opt/xns-relayer && docker compose ps
|
|
106
|
+
```
|
|
107
|
+
|
|
48
108
|
## Install
|
|
49
109
|
|
|
50
110
|
**Claude Code** (one command):
|
|
@@ -148,6 +208,7 @@ The MCP detects this automatically (it honors `DOCKER_HOST` and the active Docke
|
|
|
148
208
|
- `install_relayer` runs `docker compose` against the remote daemon.
|
|
149
209
|
- `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
210
|
- `check_prerequisites` skips the local port-availability probes (the containers bind ports on the remote host) and reports them as skipped with instructions.
|
|
211
|
+
- `check_prerequisites` also raises an `install_file_location` warning, and `install_relayer` returns `action_required` plus a `file_location` block naming both machines — because the install files are written on the management node while the containers run on the Docker host. See [Environment](#environment) for what to do about it.
|
|
151
212
|
|
|
152
213
|
`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
214
|
|
|
@@ -159,6 +220,8 @@ The MCP detects this automatically (it honors `DOCKER_HOST` and the active Docke
|
|
|
159
220
|
| `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
221
|
| 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
222
|
| 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 |
|
|
223
|
+
| `docker compose` on the Docker host says no configuration file found, after a successful install | The MCP ran on another machine, so the compose and env files were written there | [Moving the install files to the Docker host](#moving-the-install-files-to-the-docker-host), or reinstall with the MCP running on the Docker host |
|
|
224
|
+
| `install_relayer` fails with "Failed to create directory … on this machine" | The install path needs root on the machine running the MCP (common on macOS/Windows workstations for paths under `/opt`) | Pass a writable `install_path`, or run the MCP on the Docker host |
|
|
162
225
|
|
|
163
226
|
## Authentication
|
|
164
227
|
|
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.
|
|
5
|
+
"version": "0.10.2",
|
|
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.
|
|
4
|
+
"version": "0.10.2",
|
|
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",
|
|
@@ -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 reports where install_relayer will write its files: on a remote Docker daemon the files land on this machine while the containers run on the remote host, raised as an install_file_location warning. Run this first before any other relayer tool.',
|
|
43
43
|
inputSchema: {
|
|
44
44
|
/* no parameters */
|
|
45
45
|
},
|
|
@@ -88,6 +88,26 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// 1b. WHERE the install files will land. This is the last point at
|
|
92
|
+
// which the user can still choose to run the MCP on the Docker host
|
|
93
|
+
// instead — install_relayer writes its docker-compose.yml and .env
|
|
94
|
+
// with local mkdir/curl/fs while starting the containers remotely,
|
|
95
|
+
// so on a remote daemon the deployment and the files that define it
|
|
96
|
+
// end up on different machines. Nothing is lost (named volumes keep
|
|
97
|
+
// the data on the Docker host), but nobody can restart, re-port, or
|
|
98
|
+
// upgrade it from the Docker host without those files — and if this
|
|
99
|
+
// machine is a sandbox, the only copy dies with it. Say so BEFORE a
|
|
100
|
+
// file is written, not in the success payload afterwards.
|
|
101
|
+
if (dockerHost.remote) {
|
|
102
|
+
checks.push({
|
|
103
|
+
name: 'install_file_location',
|
|
104
|
+
passed: true,
|
|
105
|
+
warning: true,
|
|
106
|
+
detail: `install_relayer runs on THIS machine and writes docker-compose.yml and .env here, but the Docker daemon is on ${dockerHost.host} — so the containers and the files that define them will end up on different machines. The install itself works and the data is safe (Docker named volumes on ${dockerHost.host}); what will not work is restarting, changing ports, or upgrading from ${dockerHost.host}, because that host has no compose file.`,
|
|
107
|
+
remediation: `Preferred: run the MCP on ${dockerHost.host} itself (install Node.js 20 there and point your MCP client at it) so the files and the containers stay together. Otherwise install from here and move the install directory to ${dockerHost.host} immediately afterwards, before you need to restart or upgrade — see "Moving the install files to the Docker host" in the relayer-mcp README for worked examples. If this machine is a sandbox, CI runner, or throwaway VM, move them before the session ends: the only copy of your compose file leaves with it.`
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
// 2-3. Required ports. The bind-probe runs on THIS machine — when
|
|
92
112
|
// the Docker daemon is remote, the containers (and their port
|
|
93
113
|
// bindings) live on the remote host, so a local probe would test
|
|
@@ -153,7 +173,7 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
153
173
|
? `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
174
|
: `This environment appears to be ephemeral (${probe.signals.join('; ')}). A Relayer installed here will be lost when the container exits.`,
|
|
155
175
|
remediation: remoteDocker
|
|
156
|
-
?
|
|
176
|
+
? `The Relayer will be installed on the remote Docker host — verify that host has persistent storage. Note also that install_relayer writes docker-compose.yml and .env HERE, in this ephemeral environment, not on ${dockerHost.host}. Move them to ${dockerHost.host} straight after the install or they are gone when this environment exits, leaving a running deployment nobody can restart or upgrade.`
|
|
157
177
|
: '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',
|
|
158
178
|
});
|
|
159
179
|
} else {
|
|
@@ -46,6 +46,45 @@ 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 are
|
|
50
|
+
// routinely NOT the same one. Claude Desktop and Cursor run on a workstation;
|
|
51
|
+
// the disks live on a server. Our own README steers ephemeral-sandbox users to
|
|
52
|
+
// an ssh:// Docker context, and check_prerequisites' remediation text says the
|
|
53
|
+
// same. In that configuration every file this tool writes (mkdir, curl, the
|
|
54
|
+
// .env) lands HERE while composeUp starts the containers THERE.
|
|
55
|
+
//
|
|
56
|
+
// The install still works: the compose uses named volumes, so the data lives on
|
|
57
|
+
// the Docker host and nothing is lost. What breaks is day 2 — restart, port
|
|
58
|
+
// change, upgrade all need a compose file that is not on the machine running
|
|
59
|
+
// the containers, and if this machine is a sandbox it takes the only copy with
|
|
60
|
+
// it. Reporting a single install_path hides that, so the response names both
|
|
61
|
+
// machines instead.
|
|
62
|
+
const LOCAL_DOCKER_HOST = Object.freeze({ remote: false, host: 'localhost', endpoint: null });
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Resolve which machine the Docker daemon runs on, defensively.
|
|
66
|
+
*
|
|
67
|
+
* Advisory only — this must NEVER be the reason an install fails, so a missing
|
|
68
|
+
* helper, a throwing helper, or incomplete metadata all fall back to local.
|
|
69
|
+
* "remote" without a nameable host is incomplete metadata, not a remote
|
|
70
|
+
* install; checkPrerequisites applies the same rule and we must not warn about
|
|
71
|
+
* a machine we cannot name.
|
|
72
|
+
*/
|
|
73
|
+
async function resolveDockerHost(docker) {
|
|
74
|
+
if (!docker || typeof docker.getDockerHost !== 'function') return LOCAL_DOCKER_HOST;
|
|
75
|
+
try {
|
|
76
|
+
const raw = await docker.getDockerHost();
|
|
77
|
+
const host = typeof raw?.host === 'string' ? raw.host.trim() : '';
|
|
78
|
+
const endpoint = raw?.endpoint ?? null;
|
|
79
|
+
// Report the endpoint even when local — check_prerequisites does, and a
|
|
80
|
+
// response saying "local" with no endpoint reads like detection failed.
|
|
81
|
+
if (!raw?.remote || host === '' || host === 'localhost') return { ...LOCAL_DOCKER_HOST, endpoint };
|
|
82
|
+
return { remote: true, host, endpoint };
|
|
83
|
+
} catch {
|
|
84
|
+
return LOCAL_DOCKER_HOST;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
49
88
|
/**
|
|
50
89
|
* Tool 4: install_relayer
|
|
51
90
|
* AC-12: confirms "containers starting"; no manual shell.
|
|
@@ -72,7 +111,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
72
111
|
'install_relayer',
|
|
73
112
|
{
|
|
74
113
|
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.',
|
|
114
|
+
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, but starts the containers on whichever machine the Docker daemon is on. With DOCKER_HOST or an ssh:// Docker context those are different machines. The install works and the data is safe (Docker named volumes on the Docker host), but the deployment cannot be restarted, re-ported, or upgraded from the Docker host until those files are copied there. When it detects a remote daemon the response leads with an action_required field, file_location names both machines, and move_files carries the source and destination plus the env-file contents. This tool deliberately does NOT generate a copy command — the correct one depends on the scp version, shell, ssh port, bastion and sudo policy in use, and a wrong command that looks right is worse than none; the README section named in the response has worked examples for the common setups. Surface action_required to the user verbatim — do not summarize it away.\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
115
|
inputSchema: {
|
|
77
116
|
install_path: z.string().optional().default('/opt/xns-relayer').describe('Directory to install the compose file into'),
|
|
78
117
|
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 +136,13 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
97
136
|
const composePath = path.join(install_path, 'docker-compose.yml');
|
|
98
137
|
const envPath = path.join(install_path, '.env');
|
|
99
138
|
|
|
139
|
+
// Resolved before the first write so every message below — the
|
|
140
|
+
// mkdir error included — can name the right machine.
|
|
141
|
+
const dockerHost = await resolveDockerHost(docker);
|
|
142
|
+
const localDesc = dockerHost.remote
|
|
143
|
+
? `this machine (the one running the MCP, NOT the Docker host ${dockerHost.host})`
|
|
144
|
+
: 'this machine';
|
|
145
|
+
|
|
100
146
|
// Preflight: install_relayer is for FRESH installs only — it does
|
|
101
147
|
// not upgrade an existing deployment in place. An existing
|
|
102
148
|
// container (running or stopped, any channel) owns the name and
|
|
@@ -120,7 +166,10 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
120
166
|
// Create install directory (execFile, no shell)
|
|
121
167
|
await new Promise((resolve, reject) => {
|
|
122
168
|
execFileFn('mkdir', ['-p', install_path], {}, (err) => {
|
|
123
|
-
|
|
169
|
+
// mkdir runs HERE, not on the Docker host. On a workstation
|
|
170
|
+
// driving a remote daemon, /opt needs root and this is the
|
|
171
|
+
// first thing that fails — so name the machine that refused.
|
|
172
|
+
if (err) return reject(new Error(`Failed to create directory ${install_path} on ${localDesc}: ${err.message}`));
|
|
124
173
|
resolve();
|
|
125
174
|
});
|
|
126
175
|
});
|
|
@@ -133,6 +182,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
133
182
|
});
|
|
134
183
|
|
|
135
184
|
const bindPrefix = bind_address ? `${bind_address}:` : '';
|
|
185
|
+
let envContents = null;
|
|
136
186
|
let source;
|
|
137
187
|
let note;
|
|
138
188
|
if (compose_url) {
|
|
@@ -153,7 +203,8 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
153
203
|
source = 'bundled-fallback';
|
|
154
204
|
note = `Channel bundle fetch failed (${fetchErr.message}) — fell back to the bundled compose. Same services; re-running install later is not required.`;
|
|
155
205
|
}
|
|
156
|
-
|
|
206
|
+
envContents = `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`;
|
|
207
|
+
await fsp.writeFile(envPath, envContents);
|
|
157
208
|
}
|
|
158
209
|
|
|
159
210
|
// Run docker compose up -d. cwd + env so ${UI_PORT}/${S3_PORT}
|
|
@@ -164,14 +215,88 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
164
215
|
env: { ...process.env, UI_PORT: String(ui_port), S3_PORT: String(s3_port), BIND_ADDRESS: bindPrefix },
|
|
165
216
|
});
|
|
166
217
|
|
|
218
|
+
// Two machines, two statements — never one install_path that is
|
|
219
|
+
// only true on one of them. `action_required` leads the payload
|
|
220
|
+
// when they differ so an agent relaying this cannot bury it.
|
|
221
|
+
const fileLocation = {
|
|
222
|
+
same_machine: !dockerHost.remote,
|
|
223
|
+
files_written_on: dockerHost.remote
|
|
224
|
+
? 'this machine — the one running the MCP, NOT the Docker host'
|
|
225
|
+
: 'this machine (which is also the Docker host)',
|
|
226
|
+
docker_host: dockerHost.remote ? dockerHost.host : 'localhost',
|
|
227
|
+
docker_endpoint: dockerHost.endpoint,
|
|
228
|
+
containers_running_on: dockerHost.remote ? dockerHost.host : 'this machine',
|
|
229
|
+
data_stored_on: dockerHost.remote
|
|
230
|
+
? `${dockerHost.host} — Docker named volumes on the Docker host; no Relayer data is stored on this machine`
|
|
231
|
+
: 'this machine — Docker named volumes',
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// Deliberately no generated shell command here. Getting one right
|
|
235
|
+
// means guessing the user's scp version, shell, ssh port, bastion,
|
|
236
|
+
// sudo policy and path — and a wrong command that looks right is
|
|
237
|
+
// worse than none. State the facts instead and point at the
|
|
238
|
+
// worked examples in the README, which a person can match to
|
|
239
|
+
// their own setup. `move_files` carries enough to rebuild the
|
|
240
|
+
// install by hand when there is no ssh route at all — but only
|
|
241
|
+
// `compose_source` tells the user WHICH of the three recovery
|
|
242
|
+
// paths applies, and on the compose_url path there is no env
|
|
243
|
+
// file to hand back because none was written.
|
|
244
|
+
const actionRequired = dockerHost.remote
|
|
245
|
+
? `The Relayer is running on ${dockerHost.host}, but the files that define it are NOT. `
|
|
246
|
+
+ `${envContents ? 'docker-compose.yml and the env file were' : 'docker-compose.yml was'} written to ${install_path} on this machine; `
|
|
247
|
+
+ `${dockerHost.host} has no copy. Your data is safe — it is in Docker volumes on ${dockerHost.host}. `
|
|
248
|
+
+ `What does not work until you fix this: restarting, changing ports, or upgrading from `
|
|
249
|
+
+ `${dockerHost.host}, because "docker compose" there has no file to read. `
|
|
250
|
+
+ `Move them now, not later — if this machine is a sandbox, CI runner, or throwaway VM, before the session ends. `
|
|
251
|
+
+ `Keep the same directory name — compose takes its project name from it, so a differently-named `
|
|
252
|
+
+ `directory starts a new project that creates empty volumes and then fails on the pinned `
|
|
253
|
+
+ `xns-relayer container name. `
|
|
254
|
+
+ `See "Moving the install files to the Docker host" in the relayer-mcp README for worked examples covering `
|
|
255
|
+
+ `an ssh Docker context, a non-standard port or bastion, and a host you cannot ssh to from here. `
|
|
256
|
+
+ `Better long-term: run this MCP on ${dockerHost.host} so the files and the containers stay together.`
|
|
257
|
+
: null;
|
|
258
|
+
|
|
167
259
|
return {
|
|
168
260
|
content: [{
|
|
169
261
|
type: 'text',
|
|
170
262
|
text: JSON.stringify({
|
|
171
263
|
success: true,
|
|
172
|
-
|
|
264
|
+
...(actionRequired ? { action_required: actionRequired } : {}),
|
|
265
|
+
message: dockerHost.remote
|
|
266
|
+
? `XNS Relayer containers are starting on ${dockerHost.host}. Read action_required before continuing — the install files were written on this machine, not on ${dockerHost.host}. Use check_relayer_health to monitor when all services are ready.`
|
|
267
|
+
: 'XNS Relayer containers are starting. Use check_relayer_health to monitor when all services are ready.',
|
|
173
268
|
compose_path: composePath,
|
|
174
269
|
install_path,
|
|
270
|
+
file_location: fileLocation,
|
|
271
|
+
...(dockerHost.remote ? {
|
|
272
|
+
move_files: {
|
|
273
|
+
source_machine: 'this machine (the one running the MCP)',
|
|
274
|
+
source_path: install_path,
|
|
275
|
+
destination_machine: dockerHost.host,
|
|
276
|
+
// The last path segment is load-bearing: compose derives
|
|
277
|
+
// the project name from it and prefixes volume names with
|
|
278
|
+
// it, so a differently-named directory on the Docker host is
|
|
279
|
+
// a different project. It creates a second set of empty
|
|
280
|
+
// volumes and then fails, because container_name is pinned
|
|
281
|
+
// to xns-relayer and that name is already taken — a 409, not
|
|
282
|
+
// a silent wrong start. Same directory name on both machines.
|
|
283
|
+
destination_path: install_path,
|
|
284
|
+
docker_endpoint: dockerHost.endpoint,
|
|
285
|
+
files: envContents ? ['docker-compose.yml', '.env'] : ['docker-compose.yml'],
|
|
286
|
+
// Which of the three recovery paths in the README applies.
|
|
287
|
+
// 'bundled-fallback' is the one with no URL to fetch — that
|
|
288
|
+
// compose came out of the npm package on THIS machine, so
|
|
289
|
+
// the file itself has to travel.
|
|
290
|
+
compose_source: source,
|
|
291
|
+
compose_url: source === 'channel' ? channelComposeUrl
|
|
292
|
+
: source === 'compose_url' ? compose_url
|
|
293
|
+
: null,
|
|
294
|
+
// null on the compose_url path: no env file is written
|
|
295
|
+
// there, so there is nothing to hand back.
|
|
296
|
+
env_contents: envContents,
|
|
297
|
+
readme_section: 'Moving the install files to the Docker host',
|
|
298
|
+
},
|
|
299
|
+
} : {}),
|
|
175
300
|
source,
|
|
176
301
|
// D5/W5: state the binding at install time, out-of-band, so a
|
|
177
302
|
// refused connection is explainable later. Two statements, never
|