@xns-cloud/relayer-mcp 0.6.1 → 0.8.1
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 +37 -7
- package/package.json +14 -2
- package/src/index.js +1 -1
- package/src/lib/environmentProbe.js +55 -0
- package/src/lib/oidcAuth.js +22 -11
- package/src/templates/docker-compose.yml +2 -2
- package/src/tools/checkEmailVerified.js +2 -2
- package/src/tools/checkPrerequisites.js +38 -2
- package/src/tools/installRelayer.js +68 -7
- package/src/tools/startRegistration.js +60 -0
- package/src/tools/verifyStorage.js +306 -77
- package/src/tools/registerAccount.js +0 -123
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# @xns-cloud/relayer-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@xns-cloud/relayer-mcp)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
MCP server for [XNS Relayer](https://xns.tech) — S3-compatible decentralized object storage. Provides 15 tools that let an AI agent drive the complete Relayer setup and day-2 management conversationally over stdio transport.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @xns-cloud/relayer-mcp@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Pricing:** [$4.99/TB-mo](https://xns.tech) storage, [$0 egress uncapped](https://xns.tech), [no minimum retention](https://xns.tech).
|
|
4
14
|
|
|
5
15
|
## Requirements
|
|
6
16
|
|
|
@@ -22,9 +32,28 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
|
|
|
22
32
|
|
|
23
33
|
If you start the MCP on an older Node, it exits immediately with this same guidance instead of a dependency stack trace.
|
|
24
34
|
|
|
25
|
-
##
|
|
35
|
+
## Environment
|
|
36
|
+
|
|
37
|
+
The Relayer runs as a Docker container and persists its data in a Docker volume. If the MCP is running inside an ephemeral environment (a sandbox container, a CI runner, or a throwaway VM), any installation performed there will be lost when that environment exits. `check_prerequisites` detects this automatically and reports it as a warning with a concrete next step — it never blocks the flow.
|
|
38
|
+
|
|
39
|
+
**If your environment is ephemeral**, install on a persistent Docker host instead. The easiest path from an ephemeral sandbox is an SSH Docker context:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
docker context create relayer --docker "host=ssh://user@persistent-host"
|
|
43
|
+
docker context use relayer
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The MCP then drives the install on the persistent host through the SSH context. Alternatively, hand the install step to a human operator on the target machine and continue onboarding from `check_relayer_health` onwards.
|
|
26
47
|
|
|
27
|
-
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
**Claude Code** (one command):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
claude mcp add relayer -- npx @xns-cloud/relayer-mcp@latest
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Claude Desktop / any MCP client** — add to your `claude_desktop_config.json` (or equivalent):
|
|
28
57
|
|
|
29
58
|
```json
|
|
30
59
|
{
|
|
@@ -37,14 +66,14 @@ Add to your `claude_desktop_config.json` (or `claude mcp add relayer -- npx @xns
|
|
|
37
66
|
}
|
|
38
67
|
```
|
|
39
68
|
|
|
40
|
-
No separate install step required.
|
|
69
|
+
No separate install step required — npx fetches the package on demand.
|
|
41
70
|
|
|
42
71
|
## Tools
|
|
43
72
|
|
|
44
73
|
| # | Tool | Purpose |
|
|
45
74
|
|---|------|---------|
|
|
46
75
|
| 1 | `check_prerequisites` | Verify Docker (local or remote), ports (8888, 9000), an existing installation, disk, and network connectivity. |
|
|
47
|
-
| 2 | `
|
|
76
|
+
| 2 | `start_registration` | Get the browser sign-up URL for creating an XNS account — the agent never handles credentials. |
|
|
48
77
|
| 3 | `check_email_verified` | Poll email verification status (15s interval, 30-min timeout). |
|
|
49
78
|
| 4 | `install_relayer` | Fetch the canonical beta channel bundle — relayer + Prometheus/Grafana monitoring stack (`https://releases.scpri.me/relayer/beta/docker-compose.yml`, anonymous pull, no `docker login`) — write the `.env`, and start the containers. Falls back to a bundled service-parity copy if the fetch fails. **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. |
|
|
50
79
|
| 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. |
|
|
@@ -52,7 +81,7 @@ No separate install step required.
|
|
|
52
81
|
| 7 | `check_claim_status` | Poll claim state (STATE_1 / STATE_2 / STATE_3). |
|
|
53
82
|
| 8 | `get_host_tags` | Retrieve available host tags for VPD configuration, plus the currently applied data/parity selection (read-back with an `is_default` flag). |
|
|
54
83
|
| 9 | `configure_vpd` | Set data/parity host selection via CEL expressions. `dry_run: true` previews the matched host counts without applying (requires a Relayer build with the HostIO evaluate endpoint; older builds report `preview_supported: false`). |
|
|
55
|
-
| 10 | `verify_storage` | Round-trip S3 test (create bucket, put object, get object) against the S3 gateway
|
|
84
|
+
| 10 | `verify_storage` | Round-trip S3 test (create bucket, put object, get object) against the S3 gateway. Provisions a temporary scoped IAM credential automatically from your OIDC session — no manual key management needed. The tool attempts to remove test data and the throwaway credential after the test; a `cleanup_warning` is reported if any resource could not be removed. `relayer_ui_url` must point at a loopback or private-network host. |
|
|
56
85
|
| 11 | `setup_cli_credentials` | Provision S3 IAM credentials and write `~/.xns/credentials` so the XNS CLI works without further configuration. |
|
|
57
86
|
| 12 | `describe_settings` | List the adjustable settings — worker/concurrency tuning, backup schedule, cost center (CCID) — with current values, defaults, and guidance. The MCP deliberately exposes only this curated set, never the full advanced catalog. |
|
|
58
87
|
| 13 | `update_settings` | Apply a map of setting changes (whitelist-enforced). Returns `require_restart`. **Requires relayer-ui >= 3.43.3** — older servers can clobber the database password on config round-trips. |
|
|
@@ -62,7 +91,7 @@ No separate install step required.
|
|
|
62
91
|
## Onboarding Flow
|
|
63
92
|
|
|
64
93
|
1. Agent checks prerequisites (Tool 1).
|
|
65
|
-
2. Agent
|
|
94
|
+
2. Agent gets the browser sign-up URL; user creates an account in the browser (Tool 2).
|
|
66
95
|
3. User clicks email verification link; agent polls (Tool 3).
|
|
67
96
|
4. Agent installs and starts Relayer containers (Tool 4) — it writes the
|
|
68
97
|
released compose + `.env` itself; the user is never asked for a compose URL.
|
|
@@ -140,3 +169,4 @@ This package uses the `relayer-native` Keycloak client ID for OIDC authenticatio
|
|
|
140
169
|
## License
|
|
141
170
|
|
|
142
171
|
Apache-2.0 © SCP Corp. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
172
|
+
|
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.8.1",
|
|
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",
|
|
@@ -23,9 +23,21 @@
|
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"mcp",
|
|
26
|
+
"mcp-server",
|
|
27
|
+
"model-context-protocol",
|
|
26
28
|
"relayer",
|
|
27
29
|
"xns",
|
|
28
|
-
"
|
|
30
|
+
"s3",
|
|
31
|
+
"object-storage",
|
|
32
|
+
"onboarding",
|
|
33
|
+
"ai-agent",
|
|
34
|
+
"stdio",
|
|
35
|
+
"docker",
|
|
36
|
+
"self-hosted",
|
|
37
|
+
"storage",
|
|
38
|
+
"backup",
|
|
39
|
+
"s3-compatible",
|
|
40
|
+
"claude"
|
|
29
41
|
],
|
|
30
42
|
"engines": {
|
|
31
43
|
"node": ">=20"
|
package/src/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const server = new McpServer({
|
|
|
20
20
|
|
|
21
21
|
// Register all 15 tools
|
|
22
22
|
require('./tools/checkPrerequisites')(server);
|
|
23
|
-
require('./tools/
|
|
23
|
+
require('./tools/startRegistration')(server);
|
|
24
24
|
require('./tools/checkEmailVerified')(server);
|
|
25
25
|
require('./tools/installRelayer')(server);
|
|
26
26
|
require('./tools/checkRelayerHealth')(server);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const nodeFs = require('fs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Read-only environment probes to detect whether the current process is
|
|
7
|
+
* running inside an ephemeral container (Docker, CI runner, sandbox).
|
|
8
|
+
*
|
|
9
|
+
* Ephemeral environments can run the Relayer install, but the installation
|
|
10
|
+
* will be lost when the container exits. This is a finding (warning), not
|
|
11
|
+
* a failure — allPassed must never flip.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} [options]
|
|
14
|
+
* @param {object} [options.fs] - Injected fs module (testing)
|
|
15
|
+
* @param {number} [options.pid] - Override process PID (testing; avoids false PID-1 signal in CI containers)
|
|
16
|
+
* @returns {{ ephemeral: boolean, signals: string[] }}
|
|
17
|
+
*/
|
|
18
|
+
function environmentProbe(options = {}) {
|
|
19
|
+
const fs = options.fs || nodeFs;
|
|
20
|
+
const pid = options.pid ?? process.pid;
|
|
21
|
+
const signals = [];
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
fs.accessSync('/.dockerenv', nodeFs.constants?.F_OK ?? 0);
|
|
25
|
+
signals.push('/.dockerenv exists');
|
|
26
|
+
} catch {
|
|
27
|
+
// Not present — not a signal
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const cgroup = fs.readFileSync('/proc/1/cgroup', 'utf8');
|
|
32
|
+
if (/docker|containerd|kubepods|lxc/i.test(cgroup)) {
|
|
33
|
+
signals.push('/proc/1/cgroup references a container runtime');
|
|
34
|
+
}
|
|
35
|
+
} catch {
|
|
36
|
+
// Not readable — not a signal
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (pid === 1) {
|
|
40
|
+
signals.push('Process is PID 1');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
fs.accessSync('/run/systemd/system', nodeFs.constants?.F_OK ?? 0);
|
|
45
|
+
} catch {
|
|
46
|
+
signals.push('systemd is absent');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
ephemeral: signals.length >= 2,
|
|
51
|
+
signals,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { environmentProbe };
|
package/src/lib/oidcAuth.js
CHANGED
|
@@ -7,6 +7,7 @@ const { createHttpClient } = require('./httpClient');
|
|
|
7
7
|
const DEFAULT_KEYCLOAK_URL = 'https://auth.xns.tech/auth';
|
|
8
8
|
const DEFAULT_REALM = 'scprime';
|
|
9
9
|
const DEFAULT_CLIENT_ID = 'relayer-native';
|
|
10
|
+
const DEFAULT_SIGNIN_TIMEOUT_MS = 1800000; // 30 minutes
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* OIDC Authorization Code + PKCE (S256) token acquisition.
|
|
@@ -53,6 +54,7 @@ async function acquireToken(opts = {}) {
|
|
|
53
54
|
challenge,
|
|
54
55
|
openBrowser,
|
|
55
56
|
createServer: _createServer,
|
|
57
|
+
timeoutMs: opts.timeoutMs,
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
// 5. Exchange code for tokens
|
|
@@ -157,7 +159,7 @@ function captureAuthCode(opts) {
|
|
|
157
159
|
|
|
158
160
|
const error = url.searchParams.get('error');
|
|
159
161
|
if (error) {
|
|
160
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
162
|
+
res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
161
163
|
res.end('<html><body><h1>Authentication failed</h1><p>You can close this window.</p></body></html>');
|
|
162
164
|
clearTimeout(timeoutHandle);
|
|
163
165
|
srv.close();
|
|
@@ -166,7 +168,7 @@ function captureAuthCode(opts) {
|
|
|
166
168
|
|
|
167
169
|
const code = url.searchParams.get('code');
|
|
168
170
|
if (!code) {
|
|
169
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
171
|
+
res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
170
172
|
res.end('<html><body><h1>Missing authorization code</h1></body></html>');
|
|
171
173
|
return; // Don't close server — wait for the real redirect
|
|
172
174
|
}
|
|
@@ -174,14 +176,14 @@ function captureAuthCode(opts) {
|
|
|
174
176
|
// R5-STATE-1: Validate OIDC state parameter to prevent CSRF
|
|
175
177
|
const returnedState = url.searchParams.get('state');
|
|
176
178
|
if (returnedState !== expectedState) {
|
|
177
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
179
|
+
res.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
178
180
|
res.end('<html><body><h1>Invalid state parameter</h1><p>Possible CSRF attack. Please try again.</p></body></html>');
|
|
179
181
|
clearTimeout(timeoutHandle);
|
|
180
182
|
srv.close();
|
|
181
183
|
return reject(new Error('OIDC callback state mismatch — possible CSRF. Please try again.'));
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
186
|
+
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
185
187
|
res.end('<html><body><h1>Authentication successful</h1><p>You can close this window and return to the agent.</p></body></html>');
|
|
186
188
|
clearTimeout(timeoutHandle);
|
|
187
189
|
|
|
@@ -210,17 +212,26 @@ function captureAuthCode(opts) {
|
|
|
210
212
|
|
|
211
213
|
const authorizeUrl = `${keycloakUrl}/realms/${realm}/protocol/openid-connect/auth?${params}`;
|
|
212
214
|
|
|
215
|
+
// Arm the timeout BEFORE opening the browser — a synchronous
|
|
216
|
+
// openBrowser can resolve the flow first, and a timer created
|
|
217
|
+
// after that would never be cleared, pinning the process open.
|
|
218
|
+
// 5 minutes proved too short for a human who gets interrupted
|
|
219
|
+
// (FT-1, 2026-08-14); invalid overrides fall back to the default.
|
|
220
|
+
// Node clamps timer values above 2^31-1 to ~1ms and truncates
|
|
221
|
+
// fractions — accept only positive safe integers in timer range.
|
|
222
|
+
const timeoutMs = (Number.isInteger(opts.timeoutMs) && opts.timeoutMs > 0 && opts.timeoutMs <= 0x7fffffff)
|
|
223
|
+
? opts.timeoutMs
|
|
224
|
+
: DEFAULT_SIGNIN_TIMEOUT_MS;
|
|
225
|
+
timeoutHandle = setTimeout(() => {
|
|
226
|
+
srv.close();
|
|
227
|
+
reject(new Error(`OIDC sign-in timed out after ${Math.round(timeoutMs / 60000)} minutes. Please try again.`));
|
|
228
|
+
}, timeoutMs);
|
|
229
|
+
|
|
213
230
|
// Open browser or return URL for the agent to present
|
|
214
231
|
openBrowser(authorizeUrl).catch(() => {
|
|
215
232
|
// If browser open fails, the authorize_url is still available
|
|
216
233
|
});
|
|
217
234
|
});
|
|
218
|
-
|
|
219
|
-
// Timeout: 5 minutes for user to complete browser sign-in
|
|
220
|
-
timeoutHandle = setTimeout(() => {
|
|
221
|
-
srv.close();
|
|
222
|
-
reject(new Error('OIDC sign-in timed out after 5 minutes. Please try again.'));
|
|
223
|
-
}, 300000);
|
|
224
235
|
});
|
|
225
236
|
}
|
|
226
237
|
|
|
@@ -253,4 +264,4 @@ function defaultOpenBrowser(url) {
|
|
|
253
264
|
});
|
|
254
265
|
}
|
|
255
266
|
|
|
256
|
-
module.exports = { acquireToken, refreshToken, generateVerifier, generateChallenge };
|
|
267
|
+
module.exports = { acquireToken, refreshToken, generateVerifier, generateChallenge, DEFAULT_KEYCLOAK_URL, DEFAULT_REALM, DEFAULT_CLIENT_ID };
|
|
@@ -44,8 +44,8 @@ services:
|
|
|
44
44
|
volumes:
|
|
45
45
|
- relayer_data:/relayer # named volume — MUST match the channel bundle (bug #2)
|
|
46
46
|
ports:
|
|
47
|
-
- ${UI_PORT:-8888}:8888
|
|
48
|
-
- ${S3_PORT:-9000}:9000
|
|
47
|
+
- ${BIND_ADDRESS:-}${UI_PORT:-8888}:8888
|
|
48
|
+
- ${BIND_ADDRESS:-}${S3_PORT:-9000}:9000
|
|
49
49
|
env_file:
|
|
50
50
|
- .env
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ module.exports = function registerCheckEmailVerified(server, options = {}) {
|
|
|
57
57
|
done: true,
|
|
58
58
|
result: {
|
|
59
59
|
success: false,
|
|
60
|
-
message: `No account found for ${email}. Use
|
|
60
|
+
message: `No account found for ${email}. Use start_registration first.`,
|
|
61
61
|
exists: false,
|
|
62
62
|
verified: false,
|
|
63
63
|
},
|
|
@@ -82,7 +82,7 @@ module.exports = function registerCheckEmailVerified(server, options = {}) {
|
|
|
82
82
|
done: true,
|
|
83
83
|
result: {
|
|
84
84
|
success: false,
|
|
85
|
-
message: `No account found for ${email}. Use
|
|
85
|
+
message: `No account found for ${email}. Use start_registration to create an account first.`,
|
|
86
86
|
verified: false,
|
|
87
87
|
exists: false,
|
|
88
88
|
},
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const net = require('net');
|
|
4
4
|
const { createHttpClient } = require('../lib/httpClient');
|
|
5
5
|
const { createDockerUtil } = require('../lib/dockerUtil');
|
|
6
|
+
const { environmentProbe: defaultEnvironmentProbe } = require('../lib/environmentProbe');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Tool 1: check_prerequisites
|
|
@@ -32,6 +33,7 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
32
33
|
const docker = options.dockerUtil || createDockerUtil(options);
|
|
33
34
|
const http = options.httpClient || createHttpClient(options);
|
|
34
35
|
const _checkPort = options.checkPort || checkPort;
|
|
36
|
+
const _environmentProbe = options.environmentProbe || defaultEnvironmentProbe;
|
|
35
37
|
|
|
36
38
|
server.tool(
|
|
37
39
|
'check_prerequisites',
|
|
@@ -46,10 +48,21 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
46
48
|
// 1. Docker available — and WHERE it runs. With DOCKER_HOST or an
|
|
47
49
|
// ssh:// context (e.g. Claude Code on a jump host), the daemon is
|
|
48
50
|
// on another machine and the local checks below must adapt.
|
|
49
|
-
|
|
51
|
+
const DEFAULT_DOCKER_HOST = { remote: false, host: 'localhost', endpoint: null };
|
|
52
|
+
let dockerHost = DEFAULT_DOCKER_HOST;
|
|
50
53
|
try {
|
|
51
54
|
await docker.docker(['info', '--format', '{{.ServerVersion}}']);
|
|
52
|
-
|
|
55
|
+
const raw = await docker.getDockerHost();
|
|
56
|
+
// remote without a usable host is incomplete metadata — treat
|
|
57
|
+
// as local so the port checks run instead of silently skipping
|
|
58
|
+
// against a host we cannot name.
|
|
59
|
+
const remoteHost = typeof raw?.host === 'string' ? raw.host.trim() : '';
|
|
60
|
+
const isRemote = Boolean(raw?.remote) && remoteHost !== '' && remoteHost !== 'localhost';
|
|
61
|
+
dockerHost = {
|
|
62
|
+
remote: isRemote,
|
|
63
|
+
host: isRemote ? remoteHost : 'localhost',
|
|
64
|
+
endpoint: raw?.endpoint ?? null,
|
|
65
|
+
};
|
|
53
66
|
checks.push({
|
|
54
67
|
name: 'docker',
|
|
55
68
|
passed: true,
|
|
@@ -119,6 +132,29 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
119
132
|
checks.push({ name: 'existing_install', passed: true, detail: 'Existing-install check skipped (Docker not reachable)' });
|
|
120
133
|
}
|
|
121
134
|
|
|
135
|
+
// 3c. Ephemeral environment — finding, never a failure.
|
|
136
|
+
try {
|
|
137
|
+
const probe = _environmentProbe();
|
|
138
|
+
if (probe.ephemeral) {
|
|
139
|
+
const remoteDocker = dockerHost.remote;
|
|
140
|
+
checks.push({
|
|
141
|
+
name: 'ephemeral_environment',
|
|
142
|
+
passed: true,
|
|
143
|
+
warning: true,
|
|
144
|
+
detail: remoteDocker
|
|
145
|
+
? `This environment appears to be ephemeral (${probe.signals.join('; ')}), but Docker targets a remote host (${dockerHost.host}). Persistence depends on the remote Docker host.`
|
|
146
|
+
: `This environment appears to be ephemeral (${probe.signals.join('; ')}). A Relayer installed here will be lost when the container exits.`,
|
|
147
|
+
remediation: remoteDocker
|
|
148
|
+
? 'The Relayer will be installed on the remote Docker host. Verify that host has persistent storage.'
|
|
149
|
+
: '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',
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Environment appears persistent — install will survive restarts' });
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Ephemeral-environment check skipped (probe error)' });
|
|
156
|
+
}
|
|
157
|
+
|
|
122
158
|
// 4. Disk space (need at least 10 GB free — basic docker images + data)
|
|
123
159
|
try {
|
|
124
160
|
await docker.docker(['system', 'df', '--format', '{{.TotalCount}}']);
|
|
@@ -2,8 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
const { z } = require('zod');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const net = require('net');
|
|
5
6
|
const { createDockerUtil } = require('../lib/dockerUtil');
|
|
6
7
|
|
|
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
|
+
|
|
10
|
+
// R5 input boundary: this value is written verbatim into the .env the installer
|
|
11
|
+
// authors, and Compose auto-loads that file. An unvalidated newline injects
|
|
12
|
+
// further KEY=VALUE lines — including a second UI_PORT, which wins last-value
|
|
13
|
+
// and silently republishes on a port this tool then misreports in its own
|
|
14
|
+
// success JSON. A charset-only guard stops that but still accepts values Docker
|
|
15
|
+
// cannot bind (`[`, `999.999.999.999`, `127.0.0.1:`, raw IPv6, hostnames), which
|
|
16
|
+
// produce an invalid port mapping at `compose up` instead of a clear error here.
|
|
17
|
+
// So each documented form is validated whole.
|
|
18
|
+
//
|
|
19
|
+
// Hostnames are NOT accepted: the Compose ports short syntax defines the host
|
|
20
|
+
// component as an IP address (docs.docker.com/reference/compose-file/services).
|
|
21
|
+
// "localhost:8888:8888" is not a resolvable-then-bound mapping — it is a
|
|
22
|
+
// malformed one. Rejecting here is a clear error instead of a compose failure.
|
|
23
|
+
function isValidBindAddress(value) {
|
|
24
|
+
if (value === '') return true; // default: all interfaces
|
|
25
|
+
if (net.isIPv4(value)) return true;
|
|
26
|
+
// Raw (unbracketed) IPv6 is ambiguous against the host:container port
|
|
27
|
+
// separator — Docker requires brackets.
|
|
28
|
+
if (value.startsWith('[') && value.endsWith(']')) {
|
|
29
|
+
return net.isIPv6(value.slice(1, -1));
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
7
34
|
// Canonical released install — the full beta channel bundle (relayer +
|
|
8
35
|
// monitoring stack). Versioned in the deploy repo, shipped to web01 by
|
|
9
36
|
// `deploy.py promote`, served login-free. THE default install source.
|
|
@@ -43,14 +70,19 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
43
70
|
|
|
44
71
|
server.tool(
|
|
45
72
|
'install_relayer',
|
|
46
|
-
'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.',
|
|
73
|
+
'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.',
|
|
47
74
|
{
|
|
48
75
|
install_path: z.string().optional().default('/opt/xns-relayer').describe('Directory to install the compose file into'),
|
|
49
|
-
ui_port: z.number().int().
|
|
50
|
-
s3_port: z.number().int().
|
|
51
|
-
compose_url: z.string().url().optional().describe('OPTIONAL override: URL to a custom docker-compose.yml. Omit for the normal released install.'),
|
|
76
|
+
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.'),
|
|
77
|
+
s3_port: z.number().int().min(1).max(65535).optional().default(9000).describe('Host port for the S3 API (container 9000). Docker publishes this port on the interface chosen by bind_address.'),
|
|
78
|
+
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.'),
|
|
79
|
+
// R5 input boundary — see isValidBindAddress above for why each
|
|
80
|
+
// documented address form is validated whole rather than by charset.
|
|
81
|
+
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 path and 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.'),
|
|
82
|
+
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.'),
|
|
83
|
+
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.'),
|
|
52
84
|
},
|
|
53
|
-
async ({ install_path, ui_port, s3_port, compose_url }) => {
|
|
85
|
+
async ({ install_path, ui_port, s3_port, compose_url, bind_address, ui_tls_enabled, s3_tls_enabled }) => {
|
|
54
86
|
try {
|
|
55
87
|
const { execFile: nodeExecFile } = require('child_process');
|
|
56
88
|
const execFileFn = _execFile || nodeExecFile;
|
|
@@ -92,6 +124,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
92
124
|
});
|
|
93
125
|
});
|
|
94
126
|
|
|
127
|
+
const bindPrefix = bind_address ? `${bind_address}:` : '';
|
|
95
128
|
let source;
|
|
96
129
|
let note;
|
|
97
130
|
if (compose_url) {
|
|
@@ -112,7 +145,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
112
145
|
source = 'bundled-fallback';
|
|
113
146
|
note = `Channel bundle fetch failed (${fetchErr.message}) — fell back to the bundled compose. Same services; re-running install later is not required.`;
|
|
114
147
|
}
|
|
115
|
-
await fsp.writeFile(envPath, `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\n`);
|
|
148
|
+
await fsp.writeFile(envPath, `UI_PORT=${ui_port}\nS3_PORT=${s3_port}\nBIND_ADDRESS=${bindPrefix}\n`);
|
|
116
149
|
}
|
|
117
150
|
|
|
118
151
|
// Run docker compose up -d. cwd + env so ${UI_PORT}/${S3_PORT}
|
|
@@ -120,7 +153,7 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
120
153
|
// regardless of where the MCP process was launched.
|
|
121
154
|
await docker.composeUp(composePath, {
|
|
122
155
|
cwd: install_path,
|
|
123
|
-
env: { ...process.env, UI_PORT: String(ui_port), S3_PORT: String(s3_port) },
|
|
156
|
+
env: { ...process.env, UI_PORT: String(ui_port), S3_PORT: String(s3_port), BIND_ADDRESS: bindPrefix },
|
|
124
157
|
});
|
|
125
158
|
|
|
126
159
|
return {
|
|
@@ -132,6 +165,34 @@ module.exports = function registerInstallRelayer(server, options = {}) {
|
|
|
132
165
|
compose_path: composePath,
|
|
133
166
|
install_path,
|
|
134
167
|
source,
|
|
168
|
+
// D5/W5: state the binding at install time, out-of-band, so a
|
|
169
|
+
// refused connection is explainable later. Two statements, never
|
|
170
|
+
// merged (PRD §7): `composed_from` is what this installer asserts
|
|
171
|
+
// it composed; `reachability` is only CONFIGURED — this process
|
|
172
|
+
// cannot verify the host actually published it, so it says so and
|
|
173
|
+
// points at `docker port` (the host-side source of truth) instead
|
|
174
|
+
// of guessing.
|
|
175
|
+
// The container ports are known only for the channel compose
|
|
176
|
+
// this installer fetches. A caller-supplied compose_url may
|
|
177
|
+
// remap them, and this process never reads that file — so it
|
|
178
|
+
// says null rather than restating 8888/9000 it cannot stand
|
|
179
|
+
// behind (correct-or-absent, same rule as the port readout).
|
|
180
|
+
binding: {
|
|
181
|
+
bind_address: bind_address || '0.0.0.0 (all interfaces)',
|
|
182
|
+
bind_address_applied: source === 'bundled-fallback'
|
|
183
|
+
? 'yes — the bundled fallback compose references BIND_ADDRESS in its port declarations'
|
|
184
|
+
: 'unknown — the fetched compose may or may not reference BIND_ADDRESS in its port declarations; this installer does not read the fetched file',
|
|
185
|
+
ui: { host_port: ui_port, container_port: compose_url ? null : 8888 },
|
|
186
|
+
s3: { host_port: s3_port, container_port: compose_url ? null : 9000 },
|
|
187
|
+
composed_from: compose_url
|
|
188
|
+
? `UI_PORT=${ui_port}, S3_PORT=${s3_port}, BIND_ADDRESS=${bindPrefix} passed to docker compose (no .env written on the compose_url override path)`
|
|
189
|
+
: `UI_PORT=${ui_port}, S3_PORT=${s3_port}, BIND_ADDRESS=${bindPrefix} written to ${envPath}`,
|
|
190
|
+
reachability: 'configured — not verified from this process; run `docker port xns-relayer` on the host to see actual Docker publication',
|
|
191
|
+
},
|
|
192
|
+
tls: {
|
|
193
|
+
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).' },
|
|
194
|
+
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).' },
|
|
195
|
+
},
|
|
135
196
|
...(note ? { note } : {}),
|
|
136
197
|
}, null, 2),
|
|
137
198
|
}],
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
DEFAULT_KEYCLOAK_URL,
|
|
5
|
+
DEFAULT_REALM,
|
|
6
|
+
DEFAULT_CLIENT_ID,
|
|
7
|
+
generateVerifier,
|
|
8
|
+
generateChallenge,
|
|
9
|
+
} = require('../lib/oidcAuth');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Tool 2: start_registration
|
|
13
|
+
*
|
|
14
|
+
* Returns the Keycloak self-registration URL for the configured realm and
|
|
15
|
+
* client. The agent presents this URL to the user for browser sign-up —
|
|
16
|
+
* no password is ever handled by the MCP. After registration, use
|
|
17
|
+
* check_email_verified to poll for verification status.
|
|
18
|
+
*
|
|
19
|
+
* A fresh disposable PKCE pair is generated per call to satisfy the
|
|
20
|
+
* relayer-native client's S256 requirement. The verifier is discarded —
|
|
21
|
+
* no token exchange happens; check_email_verified is the completion signal.
|
|
22
|
+
*/
|
|
23
|
+
module.exports = function registerStartRegistration(server, options = {}) {
|
|
24
|
+
const keycloakUrl = options.keycloakUrl || DEFAULT_KEYCLOAK_URL;
|
|
25
|
+
const realm = options.realm || DEFAULT_REALM;
|
|
26
|
+
const clientId = options.clientId || DEFAULT_CLIENT_ID;
|
|
27
|
+
|
|
28
|
+
server.tool(
|
|
29
|
+
'start_registration',
|
|
30
|
+
'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.',
|
|
31
|
+
{},
|
|
32
|
+
async () => {
|
|
33
|
+
const verifier = generateVerifier();
|
|
34
|
+
const challenge = generateChallenge(verifier);
|
|
35
|
+
const redirectUri = 'http://127.0.0.1:41337/callback';
|
|
36
|
+
|
|
37
|
+
const params = new URLSearchParams({
|
|
38
|
+
client_id: clientId,
|
|
39
|
+
response_type: 'code',
|
|
40
|
+
scope: 'openid',
|
|
41
|
+
redirect_uri: redirectUri,
|
|
42
|
+
code_challenge: challenge,
|
|
43
|
+
code_challenge_method: 'S256',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const registrationUrl = `${keycloakUrl}/realms/${realm}/protocol/openid-connect/registrations?${params}`;
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
content: [{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: JSON.stringify({
|
|
52
|
+
success: true,
|
|
53
|
+
registration_url: registrationUrl,
|
|
54
|
+
message: `Open this URL in a browser to create an XNS account. After signing up, use check_email_verified to confirm the email address was verified. Note: after completing registration, the browser may show a connection error on the final redirect page — this is expected and harmless.`,
|
|
55
|
+
}, null, 2),
|
|
56
|
+
}],
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -3,81 +3,265 @@
|
|
|
3
3
|
const { z } = require('zod');
|
|
4
4
|
const { createS3Client } = require('../lib/s3Client');
|
|
5
5
|
const { createDockerUtil } = require('../lib/dockerUtil');
|
|
6
|
+
const { createHttpClient } = require('../lib/httpClient');
|
|
7
|
+
const { createTokenManager } = require('../lib/ensureToken');
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Tool 10: verify_storage
|
|
9
|
-
* AC-20: targets the S3 gateway on port 9000 plain HTTP; reports endpoint.
|
|
10
|
-
* AC-21: verify fail → names the failing step (CreateBucket/PutObject/GetObject).
|
|
11
|
-
* W3-AC1: cleanup in finally — always removes mcp-verify-* bucket/object; failure
|
|
12
|
-
* is non-fatal (noted in response, never flips pass→fail).
|
|
13
|
-
* W3-AC2: fullaccess credential requirement stated in description and error output.
|
|
14
|
-
* W3-AC3: explicit-IP hint when endpoint was auto-detected.
|
|
15
|
-
* R6: S3 credentials must be provided (from relayer-ui IAM key-mgmt flow).
|
|
16
11
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* Self-provisioning S3 round-trip verification. When called with only a
|
|
13
|
+
* muse_token, mints a throwaway IAM user with a scoped policy restricted to
|
|
14
|
+
* mcp-verify-* buckets, runs CreateBucket -> PutObject -> GetObject -> Compare,
|
|
15
|
+
* and tears everything down in finally — pass or fail.
|
|
16
|
+
*
|
|
17
|
+
* Optional access_key_id/secret_access_key skip minting entirely.
|
|
18
|
+
* The minted credential lives in memory only — zero fs usage.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validate that a URL points to a loopback, RFC-1918 private, or .local host.
|
|
23
|
+
* Rejects public/internet-routable hosts to prevent token forwarding.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} urlString - A fully qualified URL
|
|
26
|
+
* @returns {{ allowed: boolean, reason?: string }}
|
|
20
27
|
*/
|
|
28
|
+
function validateHostAllowlist(urlString) {
|
|
29
|
+
let parsed;
|
|
30
|
+
try {
|
|
31
|
+
parsed = new URL(urlString);
|
|
32
|
+
} catch {
|
|
33
|
+
return { allowed: false, reason: 'URL is malformed' };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
37
|
+
|
|
38
|
+
if (hostname === 'localhost' || hostname === '[::1]' || hostname === '::1') {
|
|
39
|
+
return { allowed: true };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (hostname.endsWith('.local')) {
|
|
43
|
+
return { allowed: true };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ipv4Match = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
47
|
+
if (ipv4Match) {
|
|
48
|
+
const octets = ipv4Match.slice(1).map(Number);
|
|
49
|
+
if (octets[0] === 127) return { allowed: true };
|
|
50
|
+
if (octets[0] === 10) return { allowed: true };
|
|
51
|
+
if (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) return { allowed: true };
|
|
52
|
+
if (octets[0] === 192 && octets[1] === 168) return { allowed: true };
|
|
53
|
+
return { allowed: false, reason: `Host ${hostname} is not a loopback or private-network address. Allowed: localhost, 127.0.0.0/8, ::1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, *.local` };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { allowed: false, reason: `Host '${hostname}' is not a loopback, private-network, or .local address. Allowed: localhost, 127.0.0.0/8, ::1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, *.local` };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const NO_REDIRECT_TOKEN_CONFIG = { maxRedirects: 0 };
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* An error whose message is authored by this tool (no caught provider text)
|
|
63
|
+
* and therefore safe to return to the MCP client verbatim.
|
|
64
|
+
*/
|
|
65
|
+
function safeError(message) {
|
|
66
|
+
return Object.assign(new Error(message), { userSafe: true });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isNotFoundResponse(msg) {
|
|
70
|
+
if (typeof msg !== 'string') return false;
|
|
71
|
+
return /not.found|does.not.exist/i.test(msg);
|
|
72
|
+
}
|
|
73
|
+
|
|
21
74
|
module.exports = function registerVerifyStorage(server, options = {}) {
|
|
22
75
|
const _createS3Client = options.createS3Client || createS3Client;
|
|
23
76
|
const docker = options.dockerUtil || createDockerUtil(options);
|
|
77
|
+
const http = options.httpClient || createHttpClient(options);
|
|
78
|
+
const tokenMgr = createTokenManager(options);
|
|
24
79
|
|
|
25
80
|
server.tool(
|
|
26
81
|
'verify_storage',
|
|
27
|
-
'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.
|
|
82
|
+
'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.',
|
|
28
83
|
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
84
|
+
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.'),
|
|
85
|
+
access_key_id: z.string().optional().describe('S3 access key ID — when provided with secret_access_key, skips automatic credential provisioning'),
|
|
86
|
+
secret_access_key: z.string().optional().describe('S3 secret access key — when provided with access_key_id, skips automatic credential provisioning'),
|
|
87
|
+
relayer_ui_url: z.string().trim().url().optional().default('http://localhost:8888').describe('Relayer UI base URL (default: http://localhost:8888)'),
|
|
88
|
+
endpoint: z.string().trim().url().optional().describe('S3 endpoint URL. Default: http://{docker-host}:9000. Pass an explicit IP (e.g. http://192.168.1.100:9000) when auto-detection cannot reach the host.'),
|
|
32
89
|
},
|
|
33
|
-
async ({ access_key_id, secret_access_key, endpoint }) => {
|
|
34
|
-
const
|
|
90
|
+
async ({ muse_token, access_key_id, secret_access_key, relayer_ui_url = 'http://localhost:8888', endpoint }) => {
|
|
91
|
+
const runTs = Date.now();
|
|
92
|
+
const testBucket = `mcp-verify-${runTs}`;
|
|
35
93
|
const testKey = 'verify-test.txt';
|
|
36
|
-
const testContent = `relayer-mcp verification ${
|
|
94
|
+
const testContent = `relayer-mcp verification ${runTs}`;
|
|
37
95
|
let currentStep = 'init';
|
|
38
96
|
let endpointAutoDetected = false;
|
|
39
97
|
|
|
40
|
-
let
|
|
98
|
+
let mintedUser = null;
|
|
99
|
+
let mintedPolicyName = null;
|
|
100
|
+
let bucketCreated = false;
|
|
101
|
+
let policyCreated = false;
|
|
102
|
+
let policyAttached = false;
|
|
103
|
+
let mintConfirmed = false;
|
|
104
|
+
let bucketConfirmed = false;
|
|
105
|
+
let policyConfirmed = false;
|
|
106
|
+
let attachConfirmed = false;
|
|
107
|
+
let effectiveAK = access_key_id;
|
|
108
|
+
let effectiveSK = secret_access_key;
|
|
109
|
+
let result;
|
|
110
|
+
let isError = false;
|
|
111
|
+
|
|
112
|
+
const baseUrl = relayer_ui_url.replace(/\/+$/, '');
|
|
41
113
|
|
|
42
114
|
try {
|
|
115
|
+
const hostCheck = validateHostAllowlist(baseUrl);
|
|
116
|
+
if (!hostCheck.allowed) {
|
|
117
|
+
throw safeError(`relayer_ui_url rejected: ${hostCheck.reason}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
43
120
|
if (!endpoint) {
|
|
44
121
|
const { host } = await docker.getDockerHost();
|
|
45
122
|
endpoint = `http://${host}:9000`;
|
|
46
123
|
endpointAutoDetected = true;
|
|
47
124
|
}
|
|
125
|
+
|
|
126
|
+
const usePassthrough = effectiveAK && effectiveSK;
|
|
127
|
+
|
|
128
|
+
if (!usePassthrough) {
|
|
129
|
+
if (!muse_token) {
|
|
130
|
+
// BUG-366: reuse the OIDC session get_host_tags/configure_vpd
|
|
131
|
+
// established (shared token state), or start a browser sign-in.
|
|
132
|
+
// No tool emits the token, so requiring it as a parameter
|
|
133
|
+
// dead-ended every agent on the no-keys path.
|
|
134
|
+
//
|
|
135
|
+
// The session token is server-held — never forward it to a
|
|
136
|
+
// caller-selected origin. The fallback only targets the
|
|
137
|
+
// server-owned base, matching restart_service/manage_backups.
|
|
138
|
+
const serverOwnedBase = (options.relayerUiBase || 'http://localhost:8888').replace(/\/+$/, '');
|
|
139
|
+
if (baseUrl !== serverOwnedBase) {
|
|
140
|
+
throw safeError('The OIDC session fallback only targets the server-configured Relayer UI base (default http://localhost:8888). Pass muse_token or access_key_id/secret_access_key explicitly when targeting a custom relayer_ui_url.');
|
|
141
|
+
}
|
|
142
|
+
currentStep = 'SignIn';
|
|
143
|
+
try {
|
|
144
|
+
muse_token = await tokenMgr.ensureToken();
|
|
145
|
+
} catch (signInErr) {
|
|
146
|
+
console.error(`[verify_storage] SignIn: ${signInErr.message}`);
|
|
147
|
+
throw safeError('OIDC sign-in did not complete. Run get_host_tags first to sign in, or pass muse_token or access_key_id/secret_access_key.');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
currentStep = 'MintUser';
|
|
152
|
+
const userName = `mcp-verify-${runTs}`;
|
|
153
|
+
mintedUser = userName;
|
|
154
|
+
const { status: mintStatus, data: mintData } = await http.post(
|
|
155
|
+
`${baseUrl}/api/v1/mc/user`,
|
|
156
|
+
{ user: userName },
|
|
157
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
158
|
+
);
|
|
159
|
+
if (mintStatus !== 200) {
|
|
160
|
+
// Definitive refusal — the server answered, no user was
|
|
161
|
+
// created, so a cleanup attempt would only cry wolf.
|
|
162
|
+
// A thrown request (no response) keeps the intent flag.
|
|
163
|
+
mintedUser = null;
|
|
164
|
+
throw new Error(`Mint user failed (HTTP ${mintStatus})`);
|
|
165
|
+
}
|
|
166
|
+
effectiveAK = mintData?.access_key;
|
|
167
|
+
effectiveSK = mintData?.secret_key;
|
|
168
|
+
|
|
169
|
+
if (mintData?.success === false) {
|
|
170
|
+
mintedUser = null;
|
|
171
|
+
throw new Error('Mint user failed');
|
|
172
|
+
}
|
|
173
|
+
if (!effectiveAK || !effectiveSK) {
|
|
174
|
+
// HTTP 200 without keys is ambiguous — the user may
|
|
175
|
+
// exist, so keep the cleanup intent.
|
|
176
|
+
throw new Error('Mint user failed: response missing access_key/secret_key');
|
|
177
|
+
}
|
|
178
|
+
mintConfirmed = true;
|
|
179
|
+
|
|
180
|
+
currentStep = 'CreatePolicy';
|
|
181
|
+
mintedPolicyName = `mcp-verify-policy-${runTs}`;
|
|
182
|
+
policyCreated = true;
|
|
183
|
+
const policyDocument = JSON.stringify({
|
|
184
|
+
Version: '2012-10-17',
|
|
185
|
+
Statement: [{
|
|
186
|
+
Effect: 'Allow',
|
|
187
|
+
Action: [
|
|
188
|
+
's3:CreateBucket',
|
|
189
|
+
's3:DeleteBucket',
|
|
190
|
+
's3:ListBucket',
|
|
191
|
+
's3:PutObject',
|
|
192
|
+
's3:GetObject',
|
|
193
|
+
's3:DeleteObject',
|
|
194
|
+
],
|
|
195
|
+
Resource: [
|
|
196
|
+
'arn:aws:s3:::mcp-verify-*',
|
|
197
|
+
'arn:aws:s3:::mcp-verify-*/*',
|
|
198
|
+
],
|
|
199
|
+
}],
|
|
200
|
+
});
|
|
201
|
+
const { status: policyStatus, data: policyData } = await http.post(
|
|
202
|
+
`${baseUrl}/api/v1/mc/policy-create`,
|
|
203
|
+
{ name: mintedPolicyName, type: 'json', json: policyDocument },
|
|
204
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
205
|
+
);
|
|
206
|
+
if (policyStatus !== 200) {
|
|
207
|
+
policyCreated = false;
|
|
208
|
+
throw new Error(`Create policy failed (HTTP ${policyStatus})`);
|
|
209
|
+
}
|
|
210
|
+
if (!policyData?.success) {
|
|
211
|
+
policyCreated = false;
|
|
212
|
+
throw new Error('Create policy failed');
|
|
213
|
+
}
|
|
214
|
+
policyConfirmed = true;
|
|
215
|
+
|
|
216
|
+
currentStep = 'AttachPolicy';
|
|
217
|
+
policyAttached = true;
|
|
218
|
+
const { status: attachStatus, data: attachData } = await http.post(
|
|
219
|
+
`${baseUrl}/api/v1/mc/policy`,
|
|
220
|
+
{ name: mintedUser, policy: mintedPolicyName },
|
|
221
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
222
|
+
);
|
|
223
|
+
if (attachStatus !== 200) {
|
|
224
|
+
policyAttached = false;
|
|
225
|
+
throw new Error(`Attach policy failed (HTTP ${attachStatus})`);
|
|
226
|
+
}
|
|
227
|
+
if (attachData?.status !== 'attached') {
|
|
228
|
+
policyAttached = false;
|
|
229
|
+
throw new Error('Attach policy failed');
|
|
230
|
+
}
|
|
231
|
+
attachConfirmed = true;
|
|
232
|
+
}
|
|
233
|
+
|
|
48
234
|
const s3 = _createS3Client({
|
|
49
235
|
endpoint,
|
|
50
|
-
accessKeyId:
|
|
51
|
-
secretAccessKey:
|
|
236
|
+
accessKeyId: effectiveAK,
|
|
237
|
+
secretAccessKey: effectiveSK,
|
|
52
238
|
});
|
|
53
239
|
|
|
54
|
-
// Step 1: CreateBucket
|
|
55
240
|
currentStep = 'CreateBucket';
|
|
241
|
+
bucketCreated = true;
|
|
56
242
|
await s3.createBucket(testBucket);
|
|
243
|
+
bucketConfirmed = true;
|
|
57
244
|
|
|
58
|
-
// Step 2: PutObject
|
|
59
245
|
currentStep = 'PutObject';
|
|
60
246
|
await s3.putObject(testBucket, testKey, testContent);
|
|
61
247
|
|
|
62
|
-
// Step 3: GetObject
|
|
63
248
|
currentStep = 'GetObject';
|
|
64
249
|
const retrieved = await s3.getObject(testBucket, testKey);
|
|
65
250
|
|
|
66
|
-
// Step 4: Compare
|
|
67
251
|
currentStep = 'Compare';
|
|
68
252
|
if (retrieved !== testContent) {
|
|
69
|
-
|
|
253
|
+
result = {
|
|
70
254
|
success: false,
|
|
71
|
-
error: 'Storage verification failed at Compare: uploaded content does not match downloaded content.
|
|
255
|
+
error: 'Storage verification failed at Compare: uploaded content does not match downloaded content.',
|
|
72
256
|
endpoint,
|
|
73
257
|
failing_step: 'Compare',
|
|
74
258
|
};
|
|
259
|
+
isError = true;
|
|
75
260
|
} else {
|
|
76
261
|
const explicitIpHint = endpointAutoDetected
|
|
77
|
-
?
|
|
262
|
+
? 'If auto-detection cannot reach the host, pass an explicit endpoint (e.g. "http://<ip>:9000").'
|
|
78
263
|
: null;
|
|
79
|
-
|
|
80
|
-
verifyResult = {
|
|
264
|
+
result = {
|
|
81
265
|
success: true,
|
|
82
266
|
message: `S3 storage verification passed. Successfully created bucket, uploaded object, and verified download at ${endpoint}.`,
|
|
83
267
|
endpoint,
|
|
@@ -85,68 +269,113 @@ module.exports = function registerVerifyStorage(server, options = {}) {
|
|
|
85
269
|
...(explicitIpHint ? { note: explicitIpHint } : {}),
|
|
86
270
|
};
|
|
87
271
|
}
|
|
88
|
-
|
|
89
|
-
// Cleanup: remove test object and bucket (W3-AC1)
|
|
90
|
-
try {
|
|
91
|
-
await s3.deleteObject(testBucket, testKey);
|
|
92
|
-
await s3.deleteBucket(testBucket);
|
|
93
|
-
} catch (cleanupErr) {
|
|
94
|
-
// Non-fatal: note it but never flip the result
|
|
95
|
-
verifyResult.cleanup_warning = `Test bucket cleanup failed (${cleanupErr.message}). The bucket "${testBucket}" may remain — remove it manually via the Relayer UI.`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
content: [{
|
|
100
|
-
type: 'text',
|
|
101
|
-
text: JSON.stringify(verifyResult, null, 2),
|
|
102
|
-
}],
|
|
103
|
-
...(verifyResult.success ? {} : { isError: true }),
|
|
104
|
-
};
|
|
105
272
|
} catch (err) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
273
|
+
console.error(`[verify_storage] ${currentStep}: ${err.message}`);
|
|
274
|
+
const explicitIpHint = endpointAutoDetected
|
|
275
|
+
? ' If the endpoint cannot be reached, pass an explicit IP via the endpoint option (e.g. "http://<ip>:9000").'
|
|
276
|
+
: '';
|
|
277
|
+
// Self-authored messages (userSafe) reach the client; anything
|
|
278
|
+
// that may carry provider/response text stays in the server log.
|
|
279
|
+
const detail = err.userSafe ? ` ${err.message}` : ' See server log for detail.';
|
|
280
|
+
result = {
|
|
281
|
+
success: false,
|
|
282
|
+
error: `Storage verification failed at ${currentStep}.${detail}${explicitIpHint}`,
|
|
283
|
+
endpoint,
|
|
284
|
+
failing_step: currentStep,
|
|
285
|
+
};
|
|
286
|
+
isError = true;
|
|
287
|
+
} finally {
|
|
288
|
+
const warnings = [];
|
|
289
|
+
|
|
290
|
+
if (bucketCreated) {
|
|
110
291
|
try {
|
|
111
292
|
const s3Cleanup = _createS3Client({
|
|
112
293
|
endpoint,
|
|
113
|
-
accessKeyId:
|
|
114
|
-
secretAccessKey:
|
|
294
|
+
accessKeyId: effectiveAK,
|
|
295
|
+
secretAccessKey: effectiveSK,
|
|
115
296
|
});
|
|
116
297
|
await s3Cleanup.deleteObject(testBucket, testKey).catch(() => {});
|
|
117
298
|
await s3Cleanup.deleteBucket(testBucket);
|
|
118
|
-
} catch (
|
|
119
|
-
|
|
299
|
+
} catch (e) {
|
|
300
|
+
if (!isNotFoundResponse(e.message)) {
|
|
301
|
+
console.error(`[verify_storage] Bucket cleanup failed: ${e.message}`);
|
|
302
|
+
warnings.push('Test bucket cleanup failed (see server log)');
|
|
303
|
+
}
|
|
120
304
|
}
|
|
121
305
|
}
|
|
122
306
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
307
|
+
if (policyAttached) {
|
|
308
|
+
try {
|
|
309
|
+
const { data: detachData } = await http.post(
|
|
310
|
+
`${baseUrl}/api/v1/mc/policy-detach`,
|
|
311
|
+
{ name: mintedUser, policy: mintedPolicyName },
|
|
312
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
313
|
+
);
|
|
314
|
+
if (detachData?.status !== 'detached') {
|
|
315
|
+
const msg = detachData?.message ?? detachData?.error ?? '';
|
|
316
|
+
if (!isNotFoundResponse(msg)) {
|
|
317
|
+
console.error(`[verify_storage] Policy detach failed: ${JSON.stringify(detachData)}`);
|
|
318
|
+
warnings.push('Policy detach failed (see server log)');
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} catch (e) {
|
|
322
|
+
console.error(`[verify_storage] Policy detach failed: ${e.message}`);
|
|
323
|
+
warnings.push('Policy detach failed (see server log)');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
127
326
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
327
|
+
if (mintedUser) {
|
|
328
|
+
try {
|
|
329
|
+
const { data: delUserData } = await http.del(
|
|
330
|
+
`${baseUrl}/api/v1/mc/user/${mintedUser}`,
|
|
331
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
332
|
+
);
|
|
333
|
+
if (delUserData?.success === false) {
|
|
334
|
+
const msg = delUserData?.message ?? delUserData?.error ?? '';
|
|
335
|
+
if (!isNotFoundResponse(msg)) {
|
|
336
|
+
console.error(`[verify_storage] User cleanup failed: ${JSON.stringify(delUserData)}`);
|
|
337
|
+
warnings.push('User cleanup failed (see server log)');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
} catch (e) {
|
|
341
|
+
console.error(`[verify_storage] User cleanup failed: ${e.message}`);
|
|
342
|
+
warnings.push('User cleanup failed (see server log)');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
131
345
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
346
|
+
if (policyCreated) {
|
|
347
|
+
try {
|
|
348
|
+
const { data: delPolicyData } = await http.del(
|
|
349
|
+
`${baseUrl}/api/v1/mc/policy/${mintedPolicyName}`,
|
|
350
|
+
{ headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
|
|
351
|
+
);
|
|
352
|
+
if (delPolicyData?.status !== 'deleted') {
|
|
353
|
+
const msg = delPolicyData?.message ?? delPolicyData?.error ?? '';
|
|
354
|
+
if (!isNotFoundResponse(msg)) {
|
|
355
|
+
console.error(`[verify_storage] Policy cleanup failed: ${JSON.stringify(delPolicyData)}`);
|
|
356
|
+
warnings.push('Policy cleanup failed (see server log)');
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
} catch (e) {
|
|
360
|
+
console.error(`[verify_storage] Policy cleanup failed: ${e.message}`);
|
|
361
|
+
warnings.push('Policy cleanup failed (see server log)');
|
|
362
|
+
}
|
|
363
|
+
}
|
|
141
364
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
text: JSON.stringify(errorPayload),
|
|
146
|
-
}],
|
|
147
|
-
isError: true,
|
|
148
|
-
};
|
|
365
|
+
if (warnings.length > 0 && result) {
|
|
366
|
+
result.cleanup_warning = warnings.join('; ');
|
|
367
|
+
}
|
|
149
368
|
}
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
content: [{
|
|
372
|
+
type: 'text',
|
|
373
|
+
text: JSON.stringify(result, null, 2),
|
|
374
|
+
}],
|
|
375
|
+
...(isError ? { isError: true } : {}),
|
|
376
|
+
};
|
|
150
377
|
},
|
|
151
378
|
);
|
|
152
379
|
};
|
|
380
|
+
|
|
381
|
+
module.exports.validateHostAllowlist = validateHostAllowlist;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { z } = require('zod');
|
|
4
|
-
const { createHttpClient } = require('../lib/httpClient');
|
|
5
|
-
|
|
6
|
-
const CONSOLE_BASE_URL = 'https://console.xns.tech';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Tool 2: register_account
|
|
10
|
-
* AC-5: silent register, confirms account at {email}.
|
|
11
|
-
* AC-6: 409 → "email already has account" + next_action skip hint.
|
|
12
|
-
* AC-7: 422 → names the specific password rule.
|
|
13
|
-
* AC-8: Gate 1 dialogue names email + auth.xns.tech + auto-check.
|
|
14
|
-
*
|
|
15
|
-
* Consumes E2: POST /api/auth/register
|
|
16
|
-
* → 201 {success:true, userId, message:"Verification email sent"}
|
|
17
|
-
* → 409 {success:false, message} (already registered)
|
|
18
|
-
* → 422 {success:false, message} (validation error — password rules)
|
|
19
|
-
* → 429 {success:false, message} (rate limited)
|
|
20
|
-
*/
|
|
21
|
-
module.exports = function registerRegisterAccount(server, options = {}) {
|
|
22
|
-
const http = options.httpClient || createHttpClient(options);
|
|
23
|
-
const consoleBaseUrl = options.consoleBaseUrl || CONSOLE_BASE_URL;
|
|
24
|
-
|
|
25
|
-
server.tool(
|
|
26
|
-
'register_account',
|
|
27
|
-
'Register a new XNS account with an email and password. After registration, the user must verify their email at auth.xns.tech by clicking the link sent to their inbox. Use check_email_verified to poll for verification status. If the email already has an account, you can skip to install_relayer.',
|
|
28
|
-
{
|
|
29
|
-
email: z.string().email().describe('User email address'),
|
|
30
|
-
password: z.string().min(8).describe('Password (minimum 8 characters)'),
|
|
31
|
-
},
|
|
32
|
-
async ({ email, password }) => {
|
|
33
|
-
try {
|
|
34
|
-
const { status, data } = await http.post(
|
|
35
|
-
`${consoleBaseUrl}/api/auth/register`,
|
|
36
|
-
{ email, password },
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (status === 201) {
|
|
40
|
-
return {
|
|
41
|
-
content: [{
|
|
42
|
-
type: 'text',
|
|
43
|
-
text: JSON.stringify({
|
|
44
|
-
success: true,
|
|
45
|
-
message: `Account registered for ${email}. A verification email has been sent. The user must click the verification link at auth.xns.tech before proceeding. Use check_email_verified to poll for verification.`,
|
|
46
|
-
email,
|
|
47
|
-
userId: data.userId,
|
|
48
|
-
}),
|
|
49
|
-
}],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (status === 409) {
|
|
54
|
-
// AC-6: carry next_action skip hint
|
|
55
|
-
return {
|
|
56
|
-
content: [{
|
|
57
|
-
type: 'text',
|
|
58
|
-
text: JSON.stringify({
|
|
59
|
-
success: false,
|
|
60
|
-
message: `Email ${email} already has an account. You can skip registration and proceed directly to install_relayer.`,
|
|
61
|
-
next_action: 'skip_to_install',
|
|
62
|
-
email,
|
|
63
|
-
}),
|
|
64
|
-
}],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (status === 422) {
|
|
69
|
-
// AC-7: name the specific password rule
|
|
70
|
-
return {
|
|
71
|
-
content: [{
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: JSON.stringify({
|
|
74
|
-
success: false,
|
|
75
|
-
message: data.message || 'Validation error — check password requirements (minimum 8 characters, at least one uppercase, one lowercase, one number).',
|
|
76
|
-
email,
|
|
77
|
-
}),
|
|
78
|
-
}],
|
|
79
|
-
isError: true,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (status === 429) {
|
|
84
|
-
return {
|
|
85
|
-
content: [{
|
|
86
|
-
type: 'text',
|
|
87
|
-
text: JSON.stringify({
|
|
88
|
-
success: false,
|
|
89
|
-
message: data.message || 'Rate limited. Please wait before retrying registration.',
|
|
90
|
-
email,
|
|
91
|
-
}),
|
|
92
|
-
}],
|
|
93
|
-
isError: true,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Unexpected status
|
|
98
|
-
return {
|
|
99
|
-
content: [{
|
|
100
|
-
type: 'text',
|
|
101
|
-
text: JSON.stringify({
|
|
102
|
-
success: false,
|
|
103
|
-
error: `Unexpected response (HTTP ${status}): ${data.message || JSON.stringify(data)}`,
|
|
104
|
-
email,
|
|
105
|
-
}),
|
|
106
|
-
}],
|
|
107
|
-
isError: true,
|
|
108
|
-
};
|
|
109
|
-
} catch (err) {
|
|
110
|
-
return {
|
|
111
|
-
content: [{
|
|
112
|
-
type: 'text',
|
|
113
|
-
text: JSON.stringify({
|
|
114
|
-
success: false,
|
|
115
|
-
error: `Registration request failed: ${err.message}`,
|
|
116
|
-
}),
|
|
117
|
-
}],
|
|
118
|
-
isError: true,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
);
|
|
123
|
-
};
|