@aiwerk/mcp-bridge 2.8.19 → 2.8.21
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/src/mcp-router.js +26 -5
- package/package.json +1 -1
package/dist/src/mcp-router.js
CHANGED
|
@@ -159,11 +159,11 @@ export class McpRouter {
|
|
|
159
159
|
return this.error("mcp_error", `Catalog browse failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
// Install server from catalog (runtime
|
|
162
|
+
// Install server from catalog (runtime + persisted to config file)
|
|
163
163
|
if (normalizedAction === "install") {
|
|
164
|
-
const serverName = server || params?.server;
|
|
164
|
+
const serverName = server || params?.server || params?.name;
|
|
165
165
|
if (!serverName) {
|
|
166
|
-
return this.error("invalid_params", "server name is required for action=install");
|
|
166
|
+
return this.error("invalid_params", "server name is required for action=install (pass as server field or params.name)");
|
|
167
167
|
}
|
|
168
168
|
if (this.servers[serverName]) {
|
|
169
169
|
return { action: "install", server: serverName, installed: true, message: `Server "${serverName}" is already configured.` };
|
|
@@ -182,15 +182,36 @@ export class McpRouter {
|
|
|
182
182
|
const missing = requiredVars.filter(v => !process.env[v]);
|
|
183
183
|
// Add to runtime config
|
|
184
184
|
this.servers[serverName] = serverConfig;
|
|
185
|
-
// Also update clientConfig.servers so generateDescription includes it
|
|
186
185
|
this.clientConfig.servers[serverName] = serverConfig;
|
|
186
|
+
// Persist to config file
|
|
187
|
+
try {
|
|
188
|
+
const os = await import("os");
|
|
189
|
+
const fs = await import("fs");
|
|
190
|
+
const path = await import("path");
|
|
191
|
+
const configPath = path.join(os.homedir(), ".mcp-bridge", "config.json");
|
|
192
|
+
if (fs.existsSync(configPath)) {
|
|
193
|
+
const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
194
|
+
if (!raw.servers)
|
|
195
|
+
raw.servers = {};
|
|
196
|
+
if (!raw.servers[serverName]) {
|
|
197
|
+
raw.servers[serverName] = serverConfig;
|
|
198
|
+
fs.writeFileSync(configPath, JSON.stringify(raw, null, 2) + "\n", "utf-8");
|
|
199
|
+
this.logger.info(`Persisted "${serverName}" to ${configPath}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (persistErr) {
|
|
204
|
+
this.logger.warn(`Could not persist "${serverName}" to config: ${persistErr instanceof Error ? persistErr.message : String(persistErr)}`);
|
|
205
|
+
}
|
|
206
|
+
const credUrl = recipe.auth?.credentialsUrl;
|
|
187
207
|
if (missing.length > 0) {
|
|
188
208
|
return {
|
|
189
209
|
action: "install",
|
|
190
210
|
server: serverName,
|
|
191
211
|
installed: true,
|
|
192
|
-
message: `Server "${serverName}"
|
|
212
|
+
message: `Server "${serverName}" installed. Missing env vars: ${missing.join(", ")}. Set them before calling.`,
|
|
193
213
|
missingEnvVars: missing,
|
|
214
|
+
...(credUrl ? { credentialsUrl: credUrl } : {}),
|
|
194
215
|
};
|
|
195
216
|
}
|
|
196
217
|
return {
|