@solongate/proxy 0.1.27 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +84 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3382,6 +3382,8 @@ var SolonGateProxy = class {
3382
3382
  await this.connectUpstream();
3383
3383
  await this.discoverTools();
3384
3384
  this.registerToolsToCloud();
3385
+ this.registerServerToCloud();
3386
+ this.syncPolicyToCloud();
3385
3387
  this.createServer();
3386
3388
  await this.serve();
3387
3389
  this.startPolicyPolling();
@@ -3596,6 +3598,88 @@ var SolonGateProxy = class {
3596
3598
  }
3597
3599
  return ["READ"];
3598
3600
  }
3601
+ /**
3602
+ * Register the upstream MCP server to the SolonGate Cloud API.
3603
+ * This makes it visible on the Dashboard MCP Servers page.
3604
+ */
3605
+ registerServerToCloud() {
3606
+ if (!this.config.apiKey || this.config.apiKey.startsWith("sg_test_")) return;
3607
+ const apiUrl = this.config.apiUrl ?? "https://api.solongate.com";
3608
+ const transport = this.config.upstream.transport ?? "stdio";
3609
+ let serverName = this.config.name ?? "solongate-proxy";
3610
+ let serverUrl;
3611
+ let command;
3612
+ let args;
3613
+ if (transport === "stdio") {
3614
+ command = this.config.upstream.command;
3615
+ args = (this.config.upstream.args ?? []).join(" ");
3616
+ serverUrl = `stdio://${command}`;
3617
+ serverName = command || serverName;
3618
+ } else {
3619
+ serverUrl = this.config.upstream.url || "";
3620
+ try {
3621
+ const u = new URL(serverUrl);
3622
+ serverName = u.hostname || serverName;
3623
+ } catch {
3624
+ }
3625
+ }
3626
+ fetch(`${apiUrl}/api/v1/mcp-servers`, {
3627
+ method: "POST",
3628
+ headers: {
3629
+ "Authorization": `Bearer ${this.config.apiKey}`,
3630
+ "Content-Type": "application/json"
3631
+ },
3632
+ body: JSON.stringify({
3633
+ name: serverName,
3634
+ url: serverUrl,
3635
+ command: command || void 0,
3636
+ args: args || void 0
3637
+ })
3638
+ }).then(async (res) => {
3639
+ if (res.ok) {
3640
+ log(`Registered MCP server "${serverName}" to dashboard.`);
3641
+ } else if (res.status === 409) {
3642
+ log(`MCP server "${serverName}" already registered.`);
3643
+ } else {
3644
+ const body = await res.text().catch(() => "");
3645
+ log(`MCP server registration failed (${res.status}): ${body}`);
3646
+ }
3647
+ }).catch((err) => {
3648
+ log(`MCP server registration error: ${err instanceof Error ? err.message : String(err)}`);
3649
+ });
3650
+ }
3651
+ /**
3652
+ * Sync the active policy to the SolonGate Cloud API.
3653
+ * This makes it visible on the Dashboard Policies page.
3654
+ */
3655
+ syncPolicyToCloud() {
3656
+ if (!this.config.apiKey || this.config.apiKey.startsWith("sg_test_")) return;
3657
+ const apiUrl = this.config.apiUrl ?? "https://api.solongate.com";
3658
+ const policy = this.config.policy;
3659
+ fetch(`${apiUrl}/api/v1/policies`, {
3660
+ method: "POST",
3661
+ headers: {
3662
+ "Authorization": `Bearer ${this.config.apiKey}`,
3663
+ "Content-Type": "application/json"
3664
+ },
3665
+ body: JSON.stringify({
3666
+ id: policy.id || "default",
3667
+ name: policy.name || "Default Policy",
3668
+ description: policy.description || `Policy synced from proxy`,
3669
+ version: policy.version || 1,
3670
+ rules: policy.rules
3671
+ })
3672
+ }).then(async (res) => {
3673
+ if (res.ok) {
3674
+ log(`Synced policy "${policy.name}" to dashboard.`);
3675
+ } else {
3676
+ const body = await res.text().catch(() => "");
3677
+ log(`Policy sync failed (${res.status}): ${body}`);
3678
+ }
3679
+ }).catch((err) => {
3680
+ log(`Policy sync error: ${err instanceof Error ? err.message : String(err)}`);
3681
+ });
3682
+ }
3599
3683
  /**
3600
3684
  * Poll for policy updates from dashboard every 60 seconds.
3601
3685
  * When user changes policy in dashboard, proxy picks it up automatically.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.1.27",
3
+ "version": "0.2.0",
4
4
  "description": "MCP security proxy \u00e2\u20ac\u201d protect any MCP server with policies, input validation, rate limiting, and audit logging. Zero code changes required.",
5
5
  "type": "module",
6
6
  "bin": {