@yanzhang123/readonly-db-mcp 0.8.1 → 0.8.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.
@@ -171,7 +171,31 @@ files.
171
171
  For strong human identity, an authenticated gateway must bind its verified
172
172
  principal to the MCP request and protect access to the MCP endpoint.
173
173
 
174
- ## SSE Deployment
174
+ ## Streamable HTTP Deployment
175
+
176
+ New remote MCP clients, including DeepSeek Harness, should use the standard
177
+ Streamable HTTP endpoint:
178
+
179
+ ```dotenv
180
+ MCP_TRANSPORT=streamable-http
181
+ MCP_HTTP_HOST=127.0.0.1
182
+ MCP_HTTP_PORT=8000
183
+ MCP_HTTP_PATH=/mcp
184
+ MCP_HTTP_SESSION_IDLE_TIMEOUT_SECONDS=1800
185
+ ```
186
+
187
+ For built-in bearer authentication:
188
+
189
+ ```dotenv
190
+ MCP_HTTP_BEARER_TOKEN=<secret-manager-value-of-at-least-32-characters>
191
+ ```
192
+
193
+ The token protects `/mcp`; `/` remains a non-sensitive health endpoint. Keep
194
+ the service on loopback behind an authenticated reverse proxy. A container
195
+ that must bind `0.0.0.0` may set `MCP_HTTP_TRUST_PROXY_AUTH=true` only when
196
+ network policy prevents direct access to the container port.
197
+
198
+ ## Legacy SSE Deployment
175
199
 
176
200
  The safe default is:
177
201
 
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  本分支推荐通过 npm 包 [`@yanzhang123/readonly-db-mcp`](https://www.npmjs.com/package/@yanzhang123/readonly-db-mcp) 使用。npm 包内置匹配版本的 Python wheel 和跨平台启动器,MCP 客户端无需检出仓库或单独安装 Python 包。
10
10
 
11
11
  > [!NOTE]
12
- > 服务同时支持标准输入输出(STDIO)和 Streamable HTTP(SSE)传输。远程或自托管场景可使用 SSE,并应按本文配置认证和网络边界。
12
+ > 服务支持标准输入输出(STDIO)、标准 Streamable HTTP 和旧版 SSE 传输。远程或自托管场景推荐使用 Streamable HTTP,并应按本文配置认证和网络边界。
13
13
 
14
14
  > [!IMPORTANT]
15
15
  > 只读约束不依赖 MySQL 账号权限。即使账号拥有 `INSERT`、`UPDATE`、`DELETE` 或 DDL 权限,SQL 闸门也只接受经过审查的只读语句,并在只读事务中执行后统一回滚。生产环境仍强烈建议使用仅授予 `SELECT` 的数据库账号,形成独立的纵深防御。
@@ -24,7 +24,7 @@
24
24
  - 查询分页下推到 MySQL,避免客户端截断结果引发 Connector/Python `errno=-1`
25
25
  - 内置结果行数和单元格长度限制,最大返回 1000 行
26
26
  - 按源字段精确脱敏,支持别名、CTE 以及 JSON 内敏感键
27
- - 支持 SSL/TLS、SSH 隧道和 SSE/HTTP 传输
27
+ - 支持 SSL/TLS、SSH 隧道、Streamable HTTP 和旧版 SSE 传输
28
28
  - 密码可保存在环境变量、操作系统凭据库或受控的密钥命令中
29
29
  - 保留旧版单连接 `MYSQL_*` 环境变量和 `query` 工具别名
30
30
 
@@ -43,7 +43,7 @@ npx -y @yanzhang123/readonly-db-mcp
43
43
  生产环境建议固定经过审核的版本:
44
44
 
45
45
  ```bash
46
- npx -y @yanzhang123/readonly-db-mcp@0.8.1
46
+ npx -y @yanzhang123/readonly-db-mcp@0.8.2
47
47
  ```
48
48
 
49
49
  首次运行时,启动器会在用户缓存目录创建版本化虚拟环境,并安装包内 wheel 与带 SHA-256 锁定的 Python 依赖。完成后的环境按 wheel 和依赖锁指纹复用。可通过 `MYSQL_MCP_PYTHON` 指定 Python,通过 `MYSQL_MCP_NPM_CACHE_DIR` 修改缓存位置。
@@ -57,7 +57,7 @@ npx -y @yanzhang123/readonly-db-mcp@0.8.1
57
57
  "mcpServers": {
58
58
  "mysql-readonly": {
59
59
  "command": "npx",
60
- "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.1"],
60
+ "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.2"],
61
61
  "env": {
62
62
  "MYSQL_PROFILES_FILE": "C:/absolute/path/mysql-connections.toml",
63
63
  "MYSQL_DEV_PASSWORD": "由客户端密钥存储提供"
@@ -232,10 +232,28 @@ MYSQL_USE_PURE=false
232
232
  MYSQL_RAISE_ON_WARNINGS=false
233
233
  ```
234
234
 
235
- ### SSE 传输
235
+ ### Streamable HTTP 传输(推荐)
236
+
237
+ DeepSeek Harness 等新客户端可直接连接标准 MCP Streamable HTTP 端点:
238
+
239
+ ```bash
240
+ MCP_TRANSPORT=streamable-http
241
+ MCP_HTTP_HOST=127.0.0.1
242
+ MCP_HTTP_PORT=8000
243
+ MCP_HTTP_PATH=/mcp
244
+ MCP_HTTP_ALLOWED_HOSTS=localhost:8000,127.0.0.1:8000
245
+ MCP_HTTP_BEARER_TOKEN= # 可选,至少 32 个字符
246
+ MCP_HTTP_TRUST_PROXY_AUTH=false # 仅在认证反向代理是唯一入口时启用
247
+ MCP_HTTP_SESSION_IDLE_TIMEOUT_SECONDS=1800
248
+ ```
249
+
250
+ 默认端点是 `http://127.0.0.1:8000/mcp`。非回环地址只有在启用 Bearer
251
+ 认证,或显式确认由认证反向代理保护时才允许启动。
252
+
253
+ ### 旧版 SSE 传输
236
254
 
237
255
  ```bash
238
- MCP_TRANSPORT=stdio # stdio 或 sse
256
+ MCP_TRANSPORT=sse
239
257
  MCP_SSE_HOST=127.0.0.1 # 默认仅监听回环地址
240
258
  PORT=8000 # MCP_SSE_PORT 的后备值
241
259
  MCP_SSE_ALLOWED_HOSTS= # 允许的 Host,逗号分隔
@@ -243,7 +261,8 @@ MCP_SSE_BEARER_TOKEN= # 可选,至少 32 个字符
243
261
  MCP_SSE_TRUST_PROXY_AUTH=false # 仅在认证反向代理是唯一入口时启用
244
262
  ```
245
263
 
246
- 非回环地址只有在启用 Bearer 认证,或显式确认由认证反向代理保护时才允许启动。部署细节见 [`ENTERPRISE_DEPLOYMENT.md`](ENTERPRISE_DEPLOYMENT.md)。
264
+ 旧版端点为 `/sse` 和 `/messages/`,仅用于兼容现有客户端。部署细节见
265
+ [`ENTERPRISE_DEPLOYMENT.md`](ENTERPRISE_DEPLOYMENT.md)。
247
266
 
248
267
  ### SSH 隧道
249
268
 
@@ -367,7 +386,7 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
367
386
  "mcpServers": {
368
387
  "mysql-readonly": {
369
388
  "command": "npx",
370
- "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.1"],
389
+ "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.2"],
371
390
  "env": {
372
391
  "MYSQL_PROFILES_FILE": "C:/absolute/path/mysql-connections.toml",
373
392
  "MYSQL_DEV_PASSWORD": "your_dev_password"
@@ -387,7 +406,7 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
387
406
  "mysql-readonly": {
388
407
  "type": "stdio",
389
408
  "command": "npx",
390
- "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.1"],
409
+ "args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.2"],
391
410
  "env": {
392
411
  "MYSQL_PROFILES_FILE": "C:/absolute/path/mysql-connections.toml",
393
412
  "MYSQL_DEV_PASSWORD": "your_dev_password"
@@ -399,6 +418,44 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
399
418
 
400
419
  Windows 宿主如无法解析 `npx`,改用 `npx.cmd`。更多调用场景见 [`MCP_USECASES.md`](MCP_USECASES.md)。
401
420
 
421
+ ### DeepSeek Harness
422
+
423
+ Harness 自带 `@deepseek-ai/dsh-mcp-client`。本地使用推荐挂载 npm 包的
424
+ STDIO 入口;在 Windows 上使用 `npx.cmd`:
425
+
426
+ ```yaml
427
+ - insert:
428
+ - id: mcp-mysql-readonly
429
+ name: '@deepseek-ai/dsh-mcp-client'
430
+ config:
431
+ serverName: mysql-readonly
432
+ transport: stdio
433
+ command: npx.cmd
434
+ args: ['-y', '@yanzhang123/readonly-db-mcp@0.8.2']
435
+ env:
436
+ MYSQL_PROFILES_FILE: 'C:/absolute/path/mysql-connections.toml'
437
+ toolCallTimeoutMs: 60000
438
+ failOnStartupError: true
439
+ ```
440
+
441
+ 远程或集中部署时使用 Streamable HTTP。先按上文启动服务,然后在 Harness
442
+ 配置中挂载端点;`MYSQL_MCP_AUTHORIZATION` 的值应为 `Bearer <token>`,并
443
+ 从进程环境或密钥管理系统注入,不要提交到仓库:
444
+
445
+ ```yaml
446
+ - insert:
447
+ - id: mcp-mysql-readonly
448
+ name: '@deepseek-ai/dsh-mcp-client'
449
+ config:
450
+ serverName: mysql-readonly
451
+ transport: streamable-http
452
+ url: 'https://mcp.example.com/mcp'
453
+ headers:
454
+ Authorization: !!js process.env.MYSQL_MCP_AUTHORIZATION
455
+ toolCallTimeoutMs: 60000
456
+ failOnStartupError: true
457
+ ```
458
+
402
459
  ## 开发与测试
403
460
 
404
461
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanzhang123/readonly-db-mcp",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Enterprise-auditable, strictly read-only MySQL MCP server with multi-environment profiles.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",