@jadchene/mcp-gateway-service 0.2.0 → 0.2.1

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.
@@ -187,7 +187,7 @@ export class GatewayServer {
187
187
  },
188
188
  serverInfo: {
189
189
  name: "mcp-gateway",
190
- version: "0.2.0"
190
+ version: "0.2.1"
191
191
  }
192
192
  };
193
193
  }
package/dist/index.js CHANGED
@@ -33,6 +33,10 @@ class Application {
33
33
  watcher = new ConfigFileWatcher(this.configPath, this.logger, async () => {
34
34
  await this.registry.reload();
35
35
  });
36
+ /**
37
+ * Prevents duplicate shutdown execution when multiple exit signals arrive.
38
+ */
39
+ shuttingDown = false;
36
40
  /**
37
41
  * Starts the application and registers shutdown hooks.
38
42
  */
@@ -55,6 +59,10 @@ class Application {
55
59
  */
56
60
  registerSignals() {
57
61
  const shutdown = async (signal) => {
62
+ if (this.shuttingDown) {
63
+ return;
64
+ }
65
+ this.shuttingDown = true;
58
66
  this.logger.info("gateway.stopping", { signal });
59
67
  this.watcher.stop();
60
68
  await this.registry.dispose();
@@ -62,6 +70,8 @@ class Application {
62
70
  };
63
71
  process.on("SIGINT", () => void shutdown("SIGINT"));
64
72
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
73
+ process.stdin.on("end", () => void shutdown("stdin-end"));
74
+ process.stdin.on("close", () => void shutdown("stdin-close"));
65
75
  }
66
76
  }
67
77
  const application = new Application();
@@ -295,14 +295,7 @@ export class StdioMcpClient {
295
295
  const child = this.child;
296
296
  this.child = null;
297
297
  this.writer = null;
298
- try {
299
- child.kill();
300
- }
301
- catch {
302
- /**
303
- * Ignores kill failures because the process may have already exited.
304
- */
305
- }
298
+ terminateChildProcess(child);
306
299
  await waitForChildExit(child);
307
300
  cleanupChildProcess(child);
308
301
  }
@@ -317,7 +310,7 @@ export class StdioMcpClient {
317
310
  },
318
311
  clientInfo: {
319
312
  name: "mcp-gateway",
320
- version: "0.2.0"
313
+ version: "0.2.1"
321
314
  }
322
315
  });
323
316
  if (isRecord(result)) {
@@ -512,6 +505,32 @@ function resolveViaPowerShell(command) {
512
505
  function escapePowerShellSingleQuotedString(value) {
513
506
  return value.replace(/'/g, "''");
514
507
  }
508
+ /**
509
+ * Terminates one child process, using process-tree shutdown on Windows when possible.
510
+ */
511
+ function terminateChildProcess(child) {
512
+ if (process.platform === "win32" && child.pid) {
513
+ try {
514
+ execFileSync("taskkill.exe", ["/PID", String(child.pid), "/T", "/F"], {
515
+ stdio: ["ignore", "ignore", "ignore"]
516
+ });
517
+ return;
518
+ }
519
+ catch {
520
+ /**
521
+ * Falls back to normal child termination when taskkill fails.
522
+ */
523
+ }
524
+ }
525
+ try {
526
+ child.kill();
527
+ }
528
+ catch {
529
+ /**
530
+ * Ignores kill failures because the process may have already exited.
531
+ */
532
+ }
533
+ }
515
534
  /**
516
535
  * Waits for one child process to exit and force-kills it if graceful shutdown stalls.
517
536
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jadchene/mcp-gateway-service",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A token-efficient MCP gateway that provides one unified entry point for multiple downstream MCP services.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -100,10 +100,10 @@ $example = @{
100
100
  mcpServers = @{
101
101
  gateway = @{
102
102
  command = "mcp-gateway-service"
103
- args = @()
104
- env = @{
105
- MCP_GATEWAY_CONFIG = $resolvedConfigPath
106
- }
103
+ args = @(
104
+ "--config",
105
+ $resolvedConfigPath
106
+ )
107
107
  }
108
108
  }
109
109
  } | ConvertTo-Json -Depth 6