@solongate/proxy 0.5.4 → 0.5.5
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.js +14 -69
- package/dist/init.js +10 -65
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -524,7 +524,7 @@ var init_config = __esm({
|
|
|
524
524
|
|
|
525
525
|
// src/init.ts
|
|
526
526
|
var init_exports = {};
|
|
527
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync3,
|
|
527
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync } from "fs";
|
|
528
528
|
import { resolve as resolve2, join } from "path";
|
|
529
529
|
import { createInterface } from "readline";
|
|
530
530
|
function findConfigFile(explicitPath, createIfMissing = false) {
|
|
@@ -580,7 +580,7 @@ function isAlreadyProtected(server) {
|
|
|
580
580
|
}
|
|
581
581
|
return false;
|
|
582
582
|
}
|
|
583
|
-
function wrapServer(server
|
|
583
|
+
function wrapServer(server) {
|
|
584
584
|
const env = { ...server.env ?? {} };
|
|
585
585
|
env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
|
|
586
586
|
return {
|
|
@@ -589,7 +589,7 @@ function wrapServer(server, policy) {
|
|
|
589
589
|
"-y",
|
|
590
590
|
"@solongate/proxy",
|
|
591
591
|
"--policy",
|
|
592
|
-
|
|
592
|
+
"restricted",
|
|
593
593
|
"--verbose",
|
|
594
594
|
"--",
|
|
595
595
|
server.command,
|
|
@@ -610,44 +610,25 @@ async function prompt(question) {
|
|
|
610
610
|
function parseInitArgs(argv) {
|
|
611
611
|
const args = argv.slice(2);
|
|
612
612
|
const options = {
|
|
613
|
-
|
|
614
|
-
all: false,
|
|
615
|
-
dryRun: false,
|
|
616
|
-
restore: false
|
|
613
|
+
all: false
|
|
617
614
|
};
|
|
618
615
|
for (let i = 0; i < args.length; i++) {
|
|
619
616
|
switch (args[i]) {
|
|
620
617
|
case "--config":
|
|
621
618
|
options.configPath = args[++i];
|
|
622
619
|
break;
|
|
623
|
-
case "--policy":
|
|
624
|
-
options.policy = args[++i];
|
|
625
|
-
break;
|
|
626
620
|
case "--api-key":
|
|
627
621
|
options.apiKey = args[++i];
|
|
628
622
|
break;
|
|
629
623
|
case "--all":
|
|
630
624
|
options.all = true;
|
|
631
625
|
break;
|
|
632
|
-
case "--dry-run":
|
|
633
|
-
options.dryRun = true;
|
|
634
|
-
break;
|
|
635
|
-
case "--restore":
|
|
636
|
-
options.restore = true;
|
|
637
|
-
break;
|
|
638
626
|
case "--help":
|
|
639
627
|
case "-h":
|
|
640
628
|
printHelp();
|
|
641
629
|
process.exit(0);
|
|
642
630
|
}
|
|
643
631
|
}
|
|
644
|
-
if (!POLICY_PRESETS.includes(options.policy)) {
|
|
645
|
-
if (!existsSync3(resolve2(options.policy))) {
|
|
646
|
-
console.log(`Unknown policy: ${options.policy}`);
|
|
647
|
-
console.log(`Available presets: ${POLICY_PRESETS.join(", ")}`);
|
|
648
|
-
process.exit(1);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
632
|
return options;
|
|
652
633
|
}
|
|
653
634
|
function printHelp() {
|
|
@@ -655,30 +636,17 @@ function printHelp() {
|
|
|
655
636
|
SolonGate Init \u2014 Protect your MCP servers in seconds
|
|
656
637
|
|
|
657
638
|
USAGE
|
|
658
|
-
solongate
|
|
639
|
+
npx @solongate/proxy init --all
|
|
659
640
|
|
|
660
641
|
OPTIONS
|
|
661
642
|
--config <path> Path to MCP config file (default: auto-detect)
|
|
662
|
-
--policy <preset> Policy preset or JSON file (default: restricted)
|
|
663
|
-
Presets: ${POLICY_PRESETS.join(", ")}
|
|
664
643
|
--api-key <key> SolonGate API key (sg_live_... or sg_test_...)
|
|
665
644
|
--all Protect all servers without prompting
|
|
666
|
-
--dry-run Preview changes without writing
|
|
667
|
-
--restore Restore original config from backup
|
|
668
645
|
-h, --help Show this help message
|
|
669
646
|
|
|
670
647
|
EXAMPLES
|
|
671
|
-
solongate
|
|
672
|
-
solongate
|
|
673
|
-
solongate-init --policy read-only # Use read-only policy
|
|
674
|
-
solongate-init --dry-run # Preview changes
|
|
675
|
-
solongate-init --restore # Undo protection
|
|
676
|
-
|
|
677
|
-
POLICY PRESETS
|
|
678
|
-
restricted Block shell/exec/eval, allow reads and writes (recommended)
|
|
679
|
-
read-only Only allow read/list/get/search/query operations
|
|
680
|
-
permissive Allow everything (monitoring + audit only)
|
|
681
|
-
deny-all Block all tool calls
|
|
648
|
+
npx @solongate/proxy init --all # Protect everything
|
|
649
|
+
npx @solongate/proxy init --api-key sg_live_xxx # With API key
|
|
682
650
|
`;
|
|
683
651
|
console.log(help);
|
|
684
652
|
}
|
|
@@ -776,16 +744,6 @@ async function main() {
|
|
|
776
744
|
console.log(` Config: ${configInfo.path}`);
|
|
777
745
|
console.log(` Type: ${configInfo.type === "claude-desktop" ? "Claude Desktop" : "MCP JSON"}`);
|
|
778
746
|
console.log("");
|
|
779
|
-
const backupPath = configInfo.path + ".solongate-backup";
|
|
780
|
-
if (options.restore) {
|
|
781
|
-
if (!existsSync3(backupPath)) {
|
|
782
|
-
console.log(" No backup found. Nothing to restore.");
|
|
783
|
-
process.exit(1);
|
|
784
|
-
}
|
|
785
|
-
copyFileSync(backupPath, configInfo.path);
|
|
786
|
-
console.log(" Restored original config from backup.");
|
|
787
|
-
process.exit(0);
|
|
788
|
-
}
|
|
789
747
|
const config = readConfig(configInfo.path);
|
|
790
748
|
const serverNames = Object.keys(config.mcpServers);
|
|
791
749
|
if (serverNames.length === 0) {
|
|
@@ -865,7 +823,7 @@ async function main() {
|
|
|
865
823
|
process.exit(1);
|
|
866
824
|
}
|
|
867
825
|
await sleep(300);
|
|
868
|
-
console.log(` Policy:
|
|
826
|
+
console.log(` Policy: restricted`);
|
|
869
827
|
await sleep(150);
|
|
870
828
|
console.log(` API Key: ${apiKey.slice(0, 12)}...${apiKey.slice(-4)}`);
|
|
871
829
|
await sleep(150);
|
|
@@ -874,23 +832,12 @@ async function main() {
|
|
|
874
832
|
const newConfig = { mcpServers: {} };
|
|
875
833
|
for (const name of serverNames) {
|
|
876
834
|
if (toProtect.includes(name)) {
|
|
877
|
-
newConfig.mcpServers[name] = wrapServer(config.mcpServers[name]
|
|
835
|
+
newConfig.mcpServers[name] = wrapServer(config.mcpServers[name]);
|
|
878
836
|
} else {
|
|
879
837
|
newConfig.mcpServers[name] = config.mcpServers[name];
|
|
880
838
|
}
|
|
881
839
|
}
|
|
882
|
-
if (options.dryRun) {
|
|
883
|
-
console.log(" --- DRY RUN (no changes written) ---");
|
|
884
|
-
console.log("");
|
|
885
|
-
console.log(" New config:");
|
|
886
|
-
console.log(JSON.stringify(newConfig, null, 2));
|
|
887
|
-
process.exit(0);
|
|
888
|
-
}
|
|
889
840
|
await sleep(400);
|
|
890
|
-
if (!configInfo.created && !existsSync3(backupPath)) {
|
|
891
|
-
copyFileSync(configInfo.path, backupPath);
|
|
892
|
-
console.log(` Backup: ${backupPath}`);
|
|
893
|
-
}
|
|
894
841
|
if (configInfo.type === "claude-desktop") {
|
|
895
842
|
const original = JSON.parse(readFileSync3(configInfo.path, "utf-8"));
|
|
896
843
|
original.mcpServers = newConfig.mcpServers;
|
|
@@ -909,7 +856,7 @@ async function main() {
|
|
|
909
856
|
console.log("");
|
|
910
857
|
for (const name of toProtect) {
|
|
911
858
|
await sleep(200);
|
|
912
|
-
console.log(` \u2713 ${name} \u2014 protected
|
|
859
|
+
console.log(` \u2713 ${name} \u2014 protected`);
|
|
913
860
|
}
|
|
914
861
|
for (const name of alreadyProtected) {
|
|
915
862
|
await sleep(200);
|
|
@@ -929,17 +876,15 @@ async function main() {
|
|
|
929
876
|
console.log(" \u2502 API key \u2192 Set in .env \u2502");
|
|
930
877
|
console.log(" \u2502 \u2502");
|
|
931
878
|
console.log(" \u2502 View logs: https://dashboard.solongate.com \u2502");
|
|
932
|
-
console.log(" \u2502 To undo: npx @solongate/proxy init --restore \u2502");
|
|
933
879
|
console.log(" \u2502 \u2502");
|
|
934
880
|
console.log(" \u2502 Restart your MCP client to apply changes. \u2502");
|
|
935
881
|
console.log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
936
882
|
console.log("");
|
|
937
883
|
}
|
|
938
|
-
var
|
|
884
|
+
var SEARCH_PATHS, CLAUDE_DESKTOP_PATHS, sleep, GUARD_SCRIPT, AUDIT_SCRIPT;
|
|
939
885
|
var init_init = __esm({
|
|
940
886
|
"src/init.ts"() {
|
|
941
887
|
"use strict";
|
|
942
|
-
POLICY_PRESETS = ["restricted", "read-only", "permissive", "deny-all"];
|
|
943
888
|
SEARCH_PATHS = [
|
|
944
889
|
".mcp.json",
|
|
945
890
|
"mcp.json",
|
|
@@ -1162,7 +1107,7 @@ process.stdin.on('end', async () => {
|
|
|
1162
1107
|
|
|
1163
1108
|
// src/inject.ts
|
|
1164
1109
|
var inject_exports = {};
|
|
1165
|
-
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync4, copyFileSync
|
|
1110
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync4, copyFileSync } from "fs";
|
|
1166
1111
|
import { resolve as resolve3 } from "path";
|
|
1167
1112
|
import { execSync } from "child_process";
|
|
1168
1113
|
function parseInjectArgs(argv) {
|
|
@@ -1454,7 +1399,7 @@ async function main2() {
|
|
|
1454
1399
|
log3(" No backup found. Nothing to restore.");
|
|
1455
1400
|
process.exit(1);
|
|
1456
1401
|
}
|
|
1457
|
-
|
|
1402
|
+
copyFileSync(backupPath, entryFile);
|
|
1458
1403
|
log3(` Restored original file from backup.`);
|
|
1459
1404
|
log3(` Backup: ${backupPath}`);
|
|
1460
1405
|
process.exit(0);
|
|
@@ -1487,7 +1432,7 @@ async function main2() {
|
|
|
1487
1432
|
process.exit(0);
|
|
1488
1433
|
}
|
|
1489
1434
|
if (!existsSync4(backupPath)) {
|
|
1490
|
-
|
|
1435
|
+
copyFileSync(entryFile, backupPath);
|
|
1491
1436
|
log3("");
|
|
1492
1437
|
log3(` Backup: ${backupPath}`);
|
|
1493
1438
|
}
|
package/dist/init.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/init.ts
|
|
4
|
-
import { readFileSync, writeFileSync, existsSync,
|
|
4
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
5
5
|
import { resolve, join } from "path";
|
|
6
6
|
import { createInterface } from "readline";
|
|
7
|
-
var POLICY_PRESETS = ["restricted", "read-only", "permissive", "deny-all"];
|
|
8
7
|
var SEARCH_PATHS = [
|
|
9
8
|
".mcp.json",
|
|
10
9
|
"mcp.json",
|
|
@@ -65,7 +64,7 @@ function isAlreadyProtected(server) {
|
|
|
65
64
|
}
|
|
66
65
|
return false;
|
|
67
66
|
}
|
|
68
|
-
function wrapServer(server
|
|
67
|
+
function wrapServer(server) {
|
|
69
68
|
const env = { ...server.env ?? {} };
|
|
70
69
|
env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
|
|
71
70
|
return {
|
|
@@ -74,7 +73,7 @@ function wrapServer(server, policy) {
|
|
|
74
73
|
"-y",
|
|
75
74
|
"@solongate/proxy",
|
|
76
75
|
"--policy",
|
|
77
|
-
|
|
76
|
+
"restricted",
|
|
78
77
|
"--verbose",
|
|
79
78
|
"--",
|
|
80
79
|
server.command,
|
|
@@ -95,44 +94,25 @@ async function prompt(question) {
|
|
|
95
94
|
function parseInitArgs(argv) {
|
|
96
95
|
const args = argv.slice(2);
|
|
97
96
|
const options = {
|
|
98
|
-
|
|
99
|
-
all: false,
|
|
100
|
-
dryRun: false,
|
|
101
|
-
restore: false
|
|
97
|
+
all: false
|
|
102
98
|
};
|
|
103
99
|
for (let i = 0; i < args.length; i++) {
|
|
104
100
|
switch (args[i]) {
|
|
105
101
|
case "--config":
|
|
106
102
|
options.configPath = args[++i];
|
|
107
103
|
break;
|
|
108
|
-
case "--policy":
|
|
109
|
-
options.policy = args[++i];
|
|
110
|
-
break;
|
|
111
104
|
case "--api-key":
|
|
112
105
|
options.apiKey = args[++i];
|
|
113
106
|
break;
|
|
114
107
|
case "--all":
|
|
115
108
|
options.all = true;
|
|
116
109
|
break;
|
|
117
|
-
case "--dry-run":
|
|
118
|
-
options.dryRun = true;
|
|
119
|
-
break;
|
|
120
|
-
case "--restore":
|
|
121
|
-
options.restore = true;
|
|
122
|
-
break;
|
|
123
110
|
case "--help":
|
|
124
111
|
case "-h":
|
|
125
112
|
printHelp();
|
|
126
113
|
process.exit(0);
|
|
127
114
|
}
|
|
128
115
|
}
|
|
129
|
-
if (!POLICY_PRESETS.includes(options.policy)) {
|
|
130
|
-
if (!existsSync(resolve(options.policy))) {
|
|
131
|
-
console.log(`Unknown policy: ${options.policy}`);
|
|
132
|
-
console.log(`Available presets: ${POLICY_PRESETS.join(", ")}`);
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
116
|
return options;
|
|
137
117
|
}
|
|
138
118
|
function printHelp() {
|
|
@@ -140,30 +120,17 @@ function printHelp() {
|
|
|
140
120
|
SolonGate Init \u2014 Protect your MCP servers in seconds
|
|
141
121
|
|
|
142
122
|
USAGE
|
|
143
|
-
solongate
|
|
123
|
+
npx @solongate/proxy init --all
|
|
144
124
|
|
|
145
125
|
OPTIONS
|
|
146
126
|
--config <path> Path to MCP config file (default: auto-detect)
|
|
147
|
-
--policy <preset> Policy preset or JSON file (default: restricted)
|
|
148
|
-
Presets: ${POLICY_PRESETS.join(", ")}
|
|
149
127
|
--api-key <key> SolonGate API key (sg_live_... or sg_test_...)
|
|
150
128
|
--all Protect all servers without prompting
|
|
151
|
-
--dry-run Preview changes without writing
|
|
152
|
-
--restore Restore original config from backup
|
|
153
129
|
-h, --help Show this help message
|
|
154
130
|
|
|
155
131
|
EXAMPLES
|
|
156
|
-
solongate
|
|
157
|
-
solongate
|
|
158
|
-
solongate-init --policy read-only # Use read-only policy
|
|
159
|
-
solongate-init --dry-run # Preview changes
|
|
160
|
-
solongate-init --restore # Undo protection
|
|
161
|
-
|
|
162
|
-
POLICY PRESETS
|
|
163
|
-
restricted Block shell/exec/eval, allow reads and writes (recommended)
|
|
164
|
-
read-only Only allow read/list/get/search/query operations
|
|
165
|
-
permissive Allow everything (monitoring + audit only)
|
|
166
|
-
deny-all Block all tool calls
|
|
132
|
+
npx @solongate/proxy init --all # Protect everything
|
|
133
|
+
npx @solongate/proxy init --api-key sg_live_xxx # With API key
|
|
167
134
|
`;
|
|
168
135
|
console.log(help);
|
|
169
136
|
}
|
|
@@ -467,16 +434,6 @@ async function main() {
|
|
|
467
434
|
console.log(` Config: ${configInfo.path}`);
|
|
468
435
|
console.log(` Type: ${configInfo.type === "claude-desktop" ? "Claude Desktop" : "MCP JSON"}`);
|
|
469
436
|
console.log("");
|
|
470
|
-
const backupPath = configInfo.path + ".solongate-backup";
|
|
471
|
-
if (options.restore) {
|
|
472
|
-
if (!existsSync(backupPath)) {
|
|
473
|
-
console.log(" No backup found. Nothing to restore.");
|
|
474
|
-
process.exit(1);
|
|
475
|
-
}
|
|
476
|
-
copyFileSync(backupPath, configInfo.path);
|
|
477
|
-
console.log(" Restored original config from backup.");
|
|
478
|
-
process.exit(0);
|
|
479
|
-
}
|
|
480
437
|
const config = readConfig(configInfo.path);
|
|
481
438
|
const serverNames = Object.keys(config.mcpServers);
|
|
482
439
|
if (serverNames.length === 0) {
|
|
@@ -556,7 +513,7 @@ async function main() {
|
|
|
556
513
|
process.exit(1);
|
|
557
514
|
}
|
|
558
515
|
await sleep(300);
|
|
559
|
-
console.log(` Policy:
|
|
516
|
+
console.log(` Policy: restricted`);
|
|
560
517
|
await sleep(150);
|
|
561
518
|
console.log(` API Key: ${apiKey.slice(0, 12)}...${apiKey.slice(-4)}`);
|
|
562
519
|
await sleep(150);
|
|
@@ -565,23 +522,12 @@ async function main() {
|
|
|
565
522
|
const newConfig = { mcpServers: {} };
|
|
566
523
|
for (const name of serverNames) {
|
|
567
524
|
if (toProtect.includes(name)) {
|
|
568
|
-
newConfig.mcpServers[name] = wrapServer(config.mcpServers[name]
|
|
525
|
+
newConfig.mcpServers[name] = wrapServer(config.mcpServers[name]);
|
|
569
526
|
} else {
|
|
570
527
|
newConfig.mcpServers[name] = config.mcpServers[name];
|
|
571
528
|
}
|
|
572
529
|
}
|
|
573
|
-
if (options.dryRun) {
|
|
574
|
-
console.log(" --- DRY RUN (no changes written) ---");
|
|
575
|
-
console.log("");
|
|
576
|
-
console.log(" New config:");
|
|
577
|
-
console.log(JSON.stringify(newConfig, null, 2));
|
|
578
|
-
process.exit(0);
|
|
579
|
-
}
|
|
580
530
|
await sleep(400);
|
|
581
|
-
if (!configInfo.created && !existsSync(backupPath)) {
|
|
582
|
-
copyFileSync(configInfo.path, backupPath);
|
|
583
|
-
console.log(` Backup: ${backupPath}`);
|
|
584
|
-
}
|
|
585
531
|
if (configInfo.type === "claude-desktop") {
|
|
586
532
|
const original = JSON.parse(readFileSync(configInfo.path, "utf-8"));
|
|
587
533
|
original.mcpServers = newConfig.mcpServers;
|
|
@@ -600,7 +546,7 @@ async function main() {
|
|
|
600
546
|
console.log("");
|
|
601
547
|
for (const name of toProtect) {
|
|
602
548
|
await sleep(200);
|
|
603
|
-
console.log(` \u2713 ${name} \u2014 protected
|
|
549
|
+
console.log(` \u2713 ${name} \u2014 protected`);
|
|
604
550
|
}
|
|
605
551
|
for (const name of alreadyProtected) {
|
|
606
552
|
await sleep(200);
|
|
@@ -620,7 +566,6 @@ async function main() {
|
|
|
620
566
|
console.log(" \u2502 API key \u2192 Set in .env \u2502");
|
|
621
567
|
console.log(" \u2502 \u2502");
|
|
622
568
|
console.log(" \u2502 View logs: https://dashboard.solongate.com \u2502");
|
|
623
|
-
console.log(" \u2502 To undo: npx @solongate/proxy init --restore \u2502");
|
|
624
569
|
console.log(" \u2502 \u2502");
|
|
625
570
|
console.log(" \u2502 Restart your MCP client to apply changes. \u2502");
|
|
626
571
|
console.log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "MCP security proxy — protect any MCP server with customizable policies, path/command constraints, rate limiting, and audit logging. Zero code changes required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|