@jadchene/mcp-gateway-service 0.6.3 → 0.6.4

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/README.md CHANGED
@@ -4,7 +4,7 @@ English | [简体中文](./README_zh.md)
4
4
 
5
5
  MCP Gateway is a token-efficient Model Context Protocol gateway. It exposes six stable routing tools instead of flattening every downstream tool into each client's startup context.
6
6
 
7
- MCP Gateway v0.6.3 uses the official TypeScript SDK v2.
7
+ MCP Gateway v0.6.4 uses the official TypeScript SDK v2.
8
8
 
9
9
  > [!IMPORTANT]
10
10
  > MCP Gateway v0.6.2 and later accept only MCP `2026-07-28`, `2025-11-25`, and `2025-06-18`, using standard newline-delimited stdio or single-endpoint Streamable HTTP. Standalone HTTP+SSE (`/sse`), `Content-Length` framing, and other protocol revisions are not supported.
package/README_zh.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  MCP Gateway 是一个节省 token 的 Model Context Protocol 网关。它不把所有下游工具展开到每个客户端的启动上下文,而是通过 6 个稳定工具完成发现、管理和转发。
6
6
 
7
- MCP Gateway v0.6.3 使用官方 TypeScript SDK v2。
7
+ MCP Gateway v0.6.4 使用官方 TypeScript SDK v2。
8
8
 
9
9
  > [!IMPORTANT]
10
10
  > MCP Gateway v0.6.2 及后续版本仅接受 MCP `2026-07-28`、`2025-11-25` 和 `2025-06-18`,传输方式仅支持标准换行分隔 stdio 和单端点 Streamable HTTP。不支持独立 HTTP+SSE(`/sse`)、`Content-Length` framing 和其他协议版本。
@@ -1,5 +1,6 @@
1
1
  import { execFileSync } from "node:child_process";
2
- import { resolve } from "node:path";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
3
4
  import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
4
5
  import { SdkMcpClient } from "./sdk-client.js";
5
6
  /**
@@ -39,11 +40,24 @@ function createStandardTransport(command, args, cwd, env, logger, serviceId) {
39
40
  /**
40
41
  * Resolves a configured command into a directly spawnable executable on Windows.
41
42
  */
42
- function resolveCommandSpec(command, args) {
43
+ export function resolveCommandSpec(command, args) {
43
44
  if (process.platform !== "win32" || /[\\/]/.test(command) || /\.[A-Za-z0-9]+$/.test(command)) {
44
45
  return { command, args };
45
46
  }
46
- const resolved = resolveViaPowerShell(command) ?? resolveViaWhere(command);
47
+ const candidates = resolveViaWhere(command);
48
+ const native = candidates.find((candidate) => /\.(?:com|exe)$/i.test(candidate));
49
+ if (native) {
50
+ return { command: native, args };
51
+ }
52
+ const commandShim = candidates.find((candidate) => candidate.toLowerCase().endsWith(".cmd"));
53
+ const nodeExecutable = resolveViaWhere("node.exe").find((candidate) => candidate.toLowerCase().endsWith("node.exe"));
54
+ if (commandShim && nodeExecutable) {
55
+ const npmLaunch = resolveWindowsNpmShim(commandShim, nodeExecutable, args);
56
+ if (npmLaunch) {
57
+ return npmLaunch;
58
+ }
59
+ }
60
+ const resolved = resolveViaPowerShell(command);
47
61
  if (!resolved) {
48
62
  return { command, args };
49
63
  }
@@ -53,6 +67,29 @@ function resolveCommandSpec(command, args) {
53
67
  }
54
68
  return { command: resolved, args };
55
69
  }
70
+ /**
71
+ * Converts a standard Windows npm command shim into a directly managed Node.js process.
72
+ */
73
+ export function resolveWindowsNpmShim(shimPath, nodeExecutable, args) {
74
+ try {
75
+ const base = dirname(shimPath);
76
+ const content = readFileSync(shimPath, "utf8");
77
+ const matches = Array.from(content.matchAll(/"%dp0%\\([^"\r\n]+\.js)"/gi));
78
+ const relativeScript = matches.at(-1)?.[1];
79
+ if (!relativeScript) {
80
+ return null;
81
+ }
82
+ const script = resolve(base, relativeScript.replace(/\\/g, "/"));
83
+ const relativePath = relative(base, script);
84
+ if (relativePath.startsWith("..") || isAbsolute(relativePath) || !existsSync(script)) {
85
+ return null;
86
+ }
87
+ return { command: nodeExecutable, args: [script, ...args] };
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ }
56
93
  /**
57
94
  * Resolves a command name through PowerShell so script shims map to their real targets.
58
95
  */
@@ -82,10 +119,10 @@ function resolveViaWhere(command) {
82
119
  encoding: "utf8",
83
120
  stdio: ["ignore", "pipe", "ignore"]
84
121
  });
85
- return output.split(/\r?\n/).map((line) => line.trim()).find((line) => line && !line.toLowerCase().endsWith(".ps1")) ?? null;
122
+ return output.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
86
123
  }
87
124
  catch {
88
- return null;
125
+ return [];
89
126
  }
90
127
  }
91
128
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jadchene/mcp-gateway-service",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
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",