@yanzhang123/readonly-db-mcp 0.9.8 → 0.9.9
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
|
@@ -72,14 +72,16 @@ npx -y @yanzhang123/readonly-db-mcp@0.9.1
|
|
|
72
72
|
|
|
73
73
|
服务启动后,建议依次调用 `validate_connections` 和 `check_connection`,确认配置有效、网络可达、账号权限符合预期。`check_connection` 只返回不可逆账号指纹和权限分类,不会暴露用户名或原始授权语句。
|
|
74
74
|
|
|
75
|
-
###
|
|
75
|
+
### 从源码安装 Python 包
|
|
76
|
+
|
|
77
|
+
本项目只通过上述 npm 包发布,不发布到 PyPI。PyPI 上名为 `mysql-mcp-server` / `mysql_mcp_server` 的包属于上游原项目,不包含本分支的只读、审计和脱敏实现,请勿用 `pip install mysql-mcp-server` 安装。源码部署时从本仓库安装:
|
|
76
78
|
|
|
77
79
|
```bash
|
|
78
|
-
|
|
80
|
+
git clone https://github.com/12zhangyan/mysql_mcp_server.git
|
|
81
|
+
cd mysql_mcp_server
|
|
82
|
+
pip install ".[http]" # 只用 STDIO 时可省略 [http]
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
Python 包仍适用于源码部署,但本分支的主要分发方式是上述 npm 包。
|
|
82
|
-
|
|
83
85
|
## 配置
|
|
84
86
|
|
|
85
87
|
### 结果脱敏配置
|
|
@@ -98,7 +100,7 @@ mask_columns = [] # 默认全部放开;省略此项效果相同。
|
|
|
98
100
|
|
|
99
101
|
旧单连接模式通过 `MYSQL_MASK_COLUMNS` 配置,以逗号分隔;未设置或设为空字符串均不脱敏。例如 `MYSQL_MASK_COLUMNS=password,access_token` 只按这两个规则处理。使用命名连接文件时,以各连接自己的 `mask_columns` 为准。
|
|
100
102
|
|
|
101
|
-
显式配置会把每个结果列追溯到底层表的字段:别名、表达式、函数与类型转换、窗口函数、标量子查询与关联子查询、派生表、CTE(含列清单)、`UNION`、`LATERAL`、`JSON_TABLE`、`TABLE` 语句和 `*` 都会继续追踪,并对 JSON
|
|
103
|
+
显式配置会把每个结果列追溯到底层表的字段:别名、表达式、函数与类型转换、窗口函数、标量子查询与关联子查询、派生表、CTE(含列清单)、`UNION`、`LATERAL`、`JSON_TABLE`、`TABLE` 语句和 `*` 都会继续追踪,并对 JSON 内匹配的键递归处理。按路径从 JSON 文档读取的值也会检查路径中的键:`JSON_EXTRACT`、`->`、`->>`、`JSON_VALUE` 和 `JSON_TABLE` 列的路径只要经过匹配不带点规则的键(例如 `$.contact.phone` 匹配 `phone`),读出的值就会隐藏;路径含通配符、递归 `**` 或不是常量时按敏感处理。派生表或 CTE 中名称匹配规则的列也视为敏感来源;只有最外层的别名不算。不带点的模式只匹配字段名,例如 `password`;带点的模式按限定路径匹配,例如 `users.phone` 或 `app.users.phone`,表别名会解析回真实表名,未写库名的表按当前库匹配。`COUNT` / `COUNT(DISTINCT ...)` 统计值可以正常读取,同一查询中匹配规则的原始值和拼接值仍会隐藏;`WHERE`、`HAVING`、`EXISTS`、`IN` 子查询里的值不会出现在结果中,不会让其他列被遮蔽。
|
|
102
104
|
|
|
103
105
|
脱敏按 fail-closed 设计:某个结果列的来源无法确定时(例如无法解析的列名、子查询中可能来自外层查询的列,或 MySQL 自动生成、与表达式文本对不上的列名),只要它可能来自匹配规则的字段,就按敏感处理;SQL 分析失败时同样按保守规则处理。因此少数复杂查询可能多遮几列。
|
|
104
106
|
|
package/SECURITY.md
CHANGED
|
@@ -173,6 +173,10 @@ The MCP server includes built-in protection against SQL injection for administra
|
|
|
173
173
|
masking from their inputs, while matching raw values and combined expressions
|
|
174
174
|
remain masked. Values from WHERE, HAVING, EXISTS and IN subqueries never reach
|
|
175
175
|
the result and do not mask other columns.
|
|
176
|
+
- Values read from a JSON document by path (`JSON_EXTRACT`, `->`, `->>`,
|
|
177
|
+
`JSON_VALUE`, JSON_TABLE column paths) are masked when any key on the path
|
|
178
|
+
matches an unqualified pattern, consistent with key masking inside returned JSON
|
|
179
|
+
text. Wildcard, recursive (`**`) and computed paths are treated as sensitive.
|
|
176
180
|
- Masking is designed to fail closed: a result column whose source cannot be
|
|
177
181
|
determined (including unqualified names a subquery may resolve in the outer
|
|
178
182
|
query) is treated as sensitive if it could come from a matching field, and
|
|
Binary file
|
package/package.json
CHANGED