@xns-cloud/relayer-mcp 0.12.0 → 0.14.3

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.
@@ -1,11 +1,169 @@
1
1
  'use strict';
2
2
 
3
+ const crypto = require('crypto');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
6
  const os = require('os');
7
+ const { isDeepStrictEqual } = require('util');
6
8
  const { z } = require('zod');
7
9
  const { createHttpClient } = require('../lib/httpClient');
8
- const { validateHostAllowlist, NO_REDIRECT_TOKEN_CONFIG } = require('../lib/hostAllowlist');
10
+ const { createTokenManager } = require('../lib/ensureToken');
11
+ const { NO_REDIRECT_TOKEN_CONFIG } = require('../lib/hostAllowlist');
12
+
13
+ const DEFAULT_UI_PORT = 8888;
14
+ const RELAYER_UI_BASE = `http://localhost:${DEFAULT_UI_PORT}`;
15
+
16
+ // The Relayer user, its policy, and the profile used when `default` already holds keys.
17
+ const CLI_NAME = 'xns-cli';
18
+
19
+ /**
20
+ * DECISION: the key is the account owner's own, so it gets the gateway's ReadWrite actions
21
+ * plus s3:DeleteBucket, on every bucket. The actions are spelled out in a policy of its own
22
+ * because a Relayer already installed may not have a built-in set by that name.
23
+ */
24
+ const CLI_POLICY = {
25
+ Version: '2012-10-17',
26
+ Statement: [{
27
+ Effect: 'Allow',
28
+ Action: [
29
+ 's3:GetObject',
30
+ 's3:GetObjectVersion',
31
+ 's3:HeadObject',
32
+ 's3:ListBucket',
33
+ 's3:ListBucketVersions',
34
+ 's3:ListAllMyBuckets',
35
+ 's3:GetBucketLocation',
36
+ 's3:GetBucketPolicy',
37
+ 's3:GetBucketTagging',
38
+ 's3:GetBucketVersioning',
39
+ 's3:GetObjectTagging',
40
+ 's3:GetObjectAttributes',
41
+ 's3:ListBucketMultipartUploads',
42
+ 's3:ListMultipartUploadParts',
43
+ 's3:PutObject',
44
+ 's3:DeleteObject',
45
+ 's3:CreateMultipartUpload',
46
+ 's3:UploadPart',
47
+ 's3:CompleteMultipartUpload',
48
+ 's3:AbortMultipartUpload',
49
+ 's3:PutObjectTagging',
50
+ 's3:DeleteObjectTagging',
51
+ 's3:CreateBucket',
52
+ 's3:DeleteBucket',
53
+ ],
54
+ Resource: ['arn:aws:s3:::*', 'arn:aws:s3:::*/*'],
55
+ }],
56
+ };
57
+
58
+ // How many policy names to try when earlier ones hold other rules.
59
+ const MAX_POLICY_NAMES = 10;
60
+
61
+ const BAD_FILE_ERROR = '~/.xns/credentials exists but could not be read as an XNS credentials file, so it was left as it is. Ask the user to fix it or move it aside, then call setup_cli_credentials again.';
62
+
63
+ const NOT_SAVED_ERROR = 'The Relayer created the user xns-cli, but its keys could not be saved to ~/.xns/credentials. See the server log for detail. Ask the user to delete the user xns-cli in the Relayer UI and make sure that file can be written, then call setup_cli_credentials again.';
64
+
65
+ const NO_POLICY_ERROR = 'The Relayer did not give the new user xns-cli its permissions, so that user was deleted and nothing was saved to ~/.xns/credentials. See the server log for detail, then call setup_cli_credentials again.';
66
+
67
+ const USER_LEFT_ERROR = 'The Relayer created the user xns-cli but did not give it its permissions, and that user could not be deleted. Nothing was saved to ~/.xns/credentials. See the server log for detail. Ask the user to delete the user xns-cli in the Relayer UI, then call setup_cli_credentials again.';
68
+
69
+ const isPlainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
70
+
71
+ /**
72
+ * Read the credentials file the xns CLI uses. Absent file: an empty set. A file that is
73
+ * there but is not one the CLI would load throws CREDS_UNREADABLE, because writing over
74
+ * it would drop keys a Relayer shows only once.
75
+ */
76
+ function readCredentials(credsPath) {
77
+ let creds;
78
+ try {
79
+ creds = JSON.parse(fs.readFileSync(credsPath, 'utf8'));
80
+ } catch (err) {
81
+ if (err.code === 'ENOENT') return { version: 1, profiles: {} };
82
+ // JSON.parse quotes the text it failed on, which may be a key: never pass it on.
83
+ throw Object.assign(new Error(`credentials file unreadable (${err.code || 'not JSON'})`), { code: 'CREDS_UNREADABLE' });
84
+ }
85
+ if (!isPlainObject(creds) || creds.version !== 1 || !isPlainObject(creds.profiles)) {
86
+ throw Object.assign(new Error('credentials file is not XNS version 1'), { code: 'CREDS_UNREADABLE' });
87
+ }
88
+ return creds;
89
+ }
90
+
91
+ /**
92
+ * DECISION: a profile that holds a secret key is never replaced, `default` included. The
93
+ * new keys go to `default` when it is absent or keyless (`xns register` writes it keyless),
94
+ * otherwise to the first free xns-cli, xns-cli-2, ... name.
95
+ */
96
+ function pickProfileName(profiles) {
97
+ if (!Object.hasOwn(profiles, 'default') || !profiles.default?.secret_access_key) return 'default';
98
+ let name = CLI_NAME;
99
+ for (let n = 2; Object.hasOwn(profiles, name); n += 1) name = `${CLI_NAME}-${n}`;
100
+ return name;
101
+ }
102
+
103
+ /**
104
+ * Replace the file in one step, so a failed write cannot cut short the profiles in it.
105
+ * The temporary file is this write's own: the xns CLI or a second server may be saving at
106
+ * the same moment, and must not take it. 'wx' creates it fresh, which makes mode 0600 hold
107
+ * whatever the old file's mode was.
108
+ */
109
+ function writeCredentials(credsPath, creds) {
110
+ fs.mkdirSync(path.dirname(credsPath), { recursive: true, mode: 0o700 });
111
+ const tmp = `${credsPath}.${crypto.randomUUID()}.tmp`;
112
+ try {
113
+ fs.writeFileSync(tmp, JSON.stringify(creds, null, 2), { mode: 0o600, flag: 'wx' });
114
+ fs.renameSync(tmp, credsPath);
115
+ } catch (err) {
116
+ fs.rmSync(tmp, { force: true });
117
+ throw err;
118
+ }
119
+ }
120
+
121
+ // For the server log only: the Relayer UI answers a gateway refusal as HTTP 200 and a message.
122
+ const describeAnswer = ({ status, data }) => `HTTP ${status}${data?.message ? `: ${data.message}` : ''}`;
123
+
124
+ /**
125
+ * Create the policy and return its name. The gateway refuses a name that is taken and keeps
126
+ * the rules stored under it, and deleting a user leaves its policy behind, so an earlier run
127
+ * may have made this one. DECISION: a policy with these same rules is used as it is; one with
128
+ * other rules is somebody else's, so it is neither used nor changed and the next name is tried.
129
+ */
130
+ async function createCliPolicy(http, mcBase, config) {
131
+ for (let n = 1; n <= MAX_POLICY_NAMES; n += 1) {
132
+ const name = n === 1 ? CLI_NAME : `${CLI_NAME}-${n}`;
133
+ const created = await http.post(
134
+ `${mcBase}/policy-create`,
135
+ { name, type: 'json', json: JSON.stringify(CLI_POLICY) },
136
+ config
137
+ );
138
+ if (created.status === 200 && created.data?.success === true) return name;
139
+
140
+ const existing = await http.get(`${mcBase}/policy/${name}`, config);
141
+ if (existing.status !== 200 || !isPlainObject(existing.data?.policy_json)) {
142
+ throw new Error(`policy create failed (${describeAnswer(created)}); reading ${name}: ${describeAnswer(existing)}`);
143
+ }
144
+ if (isDeepStrictEqual(existing.data.policy_json, CLI_POLICY)) return name;
145
+ }
146
+ throw new Error(`policy create failed: ${MAX_POLICY_NAMES} names are taken`);
147
+ }
148
+
149
+ async function attachCliPolicy(http, mcBase, policy, config) {
150
+ const answer = await http.post(`${mcBase}/policy`, { name: CLI_NAME, policy }, config);
151
+ if (answer.status !== 200 || answer.data?.status !== 'attached') {
152
+ throw new Error(`policy attach failed (${describeAnswer(answer)})`);
153
+ }
154
+ }
155
+
156
+ /** Delete the user this run made. Returns whether the Relayer says it is gone. */
157
+ async function deleteCliUser(http, mcBase, config) {
158
+ try {
159
+ const answer = await http.del(`${mcBase}/user/${CLI_NAME}`, config);
160
+ if (answer.status === 200 && answer.data?.status === 'deleted') return true;
161
+ console.error(`[setup_cli_credentials] user delete failed (${describeAnswer(answer)})`);
162
+ } catch (err) {
163
+ console.error(`[setup_cli_credentials] user delete failed: ${err && err.message ? err.message : String(err)}`);
164
+ }
165
+ return false;
166
+ }
9
167
 
10
168
  /**
11
169
  * Tool 11: setup_cli_credentials
@@ -14,23 +172,28 @@ const { validateHostAllowlist, NO_REDIRECT_TOKEN_CONFIG } = require('../lib/host
14
172
  * but no CLI credentials. This tool:
15
173
  * 1. Creates an IAM user "xns-cli" via the Relayer UI MC proxy
16
174
  * 2. Receives the one-time {access_key, secret_key} response
17
- * 3. Writes ~/.xns/credentials (AC-11 JSON schema, mode 0600)
175
+ * 3. Creates a policy and attaches it to the user: the gateway denies every request
176
+ * from a user that has none. If that fails, the user is deleted again
177
+ * 4. Adds the keys to ~/.xns/credentials as one profile (mode 0600),
178
+ * keeping every profile already there
18
179
  *
19
- * The muse_token is the Keycloak JWT already held by the agent from the
20
- * configure_vpd / get_host_tags calls — no new auth step required.
180
+ * The sign-in token comes from the server's own token manager, the same one
181
+ * get_host_tags and configure_vpd use (one browser sign-in per session); the
182
+ * caller never passes a token.
21
183
  */
22
184
  module.exports = function registerSetupCliCredentials(server, options = {}) {
23
185
  const http = options.httpClient || createHttpClient(options);
186
+ const relayerUiBase = (options.relayerUiBase || RELAYER_UI_BASE).replace(/\/+$/, '');
187
+ const tokenMgr = createTokenManager(options);
24
188
 
25
189
  server.registerTool(
26
190
  'setup_cli_credentials',
27
191
  {
28
- title: 'setup_cli_credentials',
29
- description: 'Provision S3 IAM credentials for the XNS CLI. Creates an IAM user in the Relayer and writes ~/.xns/credentials so that `xns ls` and other S3 verbs work without further configuration. Call once after check_claim_status reaches STATE_3.',
192
+ title: 'Set up CLI credentials',
193
+ description: 'Provision S3 IAM credentials for the XNS CLI. Creates an IAM user in the Relayer that can read, write and delete in every bucket, and saves its keys in ~/.xns/credentials, where `xns ls` and the other S3 verbs read them. Profiles in that file that hold keys are kept: if its default profile is one of them, the new keys go in a new profile, and the reply names it and the command that uses it. Call once after check_claim_status reaches STATE_3.',
30
194
  inputSchema: {
31
- muse_token: z.string().describe('Keycloak/Muse token — the same token used for get_host_tags and configure_vpd'),
32
195
  installation_id: z.string().optional().default('').describe('Installation ID from check_claim_status STATE_3 result — used as cost_center_id in credentials'),
33
- relayer_ui_url: z.string().url().optional().default('http://localhost:8888').describe('Relayer UI base URL (default: http://localhost:8888). Must be a loopback, private-network, or .local address — this tool sends your Muse token to it.'),
196
+ ui_port: z.number().int().min(1).max(65535).optional().default(DEFAULT_UI_PORT).describe('Relayer UI port, if install_relayer was run with a ui_port other than 8888. Only the port is chosen; the host is always this machine.'),
34
197
  },
35
198
  annotations: {
36
199
  readOnlyHint: false,
@@ -38,31 +201,34 @@ module.exports = function registerSetupCliCredentials(server, options = {}) {
38
201
  openWorldHint: true,
39
202
  },
40
203
  },
41
- async ({ muse_token, installation_id, relayer_ui_url }) => {
42
- // This request carries the caller's Muse token. Check the destination BEFORE
43
- // sending anything, or a caller can name any host and collect the token
44
- // (MR !33). Same allowlist verify_storage has always applied.
45
- const allow = validateHostAllowlist(relayer_ui_url);
46
- if (!allow.allowed) {
47
- console.error(`[setup_cli_credentials] relayer_ui_url rejected: ${allow.reason}`);
48
- return {
49
- content: [{
50
- type: 'text',
51
- text: JSON.stringify({
52
- success: false,
53
- error: `relayer_ui_url rejected: ${allow.reason}`,
54
- }),
55
- }],
56
- };
57
- }
58
-
204
+ async ({ installation_id, ui_port = DEFAULT_UI_PORT }) => {
205
+ // DECISION: the server's own sign-in token is never sent to a caller-chosen
206
+ // host. The request goes only to the server-owned Relayer UI base, the same
207
+ // base get_host_tags uses; the tool takes no URL input. The caller picks
208
+ // only the UI port, never the host.
209
+ let keysIssued = false;
59
210
  try {
211
+ const uiUrl = new URL(relayerUiBase);
212
+ uiUrl.port = String(ui_port);
213
+ const mcBase = `${uiUrl.toString().replace(/\/+$/, '')}/api/v1/mc`;
214
+ const credsPath = path.join(os.homedir(), '.xns', 'credentials');
215
+ let token = await tokenMgr.ensureToken();
216
+
217
+ // Checked before the user is created: the Relayer shows the secret key
218
+ // once, so a file that cannot take it has to stop the tool here.
219
+ readCredentials(credsPath);
220
+
221
+ const tokenConfig = () => ({ headers: { keycloaktoken: token }, ...NO_REDIRECT_TOKEN_CONFIG });
222
+ const createUser = () => http.post(`${mcBase}/user`, { user: CLI_NAME }, tokenConfig());
223
+
60
224
  // Step 1: create IAM user "xns-cli" via MC proxy
61
- const { status, data } = await http.post(
62
- `${relayer_ui_url}/api/v1/mc/user`,
63
- { user: 'xns-cli' },
64
- { headers: { keycloaktoken: muse_token }, ...NO_REDIRECT_TOKEN_CONFIG }
65
- );
225
+ let { status, data } = await createUser();
226
+
227
+ // A rejected token gets one re-auth and retry.
228
+ if (status === 401) {
229
+ token = await tokenMgr.reauth();
230
+ ({ status, data } = await createUser());
231
+ }
66
232
 
67
233
  if (status !== 200) {
68
234
  return {
@@ -88,18 +254,35 @@ module.exports = function registerSetupCliCredentials(server, options = {}) {
88
254
  text: JSON.stringify({
89
255
  success: false,
90
256
  error: `Relayer: ${msg}`,
91
- hint: 'CLI credentials may already exist. Run `xns ls` — if it works, credentials are valid.',
257
+ hint: 'CLI credentials may already exist in one of the profiles in ~/.xns/credentials. Run `xns ls`, or `xns --profile <name> ls` for a profile that is not active — if it works, those credentials are valid. If it is denied, the user xns-cli may have no permissions: ask the user to delete xns-cli in the Relayer UI, then call setup_cli_credentials again.',
92
258
  }),
93
259
  }],
94
260
  };
95
261
  }
96
262
 
97
- // Step 2: derive S3 endpoint (same host, port 9000).
263
+ // Step 2: give the user its permissions. Nothing is saved unless this works.
264
+ try {
265
+ const policy = await createCliPolicy(http, mcBase, tokenConfig());
266
+ await attachCliPolicy(http, mcBase, policy, tokenConfig());
267
+ } catch (err) {
268
+ console.error(`[setup_cli_credentials] ${err && err.message ? err.message : String(err)}`);
269
+ const deleted = await deleteCliUser(http, mcBase, tokenConfig());
270
+ return {
271
+ content: [{
272
+ type: 'text',
273
+ text: JSON.stringify({ success: false, error: deleted ? NO_POLICY_ERROR : USER_LEFT_ERROR }),
274
+ }],
275
+ };
276
+ }
277
+
278
+ keysIssued = true;
279
+
280
+ // Step 3: derive S3 endpoint (same host, port 9000).
98
281
  // Parse rather than regex-replace: the old `.replace(/:(\d+)(\/|$)/, ...)`
99
282
  // only rewrote an EXISTING :port slot, so a portless URL kept 80/443, a
100
283
  // query or fragment survived into the persisted endpoint, and a ':digits'
101
284
  // sequence in the PATH could be rewritten instead of the port (MR !33).
102
- const s3Url = new URL(relayer_ui_url);
285
+ const s3Url = new URL(relayerUiBase);
103
286
  s3Url.port = '9000';
104
287
  s3Url.username = '';
105
288
  s3Url.password = '';
@@ -107,59 +290,68 @@ module.exports = function registerSetupCliCredentials(server, options = {}) {
107
290
  s3Url.hash = '';
108
291
  const s3Endpoint = s3Url.toString().replace(/\/$/, '');
109
292
 
110
- // Step 3: write ~/.xns/credentials (AC-11 JSON schema, mode 0600)
111
- const credsPath = path.join(os.homedir(), '.xns', 'credentials');
112
- fs.mkdirSync(path.dirname(credsPath), { recursive: true });
113
-
114
- const creds = {
115
- version: 1,
116
- profiles: {
117
- default: {
118
- endpoint: s3Endpoint,
119
- access_key_id: ak,
120
- secret_access_key: sk,
121
- cost_center_id: installation_id,
122
- // Deliberately empty. The 5-key schema requires the key to be
123
- // PRESENT, but the xns CLI never reads its value — the only
124
- // reference in that codebase is `_ = p.MuseToken` in
125
- // validateProfile, whose comment states "muse_token may be
126
- // empty", and its round-trip test asserts the field IS empty.
127
- // Writing the JWT here bought nothing and cost real exposure:
128
- // it expires in minutes so the copy goes stale, there is no
129
- // refresh token to renew it, and until expiry a read of this
130
- // file grants Muse-API reach well beyond S3. The access and
131
- // secret keys below do belong here — S3 request signing needs
132
- // them in plaintext, same as ~/.aws/credentials.
133
- muse_token: '',
134
- },
135
- },
136
- active_profile: 'default',
293
+ // Step 4: add the profile to ~/.xns/credentials (mode 0600).
294
+ // Read again: another program may have saved a profile in the meantime.
295
+ const creds = readCredentials(credsPath);
296
+ const profileName = pickProfileName(creds.profiles);
297
+ creds.profiles[profileName] = {
298
+ endpoint: s3Endpoint,
299
+ access_key_id: ak,
300
+ secret_access_key: sk,
301
+ cost_center_id: installation_id,
302
+ // Deliberately empty. The 5-key schema requires the key to be
303
+ // PRESENT, but the xns CLI never reads its value — the only
304
+ // reference in that codebase is `_ = p.MuseToken` in
305
+ // validateProfile, whose comment states "muse_token may be
306
+ // empty", and its round-trip test asserts the field IS empty.
307
+ // Writing the JWT here bought nothing and cost real exposure:
308
+ // it expires in minutes so the copy goes stale, there is no
309
+ // refresh token to renew it, and until expiry a read of this
310
+ // file grants Muse-API reach well beyond S3. The access and
311
+ // secret keys below do belong here — S3 request signing needs
312
+ // them in plaintext, same as ~/.aws/credentials.
313
+ muse_token: '',
137
314
  };
138
-
139
- fs.writeFileSync(credsPath, JSON.stringify(creds, null, 2), { mode: 0o600 });
140
- // writeFileSync's mode only applies when the file is CREATED. This file is
141
- // overwritten unconditionally, so an existing loose-permission file would
142
- // keep those permissions and hold secret keys (MR !33).
143
- fs.chmodSync(credsPath, 0o600);
315
+ // DECISION: the active profile stays the user's. Moving it would point
316
+ // every later `xns` command at another Relayer. The CLI refuses a file
317
+ // whose active_profile names no profile, so only that case is set.
318
+ if (typeof creds.active_profile !== 'string' || !Object.hasOwn(creds.profiles, creds.active_profile)) {
319
+ creds.active_profile = profileName;
320
+ }
321
+ writeCredentials(credsPath, creds);
144
322
 
145
323
  return {
146
324
  content: [{
147
325
  type: 'text',
148
326
  text: JSON.stringify({
149
327
  success: true,
150
- message: 'CLI credentials written to ~/.xns/credentials. The user can now run `xns ls` to list their storage.',
328
+ message: creds.active_profile === profileName
329
+ ? 'CLI credentials written to ~/.xns/credentials. The user can now run `xns ls` to list their storage.'
330
+ : `CLI credentials written to ~/.xns/credentials as the profile ${profileName}. Profiles that already hold keys are unchanged, and plain \`xns\` commands still use ${creds.active_profile}. The user can now run \`xns --profile ${profileName} ls\` to list the storage on this Relayer.`,
331
+ profile: profileName,
332
+ active_profile: creds.active_profile,
151
333
  s3_endpoint: s3Endpoint,
152
334
  }),
153
335
  }],
154
336
  };
155
337
  } catch (err) {
338
+ // Caught error text stays in the server log. The sign-in link message
339
+ // is the one exception: this server builds it from fixed text and the
340
+ // link, and the person needs it to sign in.
341
+ let error = 'Setting up CLI credentials failed. See the server log for detail, then call setup_cli_credentials again.';
342
+ if (err && err.code === 'SIGNIN_LINK') {
343
+ error = err.message;
344
+ } else {
345
+ console.error(`[setup_cli_credentials] ${err && err.message ? err.message : String(err)}`);
346
+ // Calling again would not help once the user exists: the Relayer
347
+ // refuses a second xns-cli and does not show the first one's key again.
348
+ if (keysIssued) error = NOT_SAVED_ERROR;
349
+ else if (err && err.code === 'CREDS_UNREADABLE') error = BAD_FILE_ERROR;
350
+ }
156
351
  return {
157
352
  content: [{
158
353
  type: 'text',
159
- text: JSON.stringify({
160
- success: false,
161
- error: err.message,
162
- }),
354
+ text: JSON.stringify({ success: false, error }),
163
355
  }],
164
356
  };
165
357
  }
@@ -21,7 +21,7 @@ module.exports = function registerStartClaim(server, options = {}) {
21
21
  server.registerTool(
22
22
  'start_claim',
23
23
  {
24
- title: 'start_claim',
24
+ title: 'Start claim',
25
25
  description: 'Start a claim session to link this Relayer installation to an XNS account. Returns a claim URL that the user must open in a browser to complete the claim. The claim has an expiration time. After calling this, use check_claim_status to monitor claim progress.',
26
26
  inputSchema: {
27
27
  /* no parameters */
@@ -28,7 +28,7 @@ module.exports = function registerStartRegistration(server, options = {}) {
28
28
  server.registerTool(
29
29
  'start_registration',
30
30
  {
31
- title: 'start_registration',
31
+ title: 'Start registration',
32
32
  description: 'Get the browser registration URL for creating a new XNS account. The user opens this URL in a browser to sign up via Keycloak — the agent never touches credentials. After signing up, use check_email_verified to poll for email verification.',
33
33
  inputSchema: {},
34
34
  annotations: {
@@ -33,7 +33,7 @@ module.exports = function registerUpdateSettings(server, options = {}) {
33
33
  server.registerTool(
34
34
  'update_settings',
35
35
  {
36
- title: 'update_settings',
36
+ title: 'Update settings',
37
37
  description: 'Update adjustable Relayer settings (see describe_settings for the allowed set). Pass a map of setting name to new value, e.g. {"HOSTIO_UPLOAD_WORKERS": 20}. Returns require_restart — if true, follow up with restart_service after confirming with the operator. Changing CostCenter re-bills to a different cost center; always confirm first.',
38
38
  inputSchema: {
39
39
  settings: z.record(z.union([z.string(), z.number(), z.boolean()]))
@@ -44,7 +44,7 @@ module.exports = function registerVerifyStorage(server, options = {}) {
44
44
  server.registerTool(
45
45
  'verify_storage',
46
46
  {
47
- title: 'verify_storage',
47
+ title: 'Verify storage',
48
48
  description: 'Verify the S3-compatible storage gateway is working by performing a round-trip test: create a test bucket, upload a small object, download it, and compare. Provisions a temporary scoped IAM credential automatically using your OIDC session — no manual key management needed. The throwaway credential and test data are removed after the test, pass or fail. By default targets port 9000 on the machine the Docker daemon runs on (auto-detected from the Docker context); pass endpoint to override.',
49
49
  inputSchema: {
50
50
  muse_token: z.string().trim().min(1).optional().describe('Optional Keycloak/Muse token override. Usually omitted — without it (and without access keys) the tool reuses the sign-in session from get_host_tags/configure_vpd, or starts a browser sign-in if there is none.'),
@@ -115,6 +115,7 @@ module.exports = function registerVerifyStorage(server, options = {}) {
115
115
  try {
116
116
  muse_token = await tokenMgr.ensureToken();
117
117
  } catch (signInErr) {
118
+ if (signInErr.code === 'SIGNIN_LINK') throw safeError(signInErr.message);
118
119
  console.error(`[verify_storage] SignIn: ${signInErr.message}`);
119
120
  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.');
120
121
  }
@@ -1,85 +0,0 @@
1
- # Bundled by @xns-cloud/relayer-mcp — OFFLINE FALLBACK for the released install.
2
- # Source of truth: the release channel bundle on the XNS releases registry —
3
- # https://releases.scpri.me/relayer/release/docker-compose.yml and the .env
4
- # beside it; the release publisher ships both. install_relayer fetches those URLs by
5
- # default and only writes this copy when either fetch fails, so this file MUST
6
- # keep service parity with the channel bundle: relayer + the monitoring stack
7
- # (Prometheus + Grafana + node-exporter) that powers the dashboards under
8
- # Monitoring in the web UI. The jest contract tests enforce the parity.
9
- #
10
- # Every Relayer image comes from releases.scpri.me — never a Docker Hub fleet
11
- # tag, which is not a release channel. The one allowed upstream image is
12
- # prom/node-exporter (public, multi-arch, version-pinned — matches the channel
13
- # bundle; nothing to rebuild). No service mounts the host's Docker socket.
14
- #
15
- # Pinned to the release-latest tag, the channel standalone Relayer customers install.
16
- #
17
- # A first-time user never hand-writes this file or the .env — install_relayer
18
- # writes both.
19
- #
20
- # STORAGE STRATEGY — MUST match the channel bundle (named volume relayer_data).
21
- # This file is written only when the channel fetch fails; if the two used
22
- # DIFFERENT volume strategies, an online-vs-offline install would silently switch
23
- # the mount target and the user's buckets would appear to vanish (data orphaned
24
- # in the unmounted volume). That was tacom beta bug #2 (2026-06-09): this file
25
- # used a bind mount `./data` while the channel used `relayer_data`. Both now use
26
- # the named volume. The storage-strategy parity test in installRelayer.test.js
27
- # enforces it — do NOT reintroduce a bind mount here.
28
- #
29
- # Other differences from the channel compose, by design:
30
- # - SMB ports 139/445 are intentionally NOT exposed: 445 is held by Windows
31
- # SMB on consumer hosts and would fail the install. S3 onboarding uses :9000.
32
- # - pull_policy: always so `docker compose up -d` fetches the current release
33
- # images without a separate `docker compose pull` step.
34
- services:
35
- xns:
36
- # container_name is load-bearing: the baked-in prometheus.yml scrapes the
37
- # relayer by this name, and the install preflight keys on it.
38
- container_name: xns-relayer
39
- image: releases.scpri.me/xns-relayer:release-latest
40
- pull_policy: always
41
- restart: unless-stopped
42
- privileged: true # samba / fuse / disk management (matches channel compose)
43
- volumes:
44
- - relayer_data:/relayer # named volume — MUST match the channel bundle (bug #2)
45
- ports:
46
- - ${BIND_ADDRESS:-}${UI_PORT:-8888}:8888
47
- - ${BIND_ADDRESS:-}${S3_PORT:-9000}:9000
48
- env_file:
49
- - .env
50
-
51
- # Monitoring stack — powers the dashboards under Monitoring in the web UI.
52
- # Not host-exposed: Grafana is reached only through the relayer's /grafana
53
- # reverse proxy and the in-network Prometheus scrape.
54
- prometheus:
55
- image: releases.scpri.me/relayer-prometheus:release-latest
56
- pull_policy: always
57
- restart: unless-stopped
58
- volumes:
59
- - prometheus_data:/prometheus
60
-
61
- grafana:
62
- image: releases.scpri.me/relayer-grafana:release-latest
63
- pull_policy: always
64
- restart: unless-stopped
65
- environment:
66
- - GF_AUTH_ANONYMOUS_ENABLED=true
67
- - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
68
- - GF_SERVER_SERVE_FROM_SUB_PATH=true
69
- - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s/grafana
70
- - GF_SECURITY_ALLOW_EMBEDDING=true
71
- volumes:
72
- - grafana_data:/var/lib/grafana
73
-
74
- node-exporter:
75
- image: prom/node-exporter:v1.11.1
76
- restart: unless-stopped
77
- command:
78
- - --path.rootfs=/host
79
- volumes:
80
- - /:/host:ro # read-only host metrics for the Node Health page
81
-
82
- volumes:
83
- relayer_data:
84
- prometheus_data:
85
- grafana_data: