Skip to main content
Glama
jdbc-mcp-guard

jdbc-mcp-guard

by lyb-java

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

NameRequiredDescriptionDefault
sqlYes单条写语句(禁 DDL、禁多语句)
reasonYes为什么要改(≥6 字,写入审计日志)
confirmNo预演不传;确认提交传 "YES"
connectionNo连接名(必须在该连接 json 里设 allowWrite: true)
maxAffectedNo允许影响的最大行数,默认 1000(超出自动回滚)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full burden and does so thoroughly: preview-vs-execute semantics via confirm="YES", DML execute-then-rollback reporting row counts, DDL non-rollback due to implicit commit, maxAffected auto-rollback, and per-write audit logging. This is exactly the behavioral context an agent needs before firing a mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with a scannable tier label and organized by authorization level. It is extremely dense and semicolon-chained, which raises parsing cost, but essentially every clause (prohibitions, rollback rules, audit) earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a write tool with no annotations and no output schema, this covers the full picture: authorization gates, statement whitelist/blacklist, transaction and rollback behavior, row-count reporting, and auditing. Nothing essential for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so the schema already documents all five parameters, but the description adds real nuance: it explains that DML without confirm executes-then-rolls-back reporting affected rows while DDL preview only performs static validation, and ties maxAffected/connection/allowWrite to concrete enforcement. This goes beyond restating field docs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a bracketed label establishing this as a write-execution tool (写操作) and enumerates exactly which statement classes it accepts (DML, specific DDL, destructive). An agent can immediately tell this apart from read-oriented siblings like db_query.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Extensive when/when-not guidance: tiered authorization gates, UPDATE/DELETE requiring WHERE, and a hard prohibition list (grant/revoke/call/exec 永远禁止). It does not name a sibling alternative for reads, so routing is implied by the 'read-only → DML' tier ladder rather than stated explicitly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.