@sanctuary-framework/mcp-server 0.5.2 → 0.5.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.
package/dist/cli.cjs CHANGED
@@ -295,6 +295,12 @@ async function loadConfig(configPath) {
295
295
  if (process.env.SANCTUARY_DASHBOARD_AUTH_TOKEN) {
296
296
  config.dashboard.auth_token = process.env.SANCTUARY_DASHBOARD_AUTH_TOKEN;
297
297
  }
298
+ if (process.env.SANCTUARY_DASHBOARD_AUTO_OPEN === "true") {
299
+ config.dashboard.auto_open = true;
300
+ }
301
+ if (process.env.SANCTUARY_DASHBOARD_AUTO_OPEN === "false") {
302
+ config.dashboard.auto_open = false;
303
+ }
298
304
  if (process.env.SANCTUARY_DASHBOARD_TLS_CERT && process.env.SANCTUARY_DASHBOARD_TLS_KEY) {
299
305
  config.dashboard.tls = {
300
306
  cert_path: process.env.SANCTUARY_DASHBOARD_TLS_CERT,
@@ -5699,26 +5705,26 @@ var DashboardApprovalChannel = class {
5699
5705
  const protocol = this.useTLS ? "https" : "http";
5700
5706
  const baseUrl = `${protocol}://${this.config.host}:${this.config.port}`;
5701
5707
  this.httpServer.listen(this.config.port, this.config.host, () => {
5708
+ const sessionUrl = this.authToken ? this.createSessionUrl() : baseUrl;
5702
5709
  process.stderr.write(
5703
5710
  `
5704
5711
  Sanctuary Principal Dashboard: ${baseUrl}
5705
5712
  `
5706
5713
  );
5707
5714
  if (this.authToken) {
5708
- const sessionUrl = this.createSessionUrl();
5709
- process.stderr.write(
5710
- ` Quick open: ${sessionUrl}
5711
- `
5712
- );
5713
5715
  const hint = this.authToken.slice(0, 4) + "..." + this.authToken.slice(-4);
5714
5716
  process.stderr.write(
5715
5717
  ` Auth token: ${hint}
5716
-
5717
5718
  `
5718
5719
  );
5719
- } else {
5720
- process.stderr.write(`
5720
+ }
5721
+ process.stderr.write(`
5721
5722
  `);
5723
+ const isTest = !!(process.env.VITEST || process.env.NODE_ENV === "test" || process.env.CI);
5724
+ const isLocalhost = this.config.host === "127.0.0.1" || this.config.host === "localhost" || this.config.host === "::1";
5725
+ const shouldAutoOpen = !isTest && (this.config.auto_open ?? isLocalhost);
5726
+ if (shouldAutoOpen) {
5727
+ this.openInBrowser(sessionUrl);
5722
5728
  }
5723
5729
  resolve();
5724
5730
  });
@@ -6250,6 +6256,31 @@ data: ${JSON.stringify(data)}
6250
6256
  broadcastProtectionStatus(data) {
6251
6257
  this.broadcastSSE("protection-status", data);
6252
6258
  }
6259
+ /**
6260
+ * Open a URL in the system's default browser.
6261
+ * Cross-platform: macOS (open), Linux (xdg-open), Windows (start).
6262
+ * Fails silently — dashboard still works via terminal URL.
6263
+ */
6264
+ openInBrowser(url) {
6265
+ const os$1 = os.platform();
6266
+ let cmd;
6267
+ if (os$1 === "darwin") {
6268
+ cmd = `open "${url}"`;
6269
+ } else if (os$1 === "win32") {
6270
+ cmd = `start "" "${url}"`;
6271
+ } else {
6272
+ cmd = `xdg-open "${url}"`;
6273
+ }
6274
+ child_process.exec(cmd, (err) => {
6275
+ if (err) {
6276
+ process.stderr.write(
6277
+ ` (Could not auto-open browser. Open the URL above manually.)
6278
+
6279
+ `
6280
+ );
6281
+ }
6282
+ });
6283
+ }
6253
6284
  /**
6254
6285
  * Create a pre-authenticated URL for the dashboard.
6255
6286
  * Used by the sanctuary_dashboard_open tool and at startup.
@@ -12041,7 +12072,8 @@ async function createSanctuaryServer(options) {
12041
12072
  timeout_seconds: policy.approval_channel.timeout_seconds,
12042
12073
  // SEC-002: auto_deny removed — timeout always denies
12043
12074
  auth_token: authToken,
12044
- tls: config.dashboard.tls
12075
+ tls: config.dashboard.tls,
12076
+ auto_open: config.dashboard.auto_open
12045
12077
  });
12046
12078
  dashboard.setDependencies({ policy, baseline, auditLog });
12047
12079
  await dashboard.start();