@jadchene/mcp-gateway-service 0.2.1 → 0.2.2
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 +8 -14
- package/README_zh.md +8 -14
- package/dist/gateway-server.js +1 -1
- package/dist/mcp/client.js +42 -4
- package/package.json +1 -1
- package/skills/mcp-gateway/SKILL.md +7 -1
package/README.md
CHANGED
|
@@ -38,14 +38,7 @@ That means the model only sees the minimum amount of MCP metadata needed for the
|
|
|
38
38
|
|
|
39
39
|
### 2. Provide one unified MCP entry point for multiple agents
|
|
40
40
|
|
|
41
|
-
Without a gateway, each agent usually needs its own MCP client configuration for
|
|
42
|
-
|
|
43
|
-
- database MCP
|
|
44
|
-
- SSH MCP
|
|
45
|
-
- IDE MCP
|
|
46
|
-
- Playwright MCP
|
|
47
|
-
- Gitea MCP
|
|
48
|
-
- and more
|
|
41
|
+
Without a gateway, each agent usually needs its own MCP client configuration for multiple downstream services.
|
|
49
42
|
|
|
50
43
|
That quickly becomes hard to maintain:
|
|
51
44
|
|
|
@@ -263,12 +256,13 @@ args = ["--config", "./config.json"]
|
|
|
263
256
|
|
|
264
257
|
## Development Notes
|
|
265
258
|
|
|
266
|
-
- Repository-managed `config.json` and `config.example.json` are examples only.
|
|
267
|
-
- Copy `config.example.json` to your own local `config.json` before running the gateway.
|
|
268
|
-
- Keep real local configs and logs outside the repository.
|
|
269
|
-
- Downstream output schema is returned only when the downstream service exposes it.
|
|
270
|
-
- Windows command resolution supports PowerShell shims such as `.ps1`-backed command aliases.
|
|
259
|
+
- Repository-managed `config.json` and `config.example.json` are examples only.
|
|
260
|
+
- Copy `config.example.json` to your own local `config.json` before running the gateway.
|
|
261
|
+
- Keep real local configs and logs outside the repository.
|
|
262
|
+
- Downstream output schema is returned only when the downstream service exposes it.
|
|
263
|
+
- Windows command resolution supports PowerShell shims such as `.ps1`-backed command aliases.
|
|
264
|
+
- On Windows, the gateway prefers `pwsh` for `.ps1` shim resolution and execution, and automatically falls back to `powershell.exe` when `pwsh` is unavailable.
|
|
271
265
|
|
|
272
266
|
## License
|
|
273
267
|
|
|
274
|
-
Released under the [MIT License](./LICENSE).
|
|
268
|
+
Released under the [MIT License](./LICENSE).
|
package/README_zh.md
CHANGED
|
@@ -44,14 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
### 2. 给多个 Agent 提供统一的 MCP 接入入口
|
|
46
46
|
|
|
47
|
-
如果没有网关,每个 Agent
|
|
48
|
-
|
|
49
|
-
- database MCP
|
|
50
|
-
- SSH MCP
|
|
51
|
-
- IDE MCP
|
|
52
|
-
- Playwright MCP
|
|
53
|
-
- Gitea MCP
|
|
54
|
-
- 以及其他服务
|
|
47
|
+
如果没有网关,每个 Agent 往往都要分别配置多个下游 MCP 服务。
|
|
55
48
|
|
|
56
49
|
这种方式很快会带来维护问题:
|
|
57
50
|
|
|
@@ -265,12 +258,13 @@ args = ["--config", "./config.json"]
|
|
|
265
258
|
|
|
266
259
|
## 开发说明
|
|
267
260
|
|
|
268
|
-
- 仓库只保留 `config.example.json` 作为示例
|
|
269
|
-
- 运行前请自行复制一份本地 `config.json`
|
|
270
|
-
- 真实本地配置和日志建议放在仓库外
|
|
271
|
-
- 只有下游服务自己暴露了 `outputSchema` 时,网关才会返回它
|
|
272
|
-
- Windows 下支持解析 PowerShell shim 命令,例如实际落到 `.ps1` 的全局命令
|
|
261
|
+
- 仓库只保留 `config.example.json` 作为示例
|
|
262
|
+
- 运行前请自行复制一份本地 `config.json`
|
|
263
|
+
- 真实本地配置和日志建议放在仓库外
|
|
264
|
+
- 只有下游服务自己暴露了 `outputSchema` 时,网关才会返回它
|
|
265
|
+
- Windows 下支持解析 PowerShell shim 命令,例如实际落到 `.ps1` 的全局命令
|
|
266
|
+
- 在 Windows 上,网关会优先使用 `pwsh` 解析和执行 `.ps1` shim;如果机器上没有 `pwsh`,会自动回退到 `powershell.exe`
|
|
273
267
|
|
|
274
268
|
## License
|
|
275
269
|
|
|
276
|
-
项目采用 [MIT License](./LICENSE) 开源。
|
|
270
|
+
项目采用 [MIT License](./LICENSE) 开源。
|
package/dist/gateway-server.js
CHANGED
package/dist/mcp/client.js
CHANGED
|
@@ -310,7 +310,7 @@ export class StdioMcpClient {
|
|
|
310
310
|
},
|
|
311
311
|
clientInfo: {
|
|
312
312
|
name: "mcp-gateway",
|
|
313
|
-
version: "0.2.
|
|
313
|
+
version: "0.2.2"
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
if (isRecord(result)) {
|
|
@@ -441,8 +441,12 @@ function resolveCommandSpec(command, args) {
|
|
|
441
441
|
const powershellResolved = resolveViaPowerShell(command);
|
|
442
442
|
if (powershellResolved) {
|
|
443
443
|
if (powershellResolved.toLowerCase().endsWith(".ps1")) {
|
|
444
|
+
const powerShellHost = resolvePowerShellHost();
|
|
445
|
+
if (!powerShellHost) {
|
|
446
|
+
return { command, args };
|
|
447
|
+
}
|
|
444
448
|
return {
|
|
445
|
-
command:
|
|
449
|
+
command: powerShellHost,
|
|
446
450
|
args: ["-File", powershellResolved, ...args]
|
|
447
451
|
};
|
|
448
452
|
}
|
|
@@ -465,8 +469,12 @@ function resolveCommandSpec(command, args) {
|
|
|
465
469
|
return { command, args };
|
|
466
470
|
}
|
|
467
471
|
if (preferred.toLowerCase().endsWith(".ps1")) {
|
|
472
|
+
const powerShellHost = resolvePowerShellHost();
|
|
473
|
+
if (!powerShellHost) {
|
|
474
|
+
return { command, args };
|
|
475
|
+
}
|
|
468
476
|
return {
|
|
469
|
-
command:
|
|
477
|
+
command: powerShellHost,
|
|
470
478
|
args: ["-File", preferred, ...args]
|
|
471
479
|
};
|
|
472
480
|
}
|
|
@@ -483,8 +491,12 @@ function resolveCommandSpec(command, args) {
|
|
|
483
491
|
* Resolves a command name through PowerShell so script shims map to their real targets.
|
|
484
492
|
*/
|
|
485
493
|
function resolveViaPowerShell(command) {
|
|
494
|
+
const powerShellHost = resolvePowerShellHost();
|
|
495
|
+
if (!powerShellHost) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
486
498
|
try {
|
|
487
|
-
const output = execFileSync(
|
|
499
|
+
const output = execFileSync(powerShellHost, [
|
|
488
500
|
"-NoProfile",
|
|
489
501
|
"-Command",
|
|
490
502
|
`(Get-Command '${escapePowerShellSingleQuotedString(command)}' -ErrorAction Stop).Source`
|
|
@@ -499,12 +511,38 @@ function resolveViaPowerShell(command) {
|
|
|
499
511
|
return null;
|
|
500
512
|
}
|
|
501
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Resolves the preferred PowerShell host on Windows.
|
|
516
|
+
*/
|
|
517
|
+
export function resolvePowerShellHost(probe = commandExists) {
|
|
518
|
+
if (probe("pwsh")) {
|
|
519
|
+
return "pwsh";
|
|
520
|
+
}
|
|
521
|
+
if (probe("powershell.exe")) {
|
|
522
|
+
return "powershell.exe";
|
|
523
|
+
}
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
502
526
|
/**
|
|
503
527
|
* Escapes a string for use inside a single-quoted PowerShell literal.
|
|
504
528
|
*/
|
|
505
529
|
function escapePowerShellSingleQuotedString(value) {
|
|
506
530
|
return value.replace(/'/g, "''");
|
|
507
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Checks whether a command exists in the current PATH.
|
|
534
|
+
*/
|
|
535
|
+
function commandExists(command) {
|
|
536
|
+
try {
|
|
537
|
+
execFileSync("where.exe", [command], {
|
|
538
|
+
stdio: ["ignore", "ignore", "ignore"]
|
|
539
|
+
});
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
catch {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
508
546
|
/**
|
|
509
547
|
* Terminates one child process, using process-tree shutdown on Windows when possible.
|
|
510
548
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mcp-gateway
|
|
3
|
-
description: Use the MCP gateway for token-efficient discovery of downstream MCP services, tool lists, tool schemas, and forwarded tool calls. Prefer
|
|
3
|
+
description: Use the MCP gateway for token-efficient discovery of downstream MCP services, tool lists, tool schemas, and forwarded tool calls. Prefer the default four-tool workflow and use detailed service inspection only for explicit diagnosis.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# MCP Gateway
|
|
@@ -23,6 +23,12 @@ Operate downstream MCP services through the gateway's fixed, token-efficient dis
|
|
|
23
23
|
4. Call `gateway.callTool(serviceId, toolName, arguments)` for execution.
|
|
24
24
|
5. Re-discover only when a call fails, service availability changes, or the task clearly requires fresh metadata.
|
|
25
25
|
|
|
26
|
+
## Diagnostic Exception
|
|
27
|
+
|
|
28
|
+
- Treat `gateway.getService` as a diagnostic tool, not part of the default workflow.
|
|
29
|
+
- Use it only when the user explicitly asks to inspect service health, connection state, protocol details, or recent service errors.
|
|
30
|
+
- Do not call it during normal task execution when the four-tool flow is sufficient.
|
|
31
|
+
|
|
26
32
|
## Response Shape Expectations
|
|
27
33
|
|
|
28
34
|
- `gateway.listServices` returns compact service entries with `serviceId`, `description`, and `available`.
|