@xns-cloud/relayer-mcp 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -4
- package/package.json +8 -2
- package/src/index.js +6 -2
- package/src/lib/environmentProbe.js +55 -0
- package/src/lib/hostAllowlist.js +57 -0
- package/src/lib/oidcAuth.js +22 -11
- package/src/tools/checkClaimStatus.js +14 -5
- package/src/tools/checkEmailVerified.js +14 -6
- package/src/tools/checkPrerequisites.js +49 -5
- package/src/tools/checkRelayerHealth.js +16 -7
- package/src/tools/configureVpd.js +13 -5
- package/src/tools/describeSettings.js +11 -3
- package/src/tools/getHostTags.js +11 -3
- package/src/tools/installRelayer.js +19 -11
- package/src/tools/manageBackups.js +28 -10
- package/src/tools/restartService.js +12 -4
- package/src/tools/setupCliCredentials.js +48 -8
- package/src/tools/startClaim.js +11 -3
- package/src/tools/startRegistration.js +68 -0
- package/src/tools/updateSettings.js +12 -4
- package/src/tools/verifyStorage.js +279 -78
- package/src/tools/registerAccount.js +0 -123
package/README.md
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
[](./LICENSE)
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
|
|
7
|
-
MCP server for XNS Relayer
|
|
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.00 per network-TB-month](https://xns.tech/pricing) — you pay for the parity your data is stored with, [$0 egress uncapped](https://xns.tech/pricing), [no minimum retention](https://xns.tech/pricing).
|
|
8
14
|
|
|
9
15
|
## Requirements
|
|
10
16
|
|
|
@@ -26,6 +32,19 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
|
|
|
26
32
|
|
|
27
33
|
If you start the MCP on an older Node, it exits immediately with this same guidance instead of a dependency stack trace.
|
|
28
34
|
|
|
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.
|
|
47
|
+
|
|
29
48
|
## Install
|
|
30
49
|
|
|
31
50
|
**Claude Code** (one command):
|
|
@@ -47,6 +66,19 @@ claude mcp add relayer -- npx @xns-cloud/relayer-mcp@latest
|
|
|
47
66
|
}
|
|
48
67
|
```
|
|
49
68
|
|
|
69
|
+
**Cursor** — add to `.cursor/mcp.json`:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"relayer": {
|
|
75
|
+
"command": "npx",
|
|
76
|
+
"args": ["@xns-cloud/relayer-mcp@latest"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
50
82
|
No separate install step required — npx fetches the package on demand.
|
|
51
83
|
|
|
52
84
|
## Tools
|
|
@@ -54,7 +86,7 @@ No separate install step required — npx fetches the package on demand.
|
|
|
54
86
|
| # | Tool | Purpose |
|
|
55
87
|
|---|------|---------|
|
|
56
88
|
| 1 | `check_prerequisites` | Verify Docker (local or remote), ports (8888, 9000), an existing installation, disk, and network connectivity. |
|
|
57
|
-
| 2 | `
|
|
89
|
+
| 2 | `start_registration` | Get the browser sign-up URL for creating an XNS account — the agent never handles credentials. |
|
|
58
90
|
| 3 | `check_email_verified` | Poll email verification status (15s interval, 30-min timeout). |
|
|
59
91
|
| 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. |
|
|
60
92
|
| 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. |
|
|
@@ -62,7 +94,7 @@ No separate install step required — npx fetches the package on demand.
|
|
|
62
94
|
| 7 | `check_claim_status` | Poll claim state (STATE_1 / STATE_2 / STATE_3). |
|
|
63
95
|
| 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). |
|
|
64
96
|
| 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`). |
|
|
65
|
-
| 10 | `verify_storage` | Round-trip S3 test (create bucket, put object, get object) against the S3 gateway
|
|
97
|
+
| 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. |
|
|
66
98
|
| 11 | `setup_cli_credentials` | Provision S3 IAM credentials and write `~/.xns/credentials` so the XNS CLI works without further configuration. |
|
|
67
99
|
| 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. |
|
|
68
100
|
| 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. |
|
|
@@ -72,7 +104,7 @@ No separate install step required — npx fetches the package on demand.
|
|
|
72
104
|
## Onboarding Flow
|
|
73
105
|
|
|
74
106
|
1. Agent checks prerequisites (Tool 1).
|
|
75
|
-
2. Agent
|
|
107
|
+
2. Agent gets the browser sign-up URL; user creates an account in the browser (Tool 2).
|
|
76
108
|
3. User clicks email verification link; agent polls (Tool 3).
|
|
77
109
|
4. Agent installs and starts Relayer containers (Tool 4) — it writes the
|
|
78
110
|
released compose + `.env` itself; the user is never asked for a compose URL.
|
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.9.0",
|
|
5
5
|
"description": "MCP server for XNS Relayer onboarding and day-2 management — drives Relayer setup, settings, and backups conversationally over stdio, npx-ready",
|
|
6
6
|
"author": "SCP Corp",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,13 @@
|
|
|
35
35
|
"docker",
|
|
36
36
|
"self-hosted",
|
|
37
37
|
"storage",
|
|
38
|
-
"backup"
|
|
38
|
+
"backup",
|
|
39
|
+
"s3-compatible",
|
|
40
|
+
"claude",
|
|
41
|
+
"zero-egress",
|
|
42
|
+
"rag-infrastructure",
|
|
43
|
+
"agentic-workflows",
|
|
44
|
+
"agentic"
|
|
39
45
|
],
|
|
40
46
|
"engines": {
|
|
41
47
|
"node": ">=20"
|
package/src/index.js
CHANGED
|
@@ -13,14 +13,18 @@ if (!nodeCheck.ok) {
|
|
|
13
13
|
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
14
14
|
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
15
15
|
|
|
16
|
+
// Name and version both derive from package.json so the runtime server, the npm
|
|
17
|
+
// package, and the registry card cannot drift apart (CONTRACT-1, E-A2 review).
|
|
18
|
+
// package.json mcpName is the immutable registry identity, pinned by
|
|
19
|
+
// registryIdentity.test.js.
|
|
16
20
|
const server = new McpServer({
|
|
17
|
-
name: '
|
|
21
|
+
name: require('../package.json').mcpName,
|
|
18
22
|
version: require('../package.json').version,
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
// Register all 15 tools
|
|
22
26
|
require('./tools/checkPrerequisites')(server);
|
|
23
|
-
require('./tools/
|
|
27
|
+
require('./tools/startRegistration')(server);
|
|
24
28
|
require('./tools/checkEmailVerified')(server);
|
|
25
29
|
require('./tools/installRelayer')(server);
|
|
26
30
|
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 };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared host allowlist for tools that send credentials to a caller-supplied URL.
|
|
5
|
+
*
|
|
6
|
+
* Several tools accept a Relayer base URL as a parameter and then attach a Muse/Keycloak
|
|
7
|
+
* token to the request. Without a check, a caller can name any host and receive that
|
|
8
|
+
* token. This module is the one place that decides which hosts are acceptable.
|
|
9
|
+
*
|
|
10
|
+
* Extracted from verifyStorage.js, which had the only copy — see MR !33 (CodeRabbit
|
|
11
|
+
* flagged setup_cli_credentials forwarding a token to an unvalidated URL while a sibling
|
|
12
|
+
* tool in the same repo already guarded the identical parameter).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Validate that a URL points to a loopback, RFC-1918 private, or .local host.
|
|
17
|
+
* Rejects public/internet-routable hosts to prevent token forwarding.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} urlString - A fully qualified URL
|
|
20
|
+
* @returns {{ allowed: boolean, reason?: string }}
|
|
21
|
+
*/
|
|
22
|
+
function validateHostAllowlist(urlString) {
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(urlString);
|
|
26
|
+
} catch {
|
|
27
|
+
return { allowed: false, reason: 'URL is malformed' };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
31
|
+
|
|
32
|
+
if (hostname === 'localhost' || hostname === '[::1]' || hostname === '::1') {
|
|
33
|
+
return { allowed: true };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (hostname.endsWith('.local')) {
|
|
37
|
+
return { allowed: true };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const ipv4Match = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
41
|
+
if (ipv4Match) {
|
|
42
|
+
const octets = ipv4Match.slice(1).map(Number);
|
|
43
|
+
if (octets[0] === 127) return { allowed: true };
|
|
44
|
+
if (octets[0] === 10) return { allowed: true };
|
|
45
|
+
if (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) return { allowed: true };
|
|
46
|
+
if (octets[0] === 192 && octets[1] === 168) return { allowed: true };
|
|
47
|
+
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` };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
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` };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// A redirect on a token-bearing request would hand the token to the redirect target,
|
|
54
|
+
// defeating the allowlist above. Never follow one.
|
|
55
|
+
const NO_REDIRECT_TOKEN_CONFIG = { maxRedirects: 0 };
|
|
56
|
+
|
|
57
|
+
module.exports = { validateHostAllowlist, NO_REDIRECT_TOKEN_CONFIG };
|
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 };
|
|
@@ -24,12 +24,20 @@ module.exports = function registerCheckClaimStatus(server, options = {}) {
|
|
|
24
24
|
const pollInterval = options.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
25
25
|
const sleep = options.sleep;
|
|
26
26
|
|
|
27
|
-
server.
|
|
27
|
+
server.registerTool(
|
|
28
28
|
'check_claim_status',
|
|
29
|
-
'Poll the status of a claim session. Checks every 10 seconds. States: STATE_1 (pending — user has not yet opened the claim URL), STATE_2 (in progress — user is completing the claim in browser), STATE_3 (completed — claim successful). Automatically proceeds when STATE_3 is reached.',
|
|
30
29
|
{
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
title: 'check_claim_status',
|
|
31
|
+
description: 'Poll the status of a claim session. Checks every 10 seconds. States: STATE_1 (pending — user has not yet opened the claim URL), STATE_2 (in progress — user is completing the claim in browser), STATE_3 (completed — claim successful). Automatically proceeds when STATE_3 is reached.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
claim_id: z.string().describe('The claim_id returned by start_claim'),
|
|
34
|
+
timeout_ms: z.number().int().min(1000).max(3600000).optional().default(600000).describe('Maximum time to poll in milliseconds (default: 10 minutes, max 1 hour)'),
|
|
35
|
+
},
|
|
36
|
+
annotations: {
|
|
37
|
+
readOnlyHint: true,
|
|
38
|
+
destructiveHint: false,
|
|
39
|
+
openWorldHint: true,
|
|
40
|
+
},
|
|
33
41
|
},
|
|
34
42
|
async ({ claim_id, timeout_ms }) => {
|
|
35
43
|
try {
|
|
@@ -138,12 +146,13 @@ module.exports = function registerCheckClaimStatus(server, options = {}) {
|
|
|
138
146
|
isError: (result.success === false && result.continue_polling !== false) ? true : undefined,
|
|
139
147
|
};
|
|
140
148
|
} catch (err) {
|
|
149
|
+
console.error(`[check_claim_status] ${err.message}`);
|
|
141
150
|
return {
|
|
142
151
|
content: [{
|
|
143
152
|
type: 'text',
|
|
144
153
|
text: JSON.stringify({
|
|
145
154
|
success: false,
|
|
146
|
-
error:
|
|
155
|
+
error: 'Claim status check failed. See server log for detail.',
|
|
147
156
|
}),
|
|
148
157
|
}],
|
|
149
158
|
isError: true,
|
|
@@ -27,12 +27,20 @@ module.exports = function registerCheckEmailVerified(server, options = {}) {
|
|
|
27
27
|
const pollTimeout = options.pollTimeoutMs ?? POLL_TIMEOUT_MS;
|
|
28
28
|
const sleep = options.sleep;
|
|
29
29
|
|
|
30
|
-
server.
|
|
30
|
+
server.registerTool(
|
|
31
31
|
'check_email_verified',
|
|
32
|
-
'Poll to check if the user has verified their email address. Automatically polls every 15 seconds for up to 30 minutes. Returns immediately if already verified. If the email has no account, indicates registration is needed.',
|
|
33
32
|
{
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
title: 'check_email_verified',
|
|
34
|
+
description: 'Poll to check if the user has verified their email address. Automatically polls every 15 seconds for up to 30 minutes. Returns immediately if already verified. If the email has no account, indicates registration is needed.',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
email: z.string().email().describe('Email address to check verification status'),
|
|
37
|
+
poll: z.boolean().optional().default(true).describe('If true (default), poll until verified or timeout. If false, check once.'),
|
|
38
|
+
},
|
|
39
|
+
annotations: {
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
destructiveHint: false,
|
|
42
|
+
openWorldHint: true,
|
|
43
|
+
},
|
|
36
44
|
},
|
|
37
45
|
async ({ email, poll }) => {
|
|
38
46
|
try {
|
|
@@ -57,7 +65,7 @@ module.exports = function registerCheckEmailVerified(server, options = {}) {
|
|
|
57
65
|
done: true,
|
|
58
66
|
result: {
|
|
59
67
|
success: false,
|
|
60
|
-
message: `No account found for ${email}. Use
|
|
68
|
+
message: `No account found for ${email}. Use start_registration first.`,
|
|
61
69
|
exists: false,
|
|
62
70
|
verified: false,
|
|
63
71
|
},
|
|
@@ -82,7 +90,7 @@ module.exports = function registerCheckEmailVerified(server, options = {}) {
|
|
|
82
90
|
done: true,
|
|
83
91
|
result: {
|
|
84
92
|
success: false,
|
|
85
|
-
message: `No account found for ${email}. Use
|
|
93
|
+
message: `No account found for ${email}. Use start_registration to create an account first.`,
|
|
86
94
|
verified: false,
|
|
87
95
|
exists: false,
|
|
88
96
|
},
|
|
@@ -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,12 +33,21 @@ 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
|
-
server.
|
|
38
|
+
server.registerTool(
|
|
37
39
|
'check_prerequisites',
|
|
38
|
-
'Check system prerequisites for XNS Relayer installation: Docker availability (local or remote via DOCKER_HOST / ssh:// context), required ports (8888, 9000), an existing xns-relayer installation, disk space, and network connectivity to console.xns.tech and auth.xns.tech. Run this first before any other relayer tool.',
|
|
39
40
|
{
|
|
40
|
-
|
|
41
|
+
title: 'check_prerequisites',
|
|
42
|
+
description: 'Check system prerequisites for XNS Relayer installation: Docker availability (local or remote via DOCKER_HOST / ssh:// context), required ports (8888, 9000), an existing xns-relayer installation, disk space, and network connectivity to console.xns.tech and auth.xns.tech. Run this first before any other relayer tool.',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
/* no parameters */
|
|
45
|
+
},
|
|
46
|
+
annotations: {
|
|
47
|
+
readOnlyHint: true,
|
|
48
|
+
destructiveHint: false,
|
|
49
|
+
openWorldHint: true,
|
|
50
|
+
},
|
|
41
51
|
},
|
|
42
52
|
async () => {
|
|
43
53
|
const checks = [];
|
|
@@ -46,10 +56,21 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
46
56
|
// 1. Docker available — and WHERE it runs. With DOCKER_HOST or an
|
|
47
57
|
// ssh:// context (e.g. Claude Code on a jump host), the daemon is
|
|
48
58
|
// on another machine and the local checks below must adapt.
|
|
49
|
-
|
|
59
|
+
const DEFAULT_DOCKER_HOST = { remote: false, host: 'localhost', endpoint: null };
|
|
60
|
+
let dockerHost = DEFAULT_DOCKER_HOST;
|
|
50
61
|
try {
|
|
51
62
|
await docker.docker(['info', '--format', '{{.ServerVersion}}']);
|
|
52
|
-
|
|
63
|
+
const raw = await docker.getDockerHost();
|
|
64
|
+
// remote without a usable host is incomplete metadata — treat
|
|
65
|
+
// as local so the port checks run instead of silently skipping
|
|
66
|
+
// against a host we cannot name.
|
|
67
|
+
const remoteHost = typeof raw?.host === 'string' ? raw.host.trim() : '';
|
|
68
|
+
const isRemote = Boolean(raw?.remote) && remoteHost !== '' && remoteHost !== 'localhost';
|
|
69
|
+
dockerHost = {
|
|
70
|
+
remote: isRemote,
|
|
71
|
+
host: isRemote ? remoteHost : 'localhost',
|
|
72
|
+
endpoint: raw?.endpoint ?? null,
|
|
73
|
+
};
|
|
53
74
|
checks.push({
|
|
54
75
|
name: 'docker',
|
|
55
76
|
passed: true,
|
|
@@ -119,6 +140,29 @@ module.exports = function registerCheckPrerequisites(server, options = {}) {
|
|
|
119
140
|
checks.push({ name: 'existing_install', passed: true, detail: 'Existing-install check skipped (Docker not reachable)' });
|
|
120
141
|
}
|
|
121
142
|
|
|
143
|
+
// 3c. Ephemeral environment — finding, never a failure.
|
|
144
|
+
try {
|
|
145
|
+
const probe = _environmentProbe();
|
|
146
|
+
if (probe.ephemeral) {
|
|
147
|
+
const remoteDocker = dockerHost.remote;
|
|
148
|
+
checks.push({
|
|
149
|
+
name: 'ephemeral_environment',
|
|
150
|
+
passed: true,
|
|
151
|
+
warning: true,
|
|
152
|
+
detail: remoteDocker
|
|
153
|
+
? `This environment appears to be ephemeral (${probe.signals.join('; ')}), but Docker targets a remote host (${dockerHost.host}). Persistence depends on the remote Docker host.`
|
|
154
|
+
: `This environment appears to be ephemeral (${probe.signals.join('; ')}). A Relayer installed here will be lost when the container exits.`,
|
|
155
|
+
remediation: remoteDocker
|
|
156
|
+
? 'The Relayer will be installed on the remote Docker host. Verify that host has persistent storage.'
|
|
157
|
+
: 'Install on a persistent Docker host instead. If you are running from a sandbox or CI, use an SSH Docker context to target a persistent machine: docker context create relayer --docker "host=ssh://user@host" && docker context use relayer',
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Environment appears persistent — install will survive restarts' });
|
|
161
|
+
}
|
|
162
|
+
} catch {
|
|
163
|
+
checks.push({ name: 'ephemeral_environment', passed: true, detail: 'Ephemeral-environment check skipped (probe error)' });
|
|
164
|
+
}
|
|
165
|
+
|
|
122
166
|
// 4. Disk space (need at least 10 GB free — basic docker images + data)
|
|
123
167
|
try {
|
|
124
168
|
await docker.docker(['system', 'df', '--format', '{{.TotalCount}}']);
|
|
@@ -51,14 +51,22 @@ module.exports = function registerCheckRelayerHealth(server, options = {}) {
|
|
|
51
51
|
const pollTimeout = options.pollTimeoutMs ?? POLL_TIMEOUT_MS;
|
|
52
52
|
const sleep = options.sleep;
|
|
53
53
|
|
|
54
|
-
server.
|
|
54
|
+
server.registerTool(
|
|
55
55
|
'check_relayer_health',
|
|
56
|
-
'Check the health of all Relayer services: UI (port 8888), S3 gateway (port 9000), HostIO, and the monitoring sidecars (Prometheus + Grafana containers). Polls every 10 seconds for up to 300 seconds. Reports each component status individually and names any unhealthy component; a missing monitoring stack reports as degraded (dashboards empty) without blocking the install flow. Targets the machine the Docker daemon runs on (auto-detected from the Docker context — supports remote ssh:// Docker hosts); pass host to override. Note: HostIO health status is unknown until OIDC authentication is completed.',
|
|
57
56
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
title: 'check_relayer_health',
|
|
58
|
+
description: 'Check the health of all Relayer services: UI (port 8888), S3 gateway (port 9000), HostIO, and the monitoring sidecars (Prometheus + Grafana containers). Polls every 10 seconds for up to 300 seconds. Reports each component status individually and names any unhealthy component; a missing monitoring stack reports as degraded (dashboards empty) without blocking the install flow. Targets the machine the Docker daemon runs on (auto-detected from the Docker context — supports remote ssh:// Docker hosts); pass host to override. Note: HostIO health status is unknown until OIDC authentication is completed.',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
poll: z.boolean().optional().default(true).describe('If true (default), poll until healthy or timeout. If false, check once.'),
|
|
61
|
+
host: z.string().trim().min(1).optional().describe('Hostname/IP where the Relayer containers run. Default: auto-detected from the Docker context (localhost, or the remote host for ssh:// / tcp:// contexts).'),
|
|
62
|
+
ui_port: z.number().int().min(1).max(65535).optional().default(8888).describe('Host port for the Relayer UI (matches install_relayer ui_port)'),
|
|
63
|
+
s3_port: z.number().int().min(1).max(65535).optional().default(9000).describe('Host port for the S3 API (matches install_relayer s3_port)'),
|
|
64
|
+
},
|
|
65
|
+
annotations: {
|
|
66
|
+
readOnlyHint: true,
|
|
67
|
+
destructiveHint: false,
|
|
68
|
+
openWorldHint: true,
|
|
69
|
+
},
|
|
62
70
|
},
|
|
63
71
|
async ({ poll, host, ui_port, s3_port }) => {
|
|
64
72
|
try {
|
|
@@ -201,12 +209,13 @@ module.exports = function registerCheckRelayerHealth(server, options = {}) {
|
|
|
201
209
|
}],
|
|
202
210
|
};
|
|
203
211
|
} catch (err) {
|
|
212
|
+
console.error(`[check_relayer_health] ${err.message}`);
|
|
204
213
|
return {
|
|
205
214
|
content: [{
|
|
206
215
|
type: 'text',
|
|
207
216
|
text: JSON.stringify({
|
|
208
217
|
success: false,
|
|
209
|
-
error:
|
|
218
|
+
error: 'Health check failed. See server log for detail.',
|
|
210
219
|
}),
|
|
211
220
|
}],
|
|
212
221
|
isError: true,
|
|
@@ -40,13 +40,21 @@ module.exports = function registerConfigureVpd(server, options = {}) {
|
|
|
40
40
|
const tokenMgr = createTokenManager(options);
|
|
41
41
|
const { ensureToken } = tokenMgr;
|
|
42
42
|
|
|
43
|
-
server.
|
|
43
|
+
server.registerTool(
|
|
44
44
|
'configure_vpd',
|
|
45
|
-
'Configure VPD (Virtual Private Datacenter) host selection for the Relayer, or preview it with dry_run. Use defaults ("true" for both expressions) or a CEL expression filtering hosts by tags. The Relayer requires a minimum of 10 data hosts and 20 parity hosts — if too few match, broaden the criteria. Requires OIDC sign-in (same session as get_host_tags).',
|
|
46
45
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
title: 'configure_vpd',
|
|
47
|
+
description: 'Configure VPD (Virtual Private Datacenter) host selection for the Relayer, or preview it with dry_run. Use defaults ("true" for both expressions) or a CEL expression filtering hosts by tags. The Relayer requires a minimum of 10 data hosts and 20 parity hosts — if too few match, broaden the criteria. Requires OIDC sign-in (same session as get_host_tags).',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
data_expression: z.string().describe('CEL expression for data host selection. Use "true" for default (all hosts).'),
|
|
50
|
+
parity_expression: z.string().describe('CEL expression for parity host selection. Use "true" for default (all hosts).'),
|
|
51
|
+
dry_run: z.boolean().optional().describe('Preview how many hosts match without applying anything. Not supported on Relayer versions without the evaluate endpoint.'),
|
|
52
|
+
},
|
|
53
|
+
annotations: {
|
|
54
|
+
readOnlyHint: false,
|
|
55
|
+
destructiveHint: false,
|
|
56
|
+
openWorldHint: true,
|
|
57
|
+
},
|
|
50
58
|
},
|
|
51
59
|
async ({ data_expression, parity_expression, dry_run }) => {
|
|
52
60
|
try {
|
|
@@ -20,11 +20,19 @@ module.exports = function registerDescribeSettings(server, options = {}) {
|
|
|
20
20
|
const tokenMgr = createTokenManager(options);
|
|
21
21
|
const { ensureToken } = tokenMgr;
|
|
22
22
|
|
|
23
|
-
server.
|
|
23
|
+
server.registerTool(
|
|
24
24
|
'describe_settings',
|
|
25
|
-
'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).',
|
|
26
25
|
{
|
|
27
|
-
|
|
26
|
+
title: 'describe_settings',
|
|
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
|
+
inputSchema: {
|
|
29
|
+
/* no parameters — the whitelist is small by design */
|
|
30
|
+
},
|
|
31
|
+
annotations: {
|
|
32
|
+
readOnlyHint: true,
|
|
33
|
+
destructiveHint: false,
|
|
34
|
+
openWorldHint: true,
|
|
35
|
+
},
|
|
28
36
|
},
|
|
29
37
|
async () => {
|
|
30
38
|
try {
|
package/src/tools/getHostTags.js
CHANGED
|
@@ -29,11 +29,19 @@ module.exports = function registerGetHostTags(server, options = {}) {
|
|
|
29
29
|
const tokenMgr = createTokenManager(options);
|
|
30
30
|
const { ensureToken } = tokenMgr;
|
|
31
31
|
|
|
32
|
-
server.
|
|
32
|
+
server.registerTool(
|
|
33
33
|
'get_host_tags',
|
|
34
|
-
'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).',
|
|
35
34
|
{
|
|
36
|
-
|
|
35
|
+
title: 'get_host_tags',
|
|
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
|
+
inputSchema: {
|
|
38
|
+
/* no parameters */
|
|
39
|
+
},
|
|
40
|
+
annotations: {
|
|
41
|
+
readOnlyHint: true,
|
|
42
|
+
destructiveHint: false,
|
|
43
|
+
openWorldHint: true,
|
|
44
|
+
},
|
|
37
45
|
},
|
|
38
46
|
async () => {
|
|
39
47
|
try {
|