@jadchene/mcp-gateway-service 0.4.3 → 0.5.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_zh.md CHANGED
@@ -1,170 +1,86 @@
1
- [English](./README.md) | 简体中文
2
-
3
- # MCP Gateway
4
-
5
- 这个项目提供了一个轻量的 MCP 网关,用于实现**按需发现、节省 token**,并为多个下游 MCP 服务提供**统一接入入口**。
6
-
7
- 它不会在会话开始时把所有下游 MCP 工具一次性暴露给 AI,而是保持一个固定且很小的网关工具集合,让客户端按需:
8
-
9
- - 先发现可用服务
10
- - 再查看某个服务的工具列表
11
- - 再查询某个工具的 schema
12
- - 最后转发真实工具调用
13
-
14
- ## 为什么要用这个网关
15
-
16
- 这个网关主要解决的是一个很实际的问题:
17
- 当你有多个 MCP 服务、多个 Agent 时,直接让每个 Agent 去分别配置所有 MCP,成本会越来越高。
18
-
19
- 通常会出现两个核心问题:
20
-
21
- 1. 工具太多,token 消耗太高
22
- 2. MCP 配置重复,维护成本太高
23
-
24
- ### 1. 降低 token 消耗
25
-
26
- 很多 MCP 服务本身会暴露几十甚至上百个工具。
27
-
28
- 如果一个 Agent 直接连接多个 MCP,客户端通常需要在会话开始时就把大量 tool 信息暴露给模型,这会带来:
29
-
30
- - prompt 变长
31
- - 工具发现成本变高
32
- - schema 和工具描述反复进入上下文
33
-
34
- 这个网关的做法不是把所有下游工具都直接展开,而是只暴露一个很小的固定发现接口。
35
-
36
- 正常调用流程变成:
37
-
38
- 1. 先查看有哪些服务
39
- 2. 再查看某个服务下有哪些工具
40
- 3. 再查看某个工具的 schema
41
- 4. 最后真正调用这个工具
42
-
43
- 这样模型只会在需要时看到最少量的 MCP 元数据,更适合“按需发现”的使用方式。
44
-
45
- ### 2. 给多个 Agent 提供统一的 MCP 接入入口
46
-
47
- 如果没有网关,每个 Agent 往往都要分别配置多个下游 MCP 服务。
48
-
49
- 这种方式很快会带来维护问题:
50
-
51
- - 下游服务一变,每个 Agent 配置都要改
52
- - 命令路径、环境变量、工作目录会重复出现
53
- - 密钥和本地路径分散在多个客户端配置里
54
- - 不同 Agent 的配置很容易逐渐不一致
55
-
56
- 用了这个网关之后,下游 MCP 服务池只需要在网关配置里维护一次,多个 Agent 只需要连接这一个网关即可。
57
-
58
- 这样带来的好处是:
59
-
60
- - 多个 MCP 统一成一个入口
61
- - 下游服务的增删改集中在一个地方处理
62
- - 更容易控制哪些服务对 Agent 可见
63
- - 减少本地重复配置
64
- - 更方便在 Codex、Claude Code、Gemini CLI 等不同客户端之间复用
65
-
66
- 简单说,这个网关的价值不只是“转发调用”,而是把多个 MCP 统一成一个可管理的服务池,同时把模型看到的工具上下文压缩到最小。
67
-
68
- ## 核心特点
69
-
70
- ### 按需发现,节省 Token
71
- - 对外只暴露少量固定网关工具。
72
- - 只在真正需要时查询服务工具列表和工具 schema。
73
- - 避免把数百个下游 tool 在初始化阶段全部发给模型。
74
-
75
- ### 稳定的网关接口
76
- - 不动态展开所有下游工具。
77
- - 服务列表和工具列表返回精简结构。
78
- - `gateway_call_tool` 直接透传下游工具返回结果,减少额外包装。
79
-
80
- ### 实用运维能力
81
- - 从 JSON 配置文件加载静态服务池。
82
- - 监听配置文件变化并自动热刷新。
83
- - 热刷新时会停掉已删除、已禁用或已被替换配置对应的下游进程。
84
- - 下游进程异常时最多自动重启 3 次。
85
- - 配置刷新失败时保留上一版有效快照。
86
-
87
- ## 快速开始
88
-
89
- ### 全局安装
90
-
91
- ```bash
92
- npm install -g @jadchene/mcp-gateway-service
93
- ```
94
-
95
- 启动网关:
96
-
97
- ```bash
98
- mcp-gateway-service
99
- ```
100
-
101
- 显式指定配置文件:
1
+ [English](./README.md) | 简体中文
2
+
3
+ # MCP Gateway
4
+
5
+ MCP Gateway 是一个轻量级 Model Context Protocol 网关,用一个小型 MCP 入口管理多个下游 MCP 服务。
6
+
7
+ 它不会在客户端启动时把所有下游工具直接展开,而是提供固定的发现和转发 API。Agent 可以先列出服务,再查看某个服务的工具,按需获取单个工具 schema,最后转发真实工具调用。
8
+
9
+ ## 功能
10
+
11
+ - 用一个 MCP 入口接入多个下游 MCP 服务。
12
+ - 通过固定的小型网关工具面实现按需发现,减少初始 token 消耗。
13
+ - 支持 stdio 和 Streamable HTTP 下游传输。
14
+ - 可通过 CLI 参数启用入站 Streamable HTTP。
15
+ - 支持服务池配置热刷新。
16
+ - 热刷新时会停止已删除、已禁用或配置被替换的下游服务。
17
+ - 下游进程失败后最多自动重启 3 次,然后标记为不可用。
18
+ - 配置刷新是原子的,新配置无效时保留上一份有效配置。
19
+ - 支持可选的换行 JSON 文件日志,不把运行日志写入 MCP stdout。
20
+ - 支持通过 `--version` 或 `-v` 查看版本。
21
+
22
+ ## 为什么使用它
23
+
24
+ - 简化 Agent 侧 MCP 配置:每个 Agent 只连接网关,下游服务统一在一个配置文件中管理。
25
+ - 减少初始工具上下文:Agent 只发现当前任务需要的服务、工具和 schema。
26
+ - 集中管理服务生命周期,避免在多个客户端中重复维护命令路径、环境变量和密钥。
27
+
28
+ ## 快速开始
29
+
30
+ 全局安装:
31
+
32
+ ```bash
33
+ npm install -g @jadchene/mcp-gateway-service
34
+ ```
35
+
36
+ 创建本地配置:
37
+
38
+ ```bash
39
+ cp config.example.json config.json
40
+ ```
41
+
42
+ 启动 stdio 网关:
102
43
 
103
44
  ```bash
104
45
  mcp-gateway-service --config ./config.json
105
46
  ```
106
47
 
107
- 通过 CLI 参数同时暴露 Streamable HTTP 接口:
48
+ 启动入站 Streamable HTTP:
49
+
50
+ ```bash
51
+ mcp-gateway-service --config ./config.json --http --host 127.0.0.1 --port 3100 --path /mcp
52
+ ```
53
+
54
+ 如果 HTTP 客户端希望 `POST` 直接返回 JSON-RPC 响应,可启用无状态 JSON 直返:
108
55
 
109
56
  ```bash
110
- mcp-gateway-service --config ./config.json --http --port 3100 --path /mcp
57
+ mcp-gateway-service --config ./config.json --http --port 3100 --path /mcp --json-response
111
58
  ```
112
59
 
113
- 如果 HTTP 客户端希望 `POST` 直接返回 JSON-RPC 响应,可以启用无状态 JSON 直返:
60
+ 查看安装版本:
114
61
 
115
62
  ```bash
116
- mcp-gateway-service --config ./config.json --http --port 3100 --json-response
63
+ mcp-gateway-service --version
64
+ mcp-gateway-service -v
117
65
  ```
118
-
119
- ### 从源码运行
120
-
121
- 先基于 `config.example.json` 自行创建本地 `config.json`,再启动网关:
122
-
123
- ```bash
124
- npm install
125
- npm run dev
126
- ```
127
-
128
- 默认读取 `./config.json`。
129
- 可以通过 `--config <path>` 为当前进程指定配置文件;如果未传 `--config`,则按 `MCP_GATEWAY_CONFIG`,再回退到 `./config.json`。
130
-
131
- 也可以通过环境变量指定:
132
-
133
- ```bash
134
- $env:MCP_GATEWAY_CONFIG="config/gateway/config.json"
135
- npm run dev
136
- ```
137
-
138
- ### 查看版本号
139
-
140
- ```bash
141
- mcp-gateway-service --version
142
- ```
143
-
144
- 短参数:
145
-
146
- ```bash
147
- mcp-gateway-service -v
148
- ```
149
-
150
- ## 配置格式
151
-
152
- 当前支持 `stdio` 和 Streamable HTTP 类型的下游传输。网关自身的入站 Streamable HTTP 只通过 CLI 参数启用,不通过 `config.json` 启用,这样 stdio agent 可以安全共用同一份服务池配置,不会意外启动 HTTP 监听。
153
-
154
- 只有当 `enable` 未填写或显式为 `true` 时,服务才会被加载;如果 `enable` 为 `false`,网关会跳过该服务。热刷新时,如果某个服务被禁用或从配置中删除,网关也会停掉它当前已启动的下游进程。
155
-
156
- - `logging.enable` 可选,默认是 `false`
157
- - 只有当 `logging.enable` 为 `true` 时,`logging.path` 才是必填
158
- - 启用后,网关会把换行分隔的 JSON 日志写入指定文件,不再把运行日志写到 MCP 的 `stdout` 或 `stderr`
159
- - 相对 `logging.path` 会按配置文件所在目录解析
160
- - 日志配置支持热更新,直接修改 `logging.enable` 或 `logging.path` 并保存即可生效,无需重启网关
161
- - `enable` 可选,不填时默认按启用处理
162
- - `cwd` 可选,不填时使用当前工作目录
163
- - `env` 可选
164
- - `framing` 可选,不填时先尝试 `line`,再尝试 `content-length`
165
- - HTTP 下游使用 `transport.type: "http"` 和一个 `transport.url`
166
- - `transport.headers` 可为 HTTP 下游提供静态请求头
167
- - `transport.enableJsonResponse` 可为 HTTP 下游启用无状态 JSON 直返模式
66
+
67
+ ## 配置
68
+
69
+ 通过 CLI 参数指定配置文件:
70
+
71
+ ```bash
72
+ mcp-gateway-service --config ./config.json
73
+ ```
74
+
75
+ 或通过环境变量指定:
76
+
77
+ ```bash
78
+ MCP_GATEWAY_CONFIG=./config.json mcp-gateway-service
79
+ ```
80
+
81
+ 如果两者都没有提供,服务会尝试读取当前工作目录下的 `config.json`。
82
+
83
+ 配置示例:
168
84
 
169
85
  ```json
170
86
  {
@@ -175,15 +91,15 @@ mcp-gateway-service -v
175
91
  "services": [
176
92
  {
177
93
  "serviceId": "demo-echo",
178
- "enable": true,
179
- "name": "Demo Echo Service",
180
- "description": "Sample echo MCP service.",
181
- "transport": {
182
- "type": "stdio",
183
- "command": "node",
184
- "args": [
185
- "--experimental-strip-types",
186
- "examples/echo-service.ts"
94
+ "enable": true,
95
+ "name": "Demo Echo Service",
96
+ "description": "Sample echo MCP service.",
97
+ "transport": {
98
+ "type": "stdio",
99
+ "command": "node",
100
+ "args": [
101
+ "--experimental-strip-types",
102
+ "examples/echo-service.ts"
187
103
  ]
188
104
  }
189
105
  },
@@ -196,7 +112,7 @@ mcp-gateway-service -v
196
112
  "type": "http",
197
113
  "url": "http://127.0.0.1:3200/mcp",
198
114
  "headers": {
199
- "Authorization": "Bearer replace-me"
115
+ "Authorization": "Bearer ${MCP_TOKEN}"
200
116
  },
201
117
  "enableJsonResponse": false
202
118
  }
@@ -205,145 +121,173 @@ mcp-gateway-service -v
205
121
  }
206
122
  ```
207
123
 
208
- ### Streamable HTTP 说明
209
-
210
- - 网关使用同一个 endpoint 处理 `GET` 和 `POST`
211
- - 入站 HTTP 只通过显式 `--http` CLI 参数启用,可搭配 `--port 3100 --path /mcp`
212
- - 只传 `--port`、`--host`、`--path` 或 `--json-response`,但不传 `--http` 时,不会启动 HTTP 监听
213
- - `GET /mcp` 打开 SSE 下行通道,并通过 `Mcp-Session-Id` 响应头返回 session
214
- - `POST /mcp` 发送 JSON-RPC 消息,推荐通过 `Mcp-Session-Id` 请求头绑定 session
215
- - 为兼容旧客户端,仍接受 query string 里的 `sessionId`,但新客户端应优先使用 header
216
- - `endpoint` SSE 事件只返回统一路径,例如 `/mcp`,不会把 session id 塞进 URL
217
-
218
- ## 对外网关工具
219
-
220
- - `gateway_list_services`
221
- - `gateway_get_service`
222
- - `gateway_list_tools`
223
- - `gateway_get_tool_schema`
224
- - `gateway_manage_service`
225
- - `gateway_call_tool`
226
-
227
- ### 返回结构约定
228
-
229
- - `gateway_list_services` 只返回 `serviceId`、`description`、`available`
230
- - `gateway_list_tools` 只返回 `name`、`description`,可传可选参数 `toolName`,支持字符串或字符串数组,按名称片段筛选
231
- - `gateway_get_tool_schema` 只返回 `inputSchema`、`outputSchema`
232
- - `gateway_manage_service` 只返回 `serviceId`、`action`、`enabled`、`available`
233
- - `gateway_call_tool` 直接返回下游 MCP 的结果,不再额外包一层网关元数据
234
-
235
- ### 默认流程与诊断的区别
236
-
237
- - 默认的节省 token 工作流仍然只依赖 4 个工具:`gateway_list_services`、`gateway_list_tools`、`gateway_get_tool_schema`、`gateway_call_tool`
238
- - `gateway_get_service` 主要用于诊断,例如查看最近错误、连接状态、协议版本、下游服务信息
239
- - `gateway_manage_service` 是显式运维控制工具,不属于日常 discovery 流程
240
-
241
- ### `gateway_manage_service`
242
-
243
- 当你明确需要重新拉起某个服务,或者持久化修改某个服务的启用状态时,使用 `gateway_manage_service`。
244
-
245
- 输入参数:
246
-
247
- - `serviceId`:逻辑服务标识
248
- - `action`:只能是 `reconnect`、`enable`、`disable`
249
-
250
- 动作语义:
251
-
252
- - `reconnect`:立即重新尝试启动并重新初始化指定下游 MCP。适合处理“之前因为依赖没准备好而启动失败”的场景,比如当时 IDE 没开,后来打开后再次尝试拉起 IDE MCP。
253
- - `enable`:把该服务在配置文件中的 `enable` 写成 `true`,然后触发 reload。
254
- - `disable`:把该服务在配置文件中的 `enable` 写成 `false`,然后触发 reload。
255
-
256
- 注意:
257
-
258
- - `enable` 和 `disable` 会持久化写入 JSON 配置文件,不是只在当前会话里生效。
259
- - `reconnect` 不会修改配置文件,只会重新尝试当前服务生命周期。
260
-
261
- ## 推荐调用流程
262
-
263
- 为了尽量节省 token,推荐由客户端缓存发现结果,而不是每次都重新调用网关:
264
-
265
- 1. 会话开始时调用一次 `gateway_list_services`
266
- 2. 真正需要某个服务时,再调用 `gateway_list_tools(serviceId)`,工具很多时可传 `toolName` 用一个或多个关键词缩小结果范围
267
- 3. 第一次调用某个工具前,再调用 `gateway_get_tool_schema(serviceId, toolName)`
268
- 4. 执行时调用 `gateway_call_tool(...)`
269
- 5. 只有在明确需要诊断时才调用 `gateway_get_service`
270
- 6. 只有在需要重新拉起服务或显式启用/停用服务时才调用 `gateway_manage_service`
271
- 7. 只有在调用失败、配置变更、或明确需要刷新时才重新发现
272
-
273
- ## Skill 集成(推荐)
274
-
275
- 仓库内包含一个面向公开使用者的 skill:
276
-
277
- - 路径:`skills/mcp-gateway/SKILL.md`
278
-
279
- 主要用于指导代理:
280
-
281
- - 按需发现服务和工具
282
- - 避免无意义地枚举大量 tool
283
- - 通过网关的最小接口完成下游调用
284
-
285
- ## MCP 客户端接入示例
286
-
287
- 下面示例都使用相对路径,方便迁移。
288
-
289
- ### Codex
290
-
291
- `~/.codex/config.toml`
292
-
293
- ```toml
294
- [mcp_servers.gateway]
295
- command = "mcp-gateway-service"
296
- args = ["--config", "./config.json"]
297
- ```
298
-
299
- ### Gemini CLI
300
-
301
- `~/.gemini/settings.json`
302
-
303
- ```json
304
- {
305
- "mcpServers": {
306
- "gateway": {
307
- "type": "stdio",
308
- "command": "mcp-gateway-service",
309
- "args": [
310
- "--config",
311
- "./config.json"
312
- ]
313
- }
314
- }
315
- }
316
- ```
317
-
318
- ### Claude Code
319
-
320
- `~/.claude.json`
321
-
322
- ```json
323
- {
324
- "mcpServers": {
325
- "gateway": {
326
- "type": "stdio",
327
- "command": "mcp-gateway-service",
328
- "args": [
329
- "--config",
330
- "./config.json"
331
- ]
332
- }
333
- }
334
- }
335
- ```
336
-
337
- ## 开发说明
338
-
339
- - 仓库只保留 `config.example.json` 作为示例
340
- - 运行前请自行复制一份本地 `config.json`
341
- - 真实本地配置和日志建议放在仓库外
342
- - 默认关闭文件日志,避免 MCP 启动阶段产生额外标准流输出
343
- - 只有下游服务自己暴露了 `outputSchema` 时,网关才会返回它
344
- - Windows 下支持解析 PowerShell shim 命令,例如实际落到 `.ps1` 的全局命令
345
- - 在 Windows 上,网关会优先使用 `pwsh` 解析和执行 `.ps1` shim;如果机器上没有 `pwsh`,会自动回退到 `powershell.exe`
346
-
347
- ## License
348
-
349
- 项目采用 [MIT License](./LICENSE) 开源。
124
+ 配置说明:
125
+
126
+ - `logging.enable` 默认为 `false`。
127
+ - 只有 `logging.enable` 为 `true` 时,`logging.path` 才必填。
128
+ - 相对 `logging.path` 会按配置文件所在目录解析。
129
+ - 服务 `enable` 默认为 `true`;设为 `false` 时跳过该服务。
130
+ - stdio 服务的 `cwd` 和 `env` 可选。
131
+ - stdio `transport.framing` 可为 `line` 或 `content-length`。不填写时网关先尝试 `line`,再尝试 `content-length`。
132
+ - HTTP 下游服务使用 `transport.type: "http"` 和 `transport.url`。
133
+ - HTTP `transport.headers` 用于提供静态请求头。
134
+ - HTTP `transport.enableJsonResponse` 为该下游服务启用无状态 JSON 直返模式。
135
+
136
+ ## 入站 Streamable HTTP
137
+
138
+ 入站 HTTP 只有传入 `--http` 时才会启用。只传 `--host`、`--port`、`--path` 或 `--json-response`,但不传 `--http`,不会启动 HTTP 监听。
139
+
140
+ HTTP endpoint 使用同一路径处理 `GET` 和 `POST`:
141
+
142
+ - `GET /mcp` 打开 SSE 读取通道,并通过 `Mcp-Session-Id` 响应头返回 session。
143
+ - `POST /mcp` 发送 JSON-RPC 消息。新客户端应通过 `Mcp-Session-Id` 请求头绑定 session。
144
+ - 为兼容旧客户端,仍接受 query string 中的 `sessionId`。
145
+ - `endpoint` SSE 事件只返回统一路径,例如 `/mcp`。
146
+
147
+ ## 网关工具
148
+
149
+ 网关暴露 6 个公开工具:
150
+
151
+ | 工具 | 用途 |
152
+ | --- | --- |
153
+ | `gateway_list_services` | 列出下游服务及其逻辑 `serviceId`、描述和当前可用状态。 |
154
+ | `gateway_get_service` | 返回服务标识、可用状态、最近错误和连接时间、协议版本及服务端信息,主要用于诊断。 |
155
+ | `gateway_list_tools` | 按不区分大小写的字面子串搜索工具名称或描述。可选的唯一非空 `toolName` 和 `desc` 数组使用 OR;`includeSchema: true` 会附带 schema。 |
156
+ | `gateway_get_tool_schema` | 按唯一、准确、区分大小写的工具名返回 schema,并以名称为 key;任一名称未知时整批失败。 |
157
+ | `gateway_manage_service` | 不修改配置地重连服务,或持久化启用/禁用配置并重载注册表。 |
158
+ | `gateway_call_tool` | 调用一个准确的下游工具并原样转发结果;下游工具可能包含读写副作用。 |
159
+
160
+ 默认的节省 token 流程:
161
+
162
+ 1. 调用一次 `gateway_list_services`。
163
+ 2. 真正需要某个服务时,再调用 `gateway_list_tools(serviceId)`。用 `toolName` 数组按名称关键词筛选,或用 `desc` 数组按描述关键词筛选。
164
+ 3. 所有筛选结果都需要 schema 时,传入 `includeSchema: true`;已知准确工具名时,调用 `gateway_get_tool_schema` 并传入非空名称数组。
165
+ 4. 调用 `gateway_call_tool` 执行下游工具。
166
+ 5. 只有诊断时才使用 `gateway_get_service`。
167
+ 6. 只有需要重连、启用或禁用服务时才使用 `gateway_manage_service`。
168
+
169
+ `gateway_get_tool_schema.toolName` 必须是唯一非空字符串数组,返回的 `schemas` 对象以每个准确工具名为 key。只查询一个 schema 时使用单元素数组。
170
+
171
+ `gateway_list_tools.toolName` 和 `gateway_list_tools.desc` 都是可选的唯一非空字符串数组,按字面子串进行不区分大小写的匹配。同时传入时,只要工具名称或描述匹配任一关键词就会返回。描述匹配也可能命中 “when not to use” 等负向说明,因此选择工具前应检查完整描述。
172
+
173
+ 所有具有稳定结构化结果的网关工具都声明了 `outputSchema`。`gateway_call_tool` 会转发任意下游结果,因此不声明固定输出 schema;其 `arguments` 对象始终必填,下游工具无参数时传 `{}`。
174
+
175
+ `gateway_manage_service` 动作:
176
+
177
+ - `reconnect`:不修改配置,只重试当前下游服务生命周期。
178
+ - `enable`:把该服务的 `enable: true` 持久化到配置文件,然后刷新配置。
179
+ - `disable`:把该服务的 `enable: false` 持久化到配置文件,然后刷新配置。
180
+
181
+ ## Skill 集成
182
+
183
+ 仓库内包含一个公开网关 skill:
184
+
185
+ - Skill 路径:`skills/mcp-gateway/SKILL.md`
186
+
187
+ 当你的 Agent 支持 skills 时建议加载它。它会保持按需发现、节省 token,并通过最小网关契约转发下游调用。
188
+
189
+ ## MCP 客户端配置
190
+
191
+ Codex:
192
+
193
+ ```toml
194
+ [mcp_servers.gateway]
195
+ command = "mcp-gateway-service"
196
+ args = ["--config", "./config.json"]
197
+ ```
198
+
199
+ Gemini CLI:
200
+
201
+ ```json
202
+ {
203
+ "mcpServers": {
204
+ "gateway": {
205
+ "type": "stdio",
206
+ "command": "mcp-gateway-service",
207
+ "args": ["--config", "./config.json"]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ Claude Code:
214
+
215
+ ```json
216
+ {
217
+ "mcpServers": {
218
+ "gateway": {
219
+ "type": "stdio",
220
+ "command": "mcp-gateway-service",
221
+ "args": ["--config", "./config.json"]
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ Streamable HTTP 模式:
228
+
229
+ 先启动一个共享 HTTP 网关进程:
230
+
231
+ ```bash
232
+ mcp-gateway-service --config ./config.json --http --host 127.0.0.1 --port 3100 --path /mcp
233
+ ```
234
+
235
+ 然后让 MCP 客户端连接这个 HTTP endpoint。
236
+
237
+ Codex:
238
+
239
+ ```toml
240
+ [mcp_servers.gateway]
241
+ url = "http://127.0.0.1:3100/mcp"
242
+ ```
243
+
244
+ Gemini CLI:
245
+
246
+ ```json
247
+ {
248
+ "mcpServers": {
249
+ "gateway": {
250
+ "httpUrl": "http://127.0.0.1:3100/mcp"
251
+ }
252
+ }
253
+ }
254
+ ```
255
+
256
+ Claude Code:
257
+
258
+ ```json
259
+ {
260
+ "mcpServers": {
261
+ "gateway": {
262
+ "type": "http",
263
+ "url": "http://127.0.0.1:3100/mcp"
264
+ }
265
+ }
266
+ }
267
+ ```
268
+
269
+ 需要共享同一个网关服务池的客户端都使用同一个 URL。只有当 HTTP 客户端希望 `POST` 直接返回无状态 JSON-RPC 响应时,才需要在启动网关时加 `--json-response`。
270
+
271
+ ## 开发
272
+
273
+ ```bash
274
+ npm install
275
+ npm run dev
276
+ ```
277
+
278
+ 构建和测试:
279
+
280
+ ```bash
281
+ npm run build
282
+ npm test
283
+ ```
284
+
285
+ 运行构建后的服务:
286
+
287
+ ```bash
288
+ node dist/index.js --config ./config.json
289
+ ```
290
+
291
+ ## License
292
+
293
+ MIT. See [LICENSE](LICENSE).
@@ -27,7 +27,7 @@
27
27
  "type": "http",
28
28
  "url": "http://127.0.0.1:3200/mcp",
29
29
  "headers": {
30
- "Authorization": "Bearer replace-me"
30
+ "Authorization": "Bearer example-token"
31
31
  },
32
32
  "enableJsonResponse": false
33
33
  }