@jadchene/mcp-gateway-service 0.9.0 → 0.10.0

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
@@ -168,14 +168,16 @@ The config file is watched for changes. Invalid updates are rejected and the las
168
168
 
169
169
  | Tool | Description |
170
170
  | --- | --- |
171
- | `gateway_list_services` | Lists configured services and their availability. |
171
+ | `gateway_list_services` | Searches configured services by identifier or description and can filter by availability. |
172
172
  | `gateway_get_service` | Shows one service's connection state, protocol revision, server identity, and recent error. |
173
173
  | `gateway_list_tools` | Searches a service's tools by name or description and can include schemas. |
174
174
  | `gateway_get_tool_schema` | Returns schemas for exact tool names. |
175
175
  | `gateway_manage_service` | Reconnects a service or enables/disables it in the config file. |
176
176
  | `gateway_call_tool` | Calls one downstream tool and returns its MCP result. |
177
177
 
178
- The usual flow is `gateway_list_services` → `gateway_list_tools` → `gateway_get_tool_schema` when needed → `gateway_call_tool`. Pass `{}` to `gateway_call_tool` when the downstream tool has no arguments.
178
+ The usual flow is `gateway_list_services` → `gateway_list_tools` → `gateway_get_tool_schema` when needed → `gateway_call_tool`. Pass `{}` to `gateway_call_tool` when the downstream tool has no arguments.
179
+
180
+ `gateway_list_services` accepts optional `serviceId` and `desc` string arrays as case-insensitive substring filters. Matches across these two fields use OR. The optional `available` boolean further limits those matches by current availability.
179
181
 
180
182
  Calls keep the downstream tool's original side effects and confirmation rules. Tools matching `confirmationRequiredTools` are never invoked until the current MCP session reviews the exact service, tool, and arguments and answers `yes` to the form elicitation; sessions without form elicitation support receive an error. A `no`, decline, or cancel returns an explicit rejection without invoking the downstream tool. An uncertain `gateway_call_tool` failure is never replayed automatically. Enabling or disabling a service with `gateway_manage_service` atomically updates the config file.
181
183
 
package/README_zh.md CHANGED
@@ -168,14 +168,16 @@ claude mcp add --transport http gateway http://127.0.0.1:3000/mcp
168
168
 
169
169
  | 工具 | 说明 |
170
170
  | --- | --- |
171
- | `gateway_list_services` | 列出已配置的服务及其可用状态。 |
171
+ | `gateway_list_services` | 按服务标识或描述搜索已配置服务,并可按可用状态筛选。 |
172
172
  | `gateway_get_service` | 查看服务连接状态、协议版本、服务端信息和最近一次错误。 |
173
173
  | `gateway_list_tools` | 按名称或描述搜索服务中的工具,可同时返回 schema。 |
174
174
  | `gateway_get_tool_schema` | 获取准确工具名称对应的 schema。 |
175
175
  | `gateway_manage_service` | 重连服务,或在配置文件中启用、禁用服务。 |
176
176
  | `gateway_call_tool` | 调用一个下游工具并返回 MCP 结果。 |
177
177
 
178
- 通常按 `gateway_list_services` → `gateway_list_tools` → 按需调用 `gateway_get_tool_schema` → `gateway_call_tool` 的顺序使用。下游工具没有参数时,`gateway_call_tool` 的 `arguments` 传 `{}`。
178
+ 通常按 `gateway_list_services` → `gateway_list_tools` → 按需调用 `gateway_get_tool_schema` → `gateway_call_tool` 的顺序使用。下游工具没有参数时,`gateway_call_tool` 的 `arguments` 传 `{}`。
179
+
180
+ `gateway_list_services` 可选传入 `serviceId`、`desc` 字符串数组,按不区分大小写的子串匹配,两类文本条件之间为 OR;还可传入 `available` 布尔值,在文本匹配结果上继续按当前可用状态筛选。
179
181
 
180
182
  工具调用会保留下游工具原有的副作用和确认规则。匹配 `confirmationRequiredTools` 模式的工具会展示实际服务、工具和完整参数,只有当前 MCP 会话在表单 elicitation 中选择 `yes` 后才会调用;会话不支持表单 elicitation,或用户选择 `no`、拒绝、取消时,网关会返回明确的拒绝结果且不会调用下游工具。状态不确定的 `gateway_call_tool` 失败不会自动重放。通过 `gateway_manage_service` 启用或禁用服务会原子更新配置文件。
181
183
 
@@ -35,9 +35,7 @@ export class McpGatewayEngine {
35
35
  await this.startupBarrier;
36
36
  switch (toolName) {
37
37
  case "gateway_list_services":
38
- return successContent({
39
- services: this.registry.listServices().map(formatServiceSummary)
40
- });
38
+ return this.listServices(args);
41
39
  case "gateway_get_service":
42
40
  return this.getService(args);
43
41
  case "gateway_list_tools":
@@ -52,6 +50,26 @@ export class McpGatewayEngine {
52
50
  throw new Error(`Unknown gateway tool '${toolName}'.`);
53
51
  }
54
52
  }
53
+ /**
54
+ * Returns service summaries optionally matching identifiers, descriptions, and availability.
55
+ */
56
+ listServices(args) {
57
+ const serviceId = optionalUniqueNonEmptyStringArray(args.serviceId, "The 'serviceId' argument must be a unique non-empty string array when provided.");
58
+ const desc = optionalUniqueNonEmptyStringArray(args.desc, "The 'desc' argument must be a unique non-empty string array when provided.");
59
+ const available = optionalBoolean(args.available, "The 'available' argument must be a boolean when provided.");
60
+ const serviceIdKeywords = normalizeKeywords(serviceId);
61
+ const descriptionKeywords = normalizeKeywords(desc);
62
+ const services = this.registry.listServices().filter((snapshot) => {
63
+ const matchesText = serviceIdKeywords.length === 0 && descriptionKeywords.length === 0
64
+ || serviceIdKeywords.some((keyword) => snapshot.config.serviceId.toLowerCase().includes(keyword))
65
+ || descriptionKeywords.some((keyword) => (snapshot.config.description ?? "").toLowerCase().includes(keyword));
66
+ const matchesAvailability = available === undefined || snapshot.runtime.available === available;
67
+ return matchesText && matchesAvailability;
68
+ });
69
+ return successContent({
70
+ services: services.map(formatServiceSummary)
71
+ });
72
+ }
55
73
  /**
56
74
  * Returns detailed metadata for one logical service.
57
75
  */
@@ -156,12 +174,15 @@ export function buildGatewayTools(options = {}) {
156
174
  const tools = [
157
175
  {
158
176
  name: "gateway_list_services",
159
- description: "Lists downstream MCP services with their logical identifiers, descriptions, and current availability.",
160
- inputSchema: {
161
- type: "object",
162
- properties: {},
163
- additionalProperties: false
164
- },
177
+ description: "Lists downstream MCP services by case-insensitive identifier or description substring filters and optional availability.",
178
+ inputSchema: objectSchema([], {
179
+ serviceId: uniqueNonEmptyStringArraySchema("Optional unique service identifier substrings. Matching is case-insensitive; identifier and description filters use OR."),
180
+ desc: uniqueNonEmptyStringArraySchema("Optional unique description substrings. Matching is case-insensitive; identifier and description filters use OR."),
181
+ available: {
182
+ type: "boolean",
183
+ description: "Optionally limits results to services with the requested current availability."
184
+ }
185
+ }),
165
186
  outputSchema: outputSchemas.listServices
166
187
  },
167
188
  {
@@ -419,6 +440,12 @@ function optionalBoolean(input, message) {
419
440
  }
420
441
  return input;
421
442
  }
443
+ /**
444
+ * Normalizes optional substring filters for case-insensitive matching.
445
+ */
446
+ function normalizeKeywords(input) {
447
+ return (input ?? []).map((value) => value.trim().toLowerCase());
448
+ }
422
449
  /**
423
450
  * Ensures the service management action is supported.
424
451
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jadchene/mcp-gateway-service",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
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",
@@ -9,7 +9,7 @@ Use the gateway as the single entry point for downstream MCP services.
9
9
 
10
10
  ## Workflow
11
11
 
12
- 1. Reuse an exact `serviceId` already confirmed in the current session; otherwise call `gateway_list_services`.
12
+ 1. Reuse an exact `serviceId` already confirmed in the current session; otherwise call `gateway_list_services`.
13
13
  2. Reuse an exact downstream tool name already confirmed in the session; otherwise search only that service with `gateway_list_tools`. The unique non-empty `toolName` and `desc` filters are case-insensitive literal substrings joined by OR, so inspect description matches for negative guidance.
14
14
  3. Obtain unfamiliar or safety-sensitive schemas with `includeSchema: true` or `gateway_get_tool_schema`; tool names are exact and case-sensitive.
15
15
  4. Call `gateway_call_tool` with the confirmed identifiers and an explicit `arguments` object; pass `{}` when the tool has no arguments.