@agimon-ai/mcp-proxy 0.4.9 → 0.4.10

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/cli.cjs CHANGED
@@ -138,6 +138,27 @@ function resolveWorkspaceRoot(startPath = process.env.PROJECT_PATH || process.cw
138
138
  current = parent;
139
139
  }
140
140
  }
141
+ const PROCESS_REGISTRY_SERVICE_HTTP$1 = "mcp-proxy-http";
142
+ async function findExistingHealthyRuntime(workspaceRoot) {
143
+ const match = (await new __agimon_ai_foundation_process_registry.ProcessRegistryService(process.env.PROCESS_REGISTRY_PATH).listProcesses({
144
+ repositoryPath: workspaceRoot,
145
+ serviceName: PROCESS_REGISTRY_SERVICE_HTTP$1
146
+ }))[0];
147
+ if (!match?.host || !match?.port) return null;
148
+ try {
149
+ const healthUrl = `http://${match.host}:${match.port}/health`;
150
+ if ((await fetch(healthUrl)).ok) {
151
+ const metadata = match.metadata;
152
+ return {
153
+ host: match.host,
154
+ port: match.port,
155
+ serverId: metadata?.serverId ?? "unknown",
156
+ workspaceRoot
157
+ };
158
+ }
159
+ } catch {}
160
+ return null;
161
+ }
141
162
  function resolveSiblingRegistryPath(registryPath, fileName) {
142
163
  if (!registryPath) return;
143
164
  const resolved = node_path.default.resolve(registryPath);
@@ -241,6 +262,8 @@ async function prestartHttpRuntime(options) {
241
262
  const timeoutMs = parseTimeoutMs(options.timeoutMs);
242
263
  const registryPath = options.registryPath || options.registryDir;
243
264
  const workspaceRoot = resolveWorkspaceRoot();
265
+ const existing = await findExistingHealthyRuntime(workspaceRoot);
266
+ if (existing) return existing;
244
267
  await stopExistingRuntime(new require_src.RuntimeStateService(), options.id, options.host, options.port);
245
268
  const childEnv = {
246
269
  ...process.env,
@@ -281,7 +304,7 @@ async function prestartHttpRuntime(options) {
281
304
  workspaceRoot
282
305
  };
283
306
  } catch (error) {
284
- throw new Error(`Failed to prestart HTTP runtime '${serverId}': ${error instanceof Error ? error.message : String(error)}`);
307
+ throw new Error(`Failed to prestart HTTP runtime '${serverId}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
285
308
  }
286
309
  }
287
310
  const prestartHttpCommand = new commander.Command("prestart-http").description("Start an mcp-proxy HTTP runtime in the background and wait until it is healthy").option("--id <id>", "Server identifier to assign to the runtime").option("--host <host>", "Host to bind to", DEFAULT_HOST$1).option("-p, --port <port>", "Preferred HTTP port for the runtime", (value) => Number.parseInt(value, 10)).option("-c, --config <path>", "Path to MCP server configuration file").option("--no-cache", "Disable configuration caching, always reload from config file").option("--definitions-cache <path>", "Path to prefetched tool/prompt/skill definitions cache file").option("--clear-definitions-cache", "Delete definitions cache before startup", false).option("--proxy-mode <mode>", "How mcp-proxy exposes downstream tools: meta, flat, or search", "meta").option("--registry-path <path>", "Custom registry path or directory for service discovery").option("--registry-dir <path>", "Custom registry directory for service discovery").option("--timeout-ms <ms>", "How long to wait for the runtime to become healthy", String(DEFAULT_TIMEOUT_MS)).action(async (options) => {
@@ -292,7 +315,7 @@ const prestartHttpCommand = new commander.Command("prestart-http").description("
292
315
  process.stdout.write(`runtimeUrl=http://${host}:${port}\n`);
293
316
  process.stdout.write(`workspaceRoot=${workspaceRoot}\n`);
294
317
  } catch (error) {
295
- throw new Error(`Failed to prestart HTTP runtime '${options.id || "generated-server-id"}': ${error instanceof Error ? error.message : String(error)}`);
318
+ throw new Error(`Failed to prestart HTTP runtime '${options.id || "generated-server-id"}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
296
319
  }
297
320
  });
298
321
 
package/dist/cli.mjs CHANGED
@@ -137,6 +137,27 @@ function resolveWorkspaceRoot(startPath = process.env.PROJECT_PATH || process.cw
137
137
  current = parent;
138
138
  }
139
139
  }
140
+ const PROCESS_REGISTRY_SERVICE_HTTP$1 = "mcp-proxy-http";
141
+ async function findExistingHealthyRuntime(workspaceRoot) {
142
+ const match = (await new ProcessRegistryService(process.env.PROCESS_REGISTRY_PATH).listProcesses({
143
+ repositoryPath: workspaceRoot,
144
+ serviceName: PROCESS_REGISTRY_SERVICE_HTTP$1
145
+ }))[0];
146
+ if (!match?.host || !match?.port) return null;
147
+ try {
148
+ const healthUrl = `http://${match.host}:${match.port}/health`;
149
+ if ((await fetch(healthUrl)).ok) {
150
+ const metadata = match.metadata;
151
+ return {
152
+ host: match.host,
153
+ port: match.port,
154
+ serverId: metadata?.serverId ?? "unknown",
155
+ workspaceRoot
156
+ };
157
+ }
158
+ } catch {}
159
+ return null;
160
+ }
140
161
  function resolveSiblingRegistryPath(registryPath, fileName) {
141
162
  if (!registryPath) return;
142
163
  const resolved = path.resolve(registryPath);
@@ -240,6 +261,8 @@ async function prestartHttpRuntime(options) {
240
261
  const timeoutMs = parseTimeoutMs(options.timeoutMs);
241
262
  const registryPath = options.registryPath || options.registryDir;
242
263
  const workspaceRoot = resolveWorkspaceRoot();
264
+ const existing = await findExistingHealthyRuntime(workspaceRoot);
265
+ if (existing) return existing;
243
266
  await stopExistingRuntime(new RuntimeStateService(), options.id, options.host, options.port);
244
267
  const childEnv = {
245
268
  ...process.env,
@@ -280,7 +303,7 @@ async function prestartHttpRuntime(options) {
280
303
  workspaceRoot
281
304
  };
282
305
  } catch (error) {
283
- throw new Error(`Failed to prestart HTTP runtime '${serverId}': ${error instanceof Error ? error.message : String(error)}`);
306
+ throw new Error(`Failed to prestart HTTP runtime '${serverId}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
284
307
  }
285
308
  }
286
309
  const prestartHttpCommand = new Command("prestart-http").description("Start an mcp-proxy HTTP runtime in the background and wait until it is healthy").option("--id <id>", "Server identifier to assign to the runtime").option("--host <host>", "Host to bind to", DEFAULT_HOST$1).option("-p, --port <port>", "Preferred HTTP port for the runtime", (value) => Number.parseInt(value, 10)).option("-c, --config <path>", "Path to MCP server configuration file").option("--no-cache", "Disable configuration caching, always reload from config file").option("--definitions-cache <path>", "Path to prefetched tool/prompt/skill definitions cache file").option("--clear-definitions-cache", "Delete definitions cache before startup", false).option("--proxy-mode <mode>", "How mcp-proxy exposes downstream tools: meta, flat, or search", "meta").option("--registry-path <path>", "Custom registry path or directory for service discovery").option("--registry-dir <path>", "Custom registry directory for service discovery").option("--timeout-ms <ms>", "How long to wait for the runtime to become healthy", String(DEFAULT_TIMEOUT_MS)).action(async (options) => {
@@ -291,7 +314,7 @@ const prestartHttpCommand = new Command("prestart-http").description("Start an m
291
314
  process.stdout.write(`runtimeUrl=http://${host}:${port}\n`);
292
315
  process.stdout.write(`workspaceRoot=${workspaceRoot}\n`);
293
316
  } catch (error) {
294
- throw new Error(`Failed to prestart HTTP runtime '${options.id || "generated-server-id"}': ${error instanceof Error ? error.message : String(error)}`);
317
+ throw new Error(`Failed to prestart HTTP runtime '${options.id || "generated-server-id"}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
295
318
  }
296
319
  });
297
320
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agimon-ai/mcp-proxy",
3
3
  "description": "MCP proxy server package",
4
- "version": "0.4.9",
4
+ "version": "0.4.10",
5
5
  "license": "AGPL-3.0",
6
6
  "keywords": [
7
7
  "mcp",
@@ -27,9 +27,9 @@
27
27
  "js-yaml": "^4.1.0",
28
28
  "liquidjs": "^10.21.0",
29
29
  "zod": "^3.24.1",
30
- "@agimon-ai/foundation-process-registry": "0.2.7",
31
- "@agimon-ai/foundation-port-registry": "0.2.11",
32
- "@agimon-ai/log-sink-mcp": "0.2.11"
30
+ "@agimon-ai/foundation-process-registry": "0.2.8",
31
+ "@agimon-ai/log-sink-mcp": "0.2.12",
32
+ "@agimon-ai/foundation-port-registry": "0.2.12"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/express": "^5.0.0",