@xns-cloud/relayer-mcp 0.11.1 → 0.13.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/PRIVACY.md +14 -8
- package/README.md +66 -19
- package/manifest.json +5 -6
- package/package.json +3 -5
- package/src/index.js +4 -2
- package/src/lib/dockerUtil.js +121 -2
- package/src/lib/nodeVersion.js +3 -3
- package/src/lib/serverInstructions.js +11 -0
- package/src/tools/checkClaimStatus.js +1 -1
- package/src/tools/checkEmailVerified.js +1 -1
- package/src/tools/checkPrerequisites.js +349 -40
- package/src/tools/checkRelayerHealth.js +64 -10
- package/src/tools/configureVpd.js +1 -1
- package/src/tools/describeSettings.js +2 -6
- package/src/tools/getHostTags.js +1 -1
- package/src/tools/installRelayer.js +276 -59
- package/src/tools/manageBackups.js +1 -1
- package/src/tools/restartService.js +1 -1
- package/src/tools/setupCliCredentials.js +1 -1
- package/src/tools/startClaim.js +1 -1
- package/src/tools/startRegistration.js +1 -1
- package/src/tools/updateSettings.js +1 -1
- package/src/tools/verifyStorage.js +1 -1
- package/src/templates/docker-compose.yml +0 -86
|
@@ -11,7 +11,7 @@ const RELAYER_UI_BASE = 'http://localhost:8888';
|
|
|
11
11
|
* Curated runtime catalog — the MCP exposes only the whitelist in
|
|
12
12
|
* allowedSettings.js, never the full ~74-key advanced catalog (Ken,
|
|
13
13
|
* 2026-06-11). Current values + defaults come from GET /api/v1/config
|
|
14
|
-
* (relayer-ui Config.readConfig: { current, defaults,
|
|
14
|
+
* (relayer-ui Config.readConfig: { current, defaults, ... }).
|
|
15
15
|
*/
|
|
16
16
|
module.exports = function registerDescribeSettings(server, options = {}) {
|
|
17
17
|
const http = options.httpClient || createHttpClient(options);
|
|
@@ -23,7 +23,7 @@ module.exports = function registerDescribeSettings(server, options = {}) {
|
|
|
23
23
|
server.registerTool(
|
|
24
24
|
'describe_settings',
|
|
25
25
|
{
|
|
26
|
-
title: '
|
|
26
|
+
title: 'Describe settings',
|
|
27
27
|
description: 'List the adjustable Relayer settings: worker/concurrency tuning, backup schedule, and cost center (CCID). Returns current value, default, type, and guidance per setting. Use before update_settings. Requires OIDC sign-in (same session as the other tools).',
|
|
28
28
|
inputSchema: {
|
|
29
29
|
/* no parameters — the whitelist is small by design */
|
|
@@ -90,10 +90,6 @@ module.exports = function registerDescribeSettings(server, options = {}) {
|
|
|
90
90
|
text: JSON.stringify({
|
|
91
91
|
success: true,
|
|
92
92
|
settings,
|
|
93
|
-
// uploadTuning: 'calculating' until a speedtest lands;
|
|
94
|
-
// 'tuned' carries the resource-aware concurrency ceiling
|
|
95
|
-
// that caps HOSTIO_SIMULTANEOUS_UPLOADS.
|
|
96
|
-
uploadTuning: data.uploadTuning ?? null,
|
|
97
93
|
message: 'These are the only settings adjustable through this MCP. Apply changes with update_settings; most need restart_service afterwards. Changing CostCenter changes who is billed — always confirm with the operator first.',
|
|
98
94
|
}, null, 2),
|
|
99
95
|
}],
|
package/src/tools/getHostTags.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = function registerGetHostTags(server, options = {}) {
|
|
|
32
32
|
server.registerTool(
|
|
33
33
|
'get_host_tags',
|
|
34
34
|
{
|
|
35
|
-
title: '
|
|
35
|
+
title: 'Get host tags',
|
|
36
36
|
description: 'Get the available host tags for VPD (Virtual Private Datacenter) configuration, plus the currently applied VPD host selection. Translate tags into plain-language options for the operator — never show raw CEL expressions. Requires OIDC sign-in on first use (the user will be prompted to sign in via browser).',
|
|
37
37
|
inputSchema: {
|
|
38
38
|
/* no parameters */
|
|
@@ -1,12 +1,86 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { z } = require('zod');
|
|
4
|
+
const os = require('os');
|
|
4
5
|
const path = require('path');
|
|
5
6
|
const net = require('net');
|
|
6
|
-
const { createDockerUtil, redactEndpoint } = require('../lib/dockerUtil');
|
|
7
|
+
const { createDockerUtil, redactEndpoint, classifyDockerFailure } = require('../lib/dockerUtil');
|
|
7
8
|
|
|
8
9
|
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
10
|
|
|
11
|
+
const USES_BIND_ADDRESS = /\$\{BIND_ADDRESS\b/;
|
|
12
|
+
|
|
13
|
+
/** A YAML line with its comment cut off ('#' starts no ${...} expansion). */
|
|
14
|
+
function stripComment(line) {
|
|
15
|
+
const at = line.search(/(^|\s)#/);
|
|
16
|
+
return at === -1 ? line : line.slice(0, at);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Whether every port a compose file publishes uses ${BIND_ADDRESS...} in the
|
|
21
|
+
* short syntax, so a bind_address narrows all of them. Reads each `ports:`
|
|
22
|
+
* block, block or flow form. A port without it, a long-syntax item (the .env
|
|
23
|
+
* value carries a trailing colon, which is no valid host_ip), or a file with no
|
|
24
|
+
* published port at all gives false: the caller stops before writing anything.
|
|
25
|
+
* Comments and other keys (environment) never count.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} text - compose file text
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
function everyPortUsesBindAddress(text) {
|
|
31
|
+
const lines = text.split(/\r?\n/);
|
|
32
|
+
const items = [];
|
|
33
|
+
for (let i = 0; i < lines.length; i++) {
|
|
34
|
+
const key = /^([ \t]*)(?:-[ \t]+)?ports:(.*)$/.exec(stripComment(lines[i]));
|
|
35
|
+
if (!key) continue;
|
|
36
|
+
const keyIndent = key[1].length;
|
|
37
|
+
const rest = key[2].trim();
|
|
38
|
+
if (rest) {
|
|
39
|
+
// Flow form: ports: ["a", "b"]. Anything else is unreadable here.
|
|
40
|
+
const flow = /^\[(.*)\]$/.exec(rest);
|
|
41
|
+
if (!flow) return false;
|
|
42
|
+
items.push(...flow[1].split(',').map((item) => item.trim()).filter(Boolean));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
let itemIndent = null;
|
|
46
|
+
let current = null;
|
|
47
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
48
|
+
const line = stripComment(lines[j]);
|
|
49
|
+
if (!line.trim()) continue;
|
|
50
|
+
const indent = /^[ \t]*/.exec(line)[0].length;
|
|
51
|
+
const dash = /^[ \t]*-(\s|$)/.test(line);
|
|
52
|
+
if (itemIndent === null) {
|
|
53
|
+
if (!dash || indent < keyIndent) break;
|
|
54
|
+
itemIndent = indent;
|
|
55
|
+
}
|
|
56
|
+
if (indent < itemIndent || (indent === itemIndent && !dash)) break;
|
|
57
|
+
if (indent === itemIndent) {
|
|
58
|
+
current = { text: line };
|
|
59
|
+
items.push(current);
|
|
60
|
+
} else {
|
|
61
|
+
current.text += `\n${line}`;
|
|
62
|
+
}
|
|
63
|
+
i = j;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const LONG_SYNTAX = /^[ \t]*-[ \t]+[A-Za-z_]+:(\s|$)/;
|
|
67
|
+
return items.length > 0 && items.every((item) => {
|
|
68
|
+
const text = typeof item === 'string' ? item : item.text;
|
|
69
|
+
return USES_BIND_ADDRESS.test(text) && (typeof item === 'string' || !LONG_SYNTAX.test(text));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** What the response says about bind_address, per compose source. */
|
|
74
|
+
function bindAddressApplied(source, bindAddress) {
|
|
75
|
+
if (source === 'channel' && bindAddress) {
|
|
76
|
+
return 'yes — the channel compose uses BIND_ADDRESS on every published port (checked before install)';
|
|
77
|
+
}
|
|
78
|
+
if (source === 'channel') {
|
|
79
|
+
return 'not needed — no bind_address was set, so ports are published on all interfaces';
|
|
80
|
+
}
|
|
81
|
+
return 'unknown — the compose_url compose may or may not reference BIND_ADDRESS in its port declarations; this installer does not read that file';
|
|
82
|
+
}
|
|
83
|
+
|
|
10
84
|
// R5 input boundary: this value is written verbatim into the .env the installer
|
|
11
85
|
// authors, and Compose auto-loads that file. An unvalidated newline injects
|
|
12
86
|
// further KEY=VALUE lines — including a second UI_PORT, which wins last-value
|
|
@@ -31,21 +105,24 @@ function isValidBindAddress(value) {
|
|
|
31
105
|
return false;
|
|
32
106
|
}
|
|
33
107
|
|
|
34
|
-
// Canonical released install — the full
|
|
108
|
+
// Canonical released install — the full release channel bundle (relayer +
|
|
35
109
|
// monitoring stack), published on the XNS releases registry and served
|
|
36
|
-
// login-free. THE default install source.
|
|
37
|
-
|
|
110
|
+
// login-free. THE default install source. Its .env (COMPOSE_PROFILES and the
|
|
111
|
+
// rest of the release settings) sits beside it and is fetched on every run.
|
|
112
|
+
const CHANNEL_COMPOSE_URL = 'https://releases.xns.tech/relayer/release/docker-compose.yml';
|
|
113
|
+
const CHANNEL_ENV_FILE = '.env';
|
|
38
114
|
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
// kept service-parity with the channel bundle by the jest contract tests.
|
|
42
|
-
const TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'docker-compose.yml');
|
|
115
|
+
// Where a release .env that stops short is reported.
|
|
116
|
+
const BUGS_URL = require('../../package.json').bugs.url;
|
|
43
117
|
|
|
44
|
-
// container_name in the
|
|
118
|
+
// container_name in the release compose. Docker container names are unique
|
|
45
119
|
// per daemon, so ANY existing container with this name — running or stopped,
|
|
46
|
-
//
|
|
120
|
+
// any channel — makes `docker compose up` fail with a name conflict.
|
|
47
121
|
const CONTAINER_NAME = 'xns-relayer';
|
|
48
122
|
|
|
123
|
+
// Owner read/write only for the .env this tool writes.
|
|
124
|
+
const ENV_FILE_MODE = 0o600;
|
|
125
|
+
|
|
49
126
|
// The machine running this MCP and the machine running the Docker daemon can
|
|
50
127
|
// differ (DOCKER_HOST=ssh://..., tcp://..., or an ssh Docker context). This tool
|
|
51
128
|
// writes docker-compose.yml and .env on THIS machine, while compose up runs on
|
|
@@ -84,6 +161,95 @@ function safeError(message, cause) {
|
|
|
84
161
|
return Object.assign(new Error(message, { cause }), { userSafe: true });
|
|
85
162
|
}
|
|
86
163
|
|
|
164
|
+
// The four reasons a default install stops before it touches the install
|
|
165
|
+
// folder. Each names the cause and what to do; curl and OS text go to the
|
|
166
|
+
// server log only.
|
|
167
|
+
function downloadFailedMessage(host, file) {
|
|
168
|
+
return `The Relayer release files could not be downloaded from ${host} (the ${file} download failed), so nothing was installed. Check that this machine reaches https://${host}, then run install_relayer again.`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function incompleteEnvMessage(host) {
|
|
172
|
+
return `The release .env downloaded from ${host} has no COMPOSE_PROFILES line, so the download was cut short or the published release is incomplete, and nothing was installed. Run install_relayer again; if it stops here again, report it at ${BUGS_URL}.`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function bindUnsupportedMessage(bindAddress) {
|
|
176
|
+
return `bind_address ${bindAddress} was requested, but the release compose file does not use BIND_ADDRESS on every published port, so the ports would be published on all interfaces. Nothing was installed. Run install_relayer again without bind_address, or pass compose_url pointing at a compose file whose ports use \${BIND_ADDRESS}.`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function tempFolderMessage(tmpDir) {
|
|
180
|
+
return `The release files could not be prepared on this machine: the temporary folder under ${tmpDir} could not be created or read. Nothing was installed. Check that the folder is writable and the disk is not full, then run install_relayer again.`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
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.';
|
|
184
|
+
|
|
185
|
+
// Fixed sentences per classified Docker failure (dockerUtil FAILURE_PATTERNS).
|
|
186
|
+
// They never quote Docker's text: that goes to the server log only.
|
|
187
|
+
// port_in_use is not here: its sentence depends on the port (portSentence).
|
|
188
|
+
const FAILURE_SENTENCES = {
|
|
189
|
+
permission_denied: DOCKER_GROUP_SENTENCE,
|
|
190
|
+
daemon_stopped: 'Docker is not running on this machine. Start it with sudo systemctl start docker, then run install_relayer again.',
|
|
191
|
+
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.',
|
|
192
|
+
pull_refused: 'The Relayer images could not be pulled from releases.xns.tech. Check that this machine reaches https://releases.xns.tech and that no stale registry login is stored (docker logout releases.xns.tech), then run install_relayer again.',
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// The release compose also publishes the S3 HTTPS port. No install_relayer
|
|
196
|
+
// parameter moves it.
|
|
197
|
+
const S3_TLS_PORT = 9443;
|
|
198
|
+
|
|
199
|
+
// Port in use: name the port, the parameter that moves it, and the leftover
|
|
200
|
+
// Created container compose leaves behind, which a retry would collide with.
|
|
201
|
+
function portSentence({ port }, { ui_port, s3_port }) {
|
|
202
|
+
const retry = `remove the leftover container with docker rm -f ${CONTAINER_NAME} and run install_relayer again`;
|
|
203
|
+
// DECISION: no new parameter for the 9443 port. Appending S3_TLS_PORT to the
|
|
204
|
+
// .env would fix one install only (the channel .env is re-fetched each run)
|
|
205
|
+
// and the schema has no other per-port knob for a port the Relayer does not
|
|
206
|
+
// serve plain traffic on. The sentence says to free it.
|
|
207
|
+
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}.`;
|
|
208
|
+
if (port === ui_port) return `Port ${port} is already in use on this machine. Free it or pass a different ui_port, then ${retry}.`;
|
|
209
|
+
if (port === s3_port) return `Port ${port} is already in use on this machine. Free it or pass a different s3_port, then ${retry}.`;
|
|
210
|
+
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}.`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// The client-facing reason for a caught failure: this file's own message when
|
|
214
|
+
// marked userSafe, a fixed cause sentence when Docker's stderr names one, else
|
|
215
|
+
// the generic line.
|
|
216
|
+
function failureReason(err, ports) {
|
|
217
|
+
if (err.userSafe) return err.message;
|
|
218
|
+
const cause = classifyDockerFailure(err);
|
|
219
|
+
if (cause?.key === 'port_in_use') return portSentence(cause, ports);
|
|
220
|
+
if (cause) return FAILURE_SENTENCES[cause.key];
|
|
221
|
+
return 'See server log for detail.';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function errorResponse(error) {
|
|
225
|
+
return {
|
|
226
|
+
content: [{ type: 'text', text: JSON.stringify({ success: false, error }) }],
|
|
227
|
+
isError: true,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* True when `docker info` is refused by the socket's permissions. Any other
|
|
233
|
+
* outcome (success, daemon down, a mock without docker()) returns false and
|
|
234
|
+
* the install carries on as before; the later step reports its own cause.
|
|
235
|
+
*/
|
|
236
|
+
async function socketDenied(docker) {
|
|
237
|
+
if (!docker || typeof docker.docker !== 'function') return false;
|
|
238
|
+
try {
|
|
239
|
+
await docker.docker(['info', '--format', '{{.ServerVersion}}']);
|
|
240
|
+
return false;
|
|
241
|
+
} catch (err) {
|
|
242
|
+
console.error(`[install_relayer] docker info preflight: ${err.message}`);
|
|
243
|
+
return classifyDockerFailure(err)?.key === 'permission_denied';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Append the three port lines to a fetched .env, keeping every fetched line.
|
|
248
|
+
function withPortLines(fetchedEnv, portLines) {
|
|
249
|
+
if (fetchedEnv === '' || fetchedEnv.endsWith('\n')) return `${fetchedEnv}${portLines}`;
|
|
250
|
+
return `${fetchedEnv}\n${portLines}`;
|
|
251
|
+
}
|
|
252
|
+
|
|
87
253
|
/**
|
|
88
254
|
* Tool 4: install_relayer
|
|
89
255
|
* AC-12: confirms "containers starting"; no manual shell.
|
|
@@ -91,11 +257,13 @@ function safeError(message, cause) {
|
|
|
91
257
|
*
|
|
92
258
|
* A first-time user has never heard of a Relayer and cannot supply a compose
|
|
93
259
|
* file or a .env. So by default this tool authors both for them: it fetches
|
|
94
|
-
* the CANONICAL channel bundle (relayer
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
260
|
+
* the CANONICAL release channel bundle (relayer, the Prometheus + Grafana +
|
|
261
|
+
* node-exporter monitoring stack that powers the dashboards under Monitoring in
|
|
262
|
+
* the web UI, Alertmanager, and the Loki + Alloy + audit-logrotate audit-log
|
|
263
|
+
* pipeline) and its .env, then appends the two ports and the bind address to
|
|
264
|
+
* that .env. Both files are downloaded into a temporary folder and checked
|
|
265
|
+
* there first. If either cannot be downloaded or used, the tool stops with the
|
|
266
|
+
* cause and the fix, and the install folder is left exactly as it was.
|
|
99
267
|
*
|
|
100
268
|
* `compose_url` stays as an optional override for internal/custom installs;
|
|
101
269
|
* when given, the old download-a-URL behavior is preserved.
|
|
@@ -105,12 +273,14 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
105
273
|
const _execFile = options.execFile;
|
|
106
274
|
const fsp = options.fs || require('fs').promises;
|
|
107
275
|
const channelComposeUrl = options.channelComposeUrl || CHANNEL_COMPOSE_URL;
|
|
276
|
+
// The .env lives beside the compose it configures.
|
|
277
|
+
const channelEnvUrl = new URL(CHANNEL_ENV_FILE, channelComposeUrl).href;
|
|
108
278
|
|
|
109
279
|
server.registerTool(
|
|
110
280
|
'install_relayer',
|
|
111
281
|
{
|
|
112
|
-
title: '
|
|
113
|
-
description: 'Install and start the XNS Relayer. By default fetches the canonical
|
|
282
|
+
title: 'Install the Relayer',
|
|
283
|
+
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.xns.tech (anonymous pull), appends the ports to that .env, then runs docker compose up -d — the user does NOT need to author any file. If the release files cannot be downloaded or used, it stops, says why and what to do, and installs nothing. 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 24 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 release compose does not use BIND_ADDRESS on every published port, the tool stops before installing anything and says so. 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
284
|
inputSchema: {
|
|
115
285
|
install_path: z.string().optional().default('/opt/xns-relayer').describe('Directory to install the compose file into'),
|
|
116
286
|
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 +288,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
118
288
|
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
289
|
// R5 input boundary — see isValidBindAddress above for why each
|
|
120
290
|
// 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
|
|
291
|
+
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 default path it is also written into the .env this installer authors (the compose_url override path writes no .env). On the default path the installer checks the fetched channel compose for BIND_ADDRESS and stops, installing nothing, 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
292
|
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
293
|
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
294
|
},
|
|
@@ -147,13 +317,20 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
147
317
|
error: `The Docker daemon is on ${dockerHost.host}, not this machine. install_relayer would write docker-compose.yml and .env on this machine instead of on ${dockerHost.host}, so nothing was written and nothing was started.`,
|
|
148
318
|
docker_host: dockerHost.host,
|
|
149
319
|
docker_endpoint: redactEndpoint(dockerHost.endpoint),
|
|
150
|
-
remediation: `Run the MCP on ${dockerHost.host} (install Node.js
|
|
320
|
+
remediation: `Run the MCP on ${dockerHost.host} (install Node.js 24 there and point your MCP client at it), then run install_relayer again. Or, to install on this machine, unset DOCKER_HOST or switch to the default Docker context.`,
|
|
151
321
|
}, null, 2),
|
|
152
322
|
}],
|
|
153
323
|
isError: true,
|
|
154
324
|
};
|
|
155
325
|
}
|
|
156
326
|
|
|
327
|
+
// A socket that refuses this user would make the existing-install
|
|
328
|
+
// lookup below read "no container" and the install fail later at
|
|
329
|
+
// compose up. Name the cause now, before anything is written.
|
|
330
|
+
if (await socketDenied(docker)) {
|
|
331
|
+
return errorResponse(`Relayer installation failed: ${DOCKER_GROUP_SENTENCE}`);
|
|
332
|
+
}
|
|
333
|
+
|
|
157
334
|
// Preflight: install_relayer is for FRESH installs only — it does
|
|
158
335
|
// not upgrade an existing deployment in place. An existing
|
|
159
336
|
// container (running or stopped, any channel) owns the name and
|
|
@@ -174,54 +351,106 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
174
351
|
};
|
|
175
352
|
}
|
|
176
353
|
|
|
177
|
-
|
|
178
|
-
await new Promise((resolve, reject) => {
|
|
354
|
+
const mkdirInstallPath = () => new Promise((resolve, reject) => {
|
|
179
355
|
execFileFn('mkdir', ['-p', install_path], {}, (err) => {
|
|
180
356
|
if (err) return reject(safeError(`Failed to create directory ${install_path} — check that the path is writable on this machine and no file sits at or along it`, err));
|
|
181
357
|
resolve();
|
|
182
358
|
});
|
|
183
359
|
});
|
|
184
360
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
361
|
+
// curl -fsSL -o <outPath> <url> (execFile, no shell). Rejects
|
|
362
|
+
// with curl's own error; each caller chooses the message.
|
|
363
|
+
const curlTo = (url, outPath) => new Promise((resolve, reject) => {
|
|
364
|
+
execFileFn('curl', ['-fsSL', '-o', outPath, url], { timeout: 60000 }, (err) => {
|
|
365
|
+
if (err) return reject(err);
|
|
188
366
|
resolve();
|
|
189
367
|
});
|
|
190
368
|
});
|
|
191
369
|
|
|
370
|
+
// Download the release compose and .env into an owner-only
|
|
371
|
+
// temporary folder, read them and run the two checks. The folder
|
|
372
|
+
// is removed whatever happens; a failed removal is logged and
|
|
373
|
+
// never replaces the result.
|
|
374
|
+
const stageReleaseFiles = async (bindAddress) => {
|
|
375
|
+
const host = new URL(channelComposeUrl).host;
|
|
376
|
+
const tmpDir = os.tmpdir();
|
|
377
|
+
const readStaged = (file) => fsp.readFile(file, 'utf8').catch((err) => {
|
|
378
|
+
throw safeError(tempFolderMessage(tmpDir), err);
|
|
379
|
+
});
|
|
380
|
+
let stage;
|
|
381
|
+
try {
|
|
382
|
+
stage = await fsp.mkdtemp(path.join(tmpDir, 'xns-relayer-install-'));
|
|
383
|
+
} catch (err) {
|
|
384
|
+
throw safeError(tempFolderMessage(tmpDir), err);
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
const stagedCompose = path.join(stage, 'docker-compose.yml');
|
|
388
|
+
await curlTo(channelComposeUrl, stagedCompose).catch((err) => {
|
|
389
|
+
throw safeError(downloadFailedMessage(host, 'docker-compose.yml'), err);
|
|
390
|
+
});
|
|
391
|
+
const composeText = await readStaged(stagedCompose);
|
|
392
|
+
// A bind_address the release compose ignores would publish
|
|
393
|
+
// the ports on every interface.
|
|
394
|
+
if (bindAddress && !everyPortUsesBindAddress(composeText)) {
|
|
395
|
+
throw safeError(bindUnsupportedMessage(bindAddress));
|
|
396
|
+
}
|
|
397
|
+
const stagedEnv = path.join(stage, CHANNEL_ENV_FILE);
|
|
398
|
+
await curlTo(channelEnvUrl, stagedEnv).catch((err) => {
|
|
399
|
+
throw safeError(downloadFailedMessage(host, CHANNEL_ENV_FILE), err);
|
|
400
|
+
});
|
|
401
|
+
const fetchedEnv = await readStaged(stagedEnv);
|
|
402
|
+
// The publisher always ships this line, so its absence means a
|
|
403
|
+
// truncated or empty download. Without it no audit sidecar starts.
|
|
404
|
+
if (!/^COMPOSE_PROFILES=/m.test(fetchedEnv)) {
|
|
405
|
+
throw safeError(incompleteEnvMessage(host));
|
|
406
|
+
}
|
|
407
|
+
return { composeText, fetchedEnv };
|
|
408
|
+
} finally {
|
|
409
|
+
try {
|
|
410
|
+
await fsp.rm(stage, { recursive: true, force: true });
|
|
411
|
+
} catch (rmErr) {
|
|
412
|
+
console.error(`[install_relayer] could not remove ${stage}: ${rmErr.message}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
|
|
192
417
|
const bindPrefix = bind_address ? `${bind_address}:` : '';
|
|
193
|
-
let envContents = null;
|
|
194
418
|
let source;
|
|
195
|
-
let note;
|
|
196
419
|
if (compose_url) {
|
|
197
|
-
// Override path:
|
|
198
|
-
|
|
420
|
+
// Override path: make the folder, then download a custom
|
|
421
|
+
// compose straight into it.
|
|
422
|
+
await mkdirInstallPath();
|
|
423
|
+
await curlTo(compose_url, composePath).catch((err) => {
|
|
424
|
+
throw safeError('Failed to download compose file', err);
|
|
425
|
+
});
|
|
199
426
|
source = 'compose_url';
|
|
200
427
|
} else {
|
|
201
|
-
// Default path:
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
envContents = `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`;
|
|
216
|
-
await fsp.writeFile(envPath, envContents);
|
|
428
|
+
// Default path: download the release compose and its .env
|
|
429
|
+
// into a temporary folder and check them there. Only when
|
|
430
|
+
// every check passes is the install folder made and written,
|
|
431
|
+
// so a stop leaves it exactly as it was.
|
|
432
|
+
const portLines = `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`;
|
|
433
|
+
const { composeText, fetchedEnv } = await stageReleaseFiles(bind_address);
|
|
434
|
+
await mkdirInstallPath();
|
|
435
|
+
await fsp.writeFile(composePath, composeText);
|
|
436
|
+
// The .env holds webhook/SMTP secrets: owner-only. The mode on
|
|
437
|
+
// writeFile covers a new file; chmod covers one that existed.
|
|
438
|
+
await fsp.writeFile(envPath, withPortLines(fetchedEnv, portLines), { mode: ENV_FILE_MODE });
|
|
439
|
+
await fsp.chmod(envPath, ENV_FILE_MODE);
|
|
440
|
+
source = 'channel';
|
|
217
441
|
}
|
|
218
442
|
|
|
219
443
|
// Run docker compose up -d. cwd + env so ${UI_PORT}/${S3_PORT}
|
|
220
444
|
// interpolation and the ./data bind resolve in the install dir,
|
|
221
445
|
// regardless of where the MCP process was launched.
|
|
446
|
+
// The .env written above owns COMPOSE_PROFILES, aliased to RELAYER_AUDIT_MODE.
|
|
447
|
+
// Compose lets the process environment beat .env, so an inherited value
|
|
448
|
+
// would leave the audit sink on with no sidecars to tail and rotate it.
|
|
449
|
+
// compose_url writes no .env, so there the caller's value stands.
|
|
450
|
+
const { COMPOSE_PROFILES: _inheritedProfiles, ...withoutProfiles } = process.env;
|
|
222
451
|
await docker.composeUp(composePath, {
|
|
223
452
|
cwd: install_path,
|
|
224
|
-
env: { ...process.env, UI_PORT: String(ui_port), S3_PORT: String(s3_port), BIND_ADDRESS: bindPrefix },
|
|
453
|
+
env: { ...(compose_url ? process.env : withoutProfiles), UI_PORT: String(ui_port), S3_PORT: String(s3_port), BIND_ADDRESS: bindPrefix },
|
|
225
454
|
});
|
|
226
455
|
|
|
227
456
|
return {
|
|
@@ -247,9 +476,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
247
476
|
// behind (correct-or-absent, same rule as the port readout).
|
|
248
477
|
binding: {
|
|
249
478
|
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',
|
|
479
|
+
bind_address_applied: bindAddressApplied(source, bind_address),
|
|
253
480
|
ui: { host_port: ui_port, container_port: compose_url ? null : 8888 },
|
|
254
481
|
s3: { host_port: s3_port, container_port: compose_url ? null : 9000 },
|
|
255
482
|
composed_from: compose_url
|
|
@@ -261,22 +488,12 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
261
488
|
ui_tls_enabled: { requested: ui_tls_enabled, effective: false, note: ui_tls_enabled ? 'Accepted but not wired in this version — no effect until a future release ships the TLS listener.' : 'Off (HTTP only).' },
|
|
262
489
|
s3_tls_enabled: { requested: s3_tls_enabled, effective: false, note: s3_tls_enabled ? 'Accepted but not wired in this version — no effect until a future release ships the TLS listener.' : 'Off (HTTP only).' },
|
|
263
490
|
},
|
|
264
|
-
...(note ? { note } : {}),
|
|
265
491
|
}, null, 2),
|
|
266
492
|
}],
|
|
267
493
|
};
|
|
268
494
|
} catch (err) {
|
|
269
495
|
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
|
-
};
|
|
496
|
+
return errorResponse(`Relayer installation failed: ${failureReason(err, { ui_port, s3_port })}`);
|
|
280
497
|
}
|
|
281
498
|
},
|
|
282
499
|
);
|
|
@@ -31,7 +31,7 @@ module.exports = function registerManageBackups(server, options = {}) {
|
|
|
31
31
|
server.registerTool(
|
|
32
32
|
'manage_backups',
|
|
33
33
|
{
|
|
34
|
-
title: '
|
|
34
|
+
title: 'Manage backups',
|
|
35
35
|
description: 'Manage Relayer configuration backups: list archives, start a backup, restore from an archive, or delete one. Restore OVERWRITES current state and restarts services — always confirm with the operator and state which archive and components first. Backups must be enabled (BACKUP_ENABLED) for list/start.',
|
|
36
36
|
inputSchema: {
|
|
37
37
|
action: z.enum(['list', 'start', 'restore', 'delete'])
|
|
@@ -26,7 +26,7 @@ module.exports = function registerRestartService(server, options = {}) {
|
|
|
26
26
|
server.registerTool(
|
|
27
27
|
'restart_service',
|
|
28
28
|
{
|
|
29
|
-
title: '
|
|
29
|
+
title: 'Restart service',
|
|
30
30
|
description: 'Restart a Relayer service (hostio, gateway, s3gateway, database) or all services. Disruptive: in-flight S3 requests will fail during the restart — confirm with the operator before calling. Verify recovery afterwards with check_relayer_health.',
|
|
31
31
|
inputSchema: {
|
|
32
32
|
service: z.enum(SERVICES).optional()
|
|
@@ -25,7 +25,7 @@ module.exports = function registerSetupCliCredentials(server, options = {}) {
|
|
|
25
25
|
server.registerTool(
|
|
26
26
|
'setup_cli_credentials',
|
|
27
27
|
{
|
|
28
|
-
title: '
|
|
28
|
+
title: 'Set up CLI credentials',
|
|
29
29
|
description: 'Provision S3 IAM credentials for the XNS CLI. Creates an IAM user in the Relayer and writes ~/.xns/credentials so that `xns ls` and other S3 verbs work without further configuration. Call once after check_claim_status reaches STATE_3.',
|
|
30
30
|
inputSchema: {
|
|
31
31
|
muse_token: z.string().describe('Keycloak/Muse token — the same token used for get_host_tags and configure_vpd'),
|
package/src/tools/startClaim.js
CHANGED
|
@@ -21,7 +21,7 @@ module.exports = function registerStartClaim(server, options = {}) {
|
|
|
21
21
|
server.registerTool(
|
|
22
22
|
'start_claim',
|
|
23
23
|
{
|
|
24
|
-
title: '
|
|
24
|
+
title: 'Start claim',
|
|
25
25
|
description: 'Start a claim session to link this Relayer installation to an XNS account. Returns a claim URL that the user must open in a browser to complete the claim. The claim has an expiration time. After calling this, use check_claim_status to monitor claim progress.',
|
|
26
26
|
inputSchema: {
|
|
27
27
|
/* no parameters */
|
|
@@ -28,7 +28,7 @@ module.exports = function registerStartRegistration(server, options = {}) {
|
|
|
28
28
|
server.registerTool(
|
|
29
29
|
'start_registration',
|
|
30
30
|
{
|
|
31
|
-
title: '
|
|
31
|
+
title: 'Start registration',
|
|
32
32
|
description: 'Get the browser registration URL for creating a new XNS account. The user opens this URL in a browser to sign up via Keycloak — the agent never touches credentials. After signing up, use check_email_verified to poll for email verification.',
|
|
33
33
|
inputSchema: {},
|
|
34
34
|
annotations: {
|
|
@@ -33,7 +33,7 @@ module.exports = function registerUpdateSettings(server, options = {}) {
|
|
|
33
33
|
server.registerTool(
|
|
34
34
|
'update_settings',
|
|
35
35
|
{
|
|
36
|
-
title: '
|
|
36
|
+
title: 'Update settings',
|
|
37
37
|
description: 'Update adjustable Relayer settings (see describe_settings for the allowed set). Pass a map of setting name to new value, e.g. {"HOSTIO_UPLOAD_WORKERS": 20}. Returns require_restart — if true, follow up with restart_service after confirming with the operator. Changing CostCenter re-bills to a different cost center; always confirm first.',
|
|
38
38
|
inputSchema: {
|
|
39
39
|
settings: z.record(z.union([z.string(), z.number(), z.boolean()]))
|
|
@@ -44,7 +44,7 @@ module.exports = function registerVerifyStorage(server, options = {}) {
|
|
|
44
44
|
server.registerTool(
|
|
45
45
|
'verify_storage',
|
|
46
46
|
{
|
|
47
|
-
title: '
|
|
47
|
+
title: 'Verify storage',
|
|
48
48
|
description: 'Verify the S3-compatible storage gateway is working by performing a round-trip test: create a test bucket, upload a small object, download it, and compare. Provisions a temporary scoped IAM credential automatically using your OIDC session — no manual key management needed. The throwaway credential and test data are removed after the test, pass or fail. By default targets port 9000 on the machine the Docker daemon runs on (auto-detected from the Docker context); pass endpoint to override.',
|
|
49
49
|
inputSchema: {
|
|
50
50
|
muse_token: z.string().trim().min(1).optional().describe('Optional Keycloak/Muse token override. Usually omitted — without it (and without access keys) the tool reuses the sign-in session from get_host_tags/configure_vpd, or starts a browser sign-in if there is none.'),
|