@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/index.cjs CHANGED
@@ -293,6 +293,12 @@ async function loadConfig(configPath) {
293
293
  if (process.env.SANCTUARY_DASHBOARD_AUTH_TOKEN) {
294
294
  config.dashboard.auth_token = process.env.SANCTUARY_DASHBOARD_AUTH_TOKEN;
295
295
  }
296
+ if (process.env.SANCTUARY_DASHBOARD_AUTO_OPEN === "true") {
297
+ config.dashboard.auto_open = true;
298
+ }
299
+ if (process.env.SANCTUARY_DASHBOARD_AUTO_OPEN === "false") {
300
+ config.dashboard.auto_open = false;
301
+ }
296
302
  if (process.env.SANCTUARY_DASHBOARD_TLS_CERT && process.env.SANCTUARY_DASHBOARD_TLS_KEY) {
297
303
  config.dashboard.tls = {
298
304
  cert_path: process.env.SANCTUARY_DASHBOARD_TLS_CERT,
@@ -5715,26 +5721,26 @@ var DashboardApprovalChannel = class {
5715
5721
  const protocol = this.useTLS ? "https" : "http";
5716
5722
  const baseUrl = `${protocol}://${this.config.host}:${this.config.port}`;
5717
5723
  this.httpServer.listen(this.config.port, this.config.host, () => {
5724
+ const sessionUrl = this.authToken ? this.createSessionUrl() : baseUrl;
5718
5725
  process.stderr.write(
5719
5726
  `
5720
5727
  Sanctuary Principal Dashboard: ${baseUrl}
5721
5728
  `
5722
5729
  );
5723
5730
  if (this.authToken) {
5724
- const sessionUrl = this.createSessionUrl();
5725
- process.stderr.write(
5726
- ` Quick open: ${sessionUrl}
5727
- `
5728
- );
5729
5731
  const hint = this.authToken.slice(0, 4) + "..." + this.authToken.slice(-4);
5730
5732
  process.stderr.write(
5731
5733
  ` Auth token: ${hint}
5732
-
5733
5734
  `
5734
5735
  );
5735
- } else {
5736
- process.stderr.write(`
5736
+ }
5737
+ process.stderr.write(`
5737
5738
  `);
5739
+ const isTest = !!(process.env.VITEST || process.env.NODE_ENV === "test" || process.env.CI);
5740
+ const isLocalhost = this.config.host === "127.0.0.1" || this.config.host === "localhost" || this.config.host === "::1";
5741
+ const shouldAutoOpen = !isTest && (this.config.auto_open ?? isLocalhost);
5742
+ if (shouldAutoOpen) {
5743
+ this.openInBrowser(sessionUrl);
5738
5744
  }
5739
5745
  resolve();
5740
5746
  });
@@ -6266,6 +6272,31 @@ data: ${JSON.stringify(data)}
6266
6272
  broadcastProtectionStatus(data) {
6267
6273
  this.broadcastSSE("protection-status", data);
6268
6274
  }
6275
+ /**
6276
+ * Open a URL in the system's default browser.
6277
+ * Cross-platform: macOS (open), Linux (xdg-open), Windows (start).
6278
+ * Fails silently — dashboard still works via terminal URL.
6279
+ */
6280
+ openInBrowser(url) {
6281
+ const os$1 = os.platform();
6282
+ let cmd;
6283
+ if (os$1 === "darwin") {
6284
+ cmd = `open "${url}"`;
6285
+ } else if (os$1 === "win32") {
6286
+ cmd = `start "" "${url}"`;
6287
+ } else {
6288
+ cmd = `xdg-open "${url}"`;
6289
+ }
6290
+ child_process.exec(cmd, (err) => {
6291
+ if (err) {
6292
+ process.stderr.write(
6293
+ ` (Could not auto-open browser. Open the URL above manually.)
6294
+
6295
+ `
6296
+ );
6297
+ }
6298
+ });
6299
+ }
6269
6300
  /**
6270
6301
  * Create a pre-authenticated URL for the dashboard.
6271
6302
  * Used by the sanctuary_dashboard_open tool and at startup.
@@ -12112,7 +12143,8 @@ async function createSanctuaryServer(options) {
12112
12143
  timeout_seconds: policy.approval_channel.timeout_seconds,
12113
12144
  // SEC-002: auto_deny removed — timeout always denies
12114
12145
  auth_token: authToken,
12115
- tls: config.dashboard.tls
12146
+ tls: config.dashboard.tls,
12147
+ auto_open: config.dashboard.auto_open
12116
12148
  });
12117
12149
  dashboard.setDependencies({ policy, baseline, auditLog });
12118
12150
  await dashboard.start();