@aiwerk/mcp-bridge 2.8.33 → 2.8.35
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/bin/mcp-bridge.js +45 -3
- package/package.json +1 -1
package/dist/bin/mcp-bridge.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
2
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync, unlinkSync } from "fs";
|
|
3
3
|
import { join, dirname, resolve, extname } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { homedir } from "os";
|
|
@@ -136,6 +136,10 @@ function parseArgs(argv) {
|
|
|
136
136
|
case "install":
|
|
137
137
|
args.command = "install";
|
|
138
138
|
break;
|
|
139
|
+
case "remove":
|
|
140
|
+
case "uninstall":
|
|
141
|
+
args.command = "remove";
|
|
142
|
+
break;
|
|
139
143
|
case "catalog":
|
|
140
144
|
args.command = "catalog";
|
|
141
145
|
break;
|
|
@@ -189,6 +193,7 @@ Usage:
|
|
|
189
193
|
mcp-bridge --http --port 3000 Start as streamable-http server
|
|
190
194
|
mcp-bridge init [--register <client>] [--mode router|direct] Create config + optionally register
|
|
191
195
|
mcp-bridge install <server> Install a server from the catalog
|
|
196
|
+
mcp-bridge remove <server> Remove a configured server
|
|
192
197
|
mcp-bridge catalog [--offline] List available servers
|
|
193
198
|
mcp-bridge servers List configured servers
|
|
194
199
|
mcp-bridge search <query> Search catalog by keyword
|
|
@@ -593,8 +598,11 @@ async function cmdInstall(serverName, args, logger) {
|
|
|
593
598
|
}
|
|
594
599
|
else {
|
|
595
600
|
process.stdout.write(`All required environment variables are set. Ready to use.\n`);
|
|
596
|
-
|
|
597
|
-
|
|
601
|
+
}
|
|
602
|
+
// Pre-discover tools and cache them (so direct mode has tools on first start)
|
|
603
|
+
// Try even with missing env vars — many servers respond to tools/list without auth
|
|
604
|
+
process.stdout.write(`\nDiscovering tools...\n`);
|
|
605
|
+
{
|
|
598
606
|
try {
|
|
599
607
|
const { StdioTransport } = await import("../src/transport-stdio.js");
|
|
600
608
|
const { SseTransport } = await import("../src/transport-sse.js");
|
|
@@ -630,6 +638,33 @@ async function cmdInstall(serverName, args, logger) {
|
|
|
630
638
|
}
|
|
631
639
|
}
|
|
632
640
|
}
|
|
641
|
+
function cmdRemove(serverName, args, logger) {
|
|
642
|
+
const configPath = resolveConfigPath(args.configPath);
|
|
643
|
+
if (!existsSync(configPath)) {
|
|
644
|
+
logger.error("No config file found.");
|
|
645
|
+
process.exit(1);
|
|
646
|
+
}
|
|
647
|
+
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
648
|
+
if (!raw.servers || !raw.servers[serverName]) {
|
|
649
|
+
process.stdout.write(`Server "${serverName}" is not configured.\n`);
|
|
650
|
+
const available = Object.keys(raw.servers || {});
|
|
651
|
+
if (available.length > 0) {
|
|
652
|
+
process.stdout.write(`Configured servers: ${available.join(", ")}\n`);
|
|
653
|
+
}
|
|
654
|
+
process.exit(1);
|
|
655
|
+
}
|
|
656
|
+
// Remove from config
|
|
657
|
+
delete raw.servers[serverName];
|
|
658
|
+
writeFileSync(configPath, JSON.stringify(raw, null, 2) + "\n", "utf-8");
|
|
659
|
+
process.stdout.write(`✓ Removed "${serverName}" from ${configPath}\n`);
|
|
660
|
+
// Remove tool cache
|
|
661
|
+
const cacheDir = join(dirname(configPath), "cache");
|
|
662
|
+
const cachePath = join(cacheDir, `${serverName}-tools.json`);
|
|
663
|
+
if (existsSync(cachePath)) {
|
|
664
|
+
unlinkSync(cachePath);
|
|
665
|
+
process.stdout.write(`✓ Removed tool cache for "${serverName}"\n`);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
633
668
|
async function cmdUpdate(logger, checkOnly) {
|
|
634
669
|
if (checkOnly) {
|
|
635
670
|
const info = await checkForUpdate(logger);
|
|
@@ -853,6 +888,13 @@ async function main() {
|
|
|
853
888
|
}
|
|
854
889
|
await cmdInstall(args.positional[0], args, logger);
|
|
855
890
|
break;
|
|
891
|
+
case "remove":
|
|
892
|
+
if (args.positional.length === 0) {
|
|
893
|
+
process.stderr.write("Usage: mcp-bridge remove <server>\n");
|
|
894
|
+
process.exit(1);
|
|
895
|
+
}
|
|
896
|
+
cmdRemove(args.positional[0], args, logger);
|
|
897
|
+
break;
|
|
856
898
|
case "update":
|
|
857
899
|
await cmdUpdate(logger, args.checkOnly);
|
|
858
900
|
break;
|