db_execute
Executes permission-gated write SQL (INSERT, UPDATE, DELETE, limited DDL) with dry-run rollback by default, row-limit guardrails, and audit logging; send confirm to commit.
Instructions
【写操作,分级授权】只读→DML(allowWrite)→DDL(allowDdl)→破坏性(allowDestructive),默认全关;DML: insert/update/delete/merge/replace(UPDATE/DELETE 必须带 WHERE);DDL: create table|index、alter table add|modify、comment on、drop index;破坏性: drop table/truncate/drop column(需 allowDestructive);grant/revoke/call/exec 永远禁止;DML 不传 confirm 时「执行后回滚」报影响行数;DDL 因隐式提交不可回滚,预演只做静态校验不执行;传 confirm="YES" 才真正执行;DML 超 maxAffected(默认 1000)自动回滚;每次写都记审计。必须给 reason。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>",
"reason": "<reason>"
},
"name": "db_execute"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | 单条写语句(禁 DDL、禁多语句) | |
| reason | Yes | 为什么要改(≥6 字,写入审计日志) | |
| confirm | No | 预演不传;确认提交传 "YES" | |
| connection | No | 连接名(必须在该连接 json 里设 allowWrite: true) | |
| maxAffected | No | 允许影响的最大行数,默认 1000(超出自动回滚) |