@yanzhang123/readonly-db-mcp 0.8.1 → 0.8.3
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/ENTERPRISE_DEPLOYMENT.md
CHANGED
|
@@ -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
|
-
##
|
|
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
|
-
>
|
|
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
|
|
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.
|
|
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.
|
|
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,32 @@ MYSQL_USE_PURE=false
|
|
|
232
232
|
MYSQL_RAISE_ON_WARNINGS=false
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
-
###
|
|
235
|
+
### Streamable HTTP 传输(推荐)
|
|
236
|
+
|
|
237
|
+
DeepSeek Harness 等新客户端可直接连接标准 MCP Streamable HTTP 端点:
|
|
236
238
|
|
|
237
239
|
```bash
|
|
238
|
-
MCP_TRANSPORT=
|
|
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
|
+
`MCP_TRANSPORT` 支持 `stdio`、`sse`、`streamable-http`(及别名 `http`);
|
|
251
|
+
未知值会在启动时直接报错,避免配置拼写错误被静默降级为 STDIO。
|
|
252
|
+
HTTP/SSE 端口必须在 `1-65535` 范围内;会话空闲超时必须为正有限数。
|
|
253
|
+
|
|
254
|
+
默认端点是 `http://127.0.0.1:8000/mcp`。非回环地址只有在启用 Bearer
|
|
255
|
+
认证,或显式确认由认证反向代理保护时才允许启动。
|
|
256
|
+
|
|
257
|
+
### 旧版 SSE 传输
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
MCP_TRANSPORT=sse
|
|
239
261
|
MCP_SSE_HOST=127.0.0.1 # 默认仅监听回环地址
|
|
240
262
|
PORT=8000 # MCP_SSE_PORT 的后备值
|
|
241
263
|
MCP_SSE_ALLOWED_HOSTS= # 允许的 Host,逗号分隔
|
|
@@ -243,7 +265,8 @@ MCP_SSE_BEARER_TOKEN= # 可选,至少 32 个字符
|
|
|
243
265
|
MCP_SSE_TRUST_PROXY_AUTH=false # 仅在认证反向代理是唯一入口时启用
|
|
244
266
|
```
|
|
245
267
|
|
|
246
|
-
|
|
268
|
+
旧版端点为 `/sse` 和 `/messages/`,仅用于兼容现有客户端。部署细节见
|
|
269
|
+
[`ENTERPRISE_DEPLOYMENT.md`](ENTERPRISE_DEPLOYMENT.md)。
|
|
247
270
|
|
|
248
271
|
### SSH 隧道
|
|
249
272
|
|
|
@@ -367,7 +390,7 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
|
|
|
367
390
|
"mcpServers": {
|
|
368
391
|
"mysql-readonly": {
|
|
369
392
|
"command": "npx",
|
|
370
|
-
"args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.
|
|
393
|
+
"args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.2"],
|
|
371
394
|
"env": {
|
|
372
395
|
"MYSQL_PROFILES_FILE": "C:/absolute/path/mysql-connections.toml",
|
|
373
396
|
"MYSQL_DEV_PASSWORD": "your_dev_password"
|
|
@@ -387,7 +410,7 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
|
|
|
387
410
|
"mysql-readonly": {
|
|
388
411
|
"type": "stdio",
|
|
389
412
|
"command": "npx",
|
|
390
|
-
"args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.
|
|
413
|
+
"args": ["-y", "@yanzhang123/readonly-db-mcp@0.8.2"],
|
|
391
414
|
"env": {
|
|
392
415
|
"MYSQL_PROFILES_FILE": "C:/absolute/path/mysql-connections.toml",
|
|
393
416
|
"MYSQL_DEV_PASSWORD": "your_dev_password"
|
|
@@ -399,6 +422,44 @@ Claude Desktop、Codex 等宿主通常从自己的目录启动 MCP 服务,未
|
|
|
399
422
|
|
|
400
423
|
Windows 宿主如无法解析 `npx`,改用 `npx.cmd`。更多调用场景见 [`MCP_USECASES.md`](MCP_USECASES.md)。
|
|
401
424
|
|
|
425
|
+
### DeepSeek Harness
|
|
426
|
+
|
|
427
|
+
Harness 自带 `@deepseek-ai/dsh-mcp-client`。本地使用推荐挂载 npm 包的
|
|
428
|
+
STDIO 入口;在 Windows 上使用 `npx.cmd`:
|
|
429
|
+
|
|
430
|
+
```yaml
|
|
431
|
+
- insert:
|
|
432
|
+
- id: mcp-mysql-readonly
|
|
433
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
434
|
+
config:
|
|
435
|
+
serverName: mysql-readonly
|
|
436
|
+
transport: stdio
|
|
437
|
+
command: npx.cmd
|
|
438
|
+
args: ['-y', '@yanzhang123/readonly-db-mcp@0.8.2']
|
|
439
|
+
env:
|
|
440
|
+
MYSQL_PROFILES_FILE: 'C:/absolute/path/mysql-connections.toml'
|
|
441
|
+
toolCallTimeoutMs: 60000
|
|
442
|
+
failOnStartupError: true
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
远程或集中部署时使用 Streamable HTTP。先按上文启动服务,然后在 Harness
|
|
446
|
+
配置中挂载端点;`MYSQL_MCP_AUTHORIZATION` 的值应为 `Bearer <token>`,并
|
|
447
|
+
从进程环境或密钥管理系统注入,不要提交到仓库:
|
|
448
|
+
|
|
449
|
+
```yaml
|
|
450
|
+
- insert:
|
|
451
|
+
- id: mcp-mysql-readonly
|
|
452
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
453
|
+
config:
|
|
454
|
+
serverName: mysql-readonly
|
|
455
|
+
transport: streamable-http
|
|
456
|
+
url: 'https://mcp.example.com/mcp'
|
|
457
|
+
headers:
|
|
458
|
+
Authorization: !!js process.env.MYSQL_MCP_AUTHORIZATION
|
|
459
|
+
toolCallTimeoutMs: 60000
|
|
460
|
+
failOnStartupError: true
|
|
461
|
+
```
|
|
462
|
+
|
|
402
463
|
## 开发与测试
|
|
403
464
|
|
|
404
465
|
```bash
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|