Skip to main content
Glama

run-sql

Destructive

Run SQL statements on SQL Server, Oracle, PostgreSQL, or MySQL targets using stored credentials, returning results without exposing passwords to the model.

Instructions

dbabrain common.cli run-sql: A statement to run on one target, and how. Runs with the rights of the login this node stores for the server (users.json: the instance's default_credential_name, or credential_name): what that login may do, this may do - DML and DDL included. The statement is checked to be one SELECT and the batch is rolled back, but the check reads text and does not bound what the login can do; a login with read rights only is what keeps it to reading. The SQL is the target engine's: SQL Server T-SQL https://learn.microsoft.com/sql/t-sql/language-reference, PostgreSQL https://www.postgresql.org/docs/current/sql-commands.html, Oracle https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/, MySQL https://dev.mysql.com/doc/refman/8.4/en/sql-statements.html. server_id (or target) names the server; its connection or host login is completed from this node's inventory and encrypted secret store, so a request carries no password. Changes or removes something. A command on the emergency-operations list takes confirm: "yes" and a reason in its request, as on the command line. Request fields (pass them as request):

  • target: A label for the answer - the server_id. Nothing is looked up by it: common.cli reads no configuration (rules R09).

  • sql_text: The SQL.

  • sql_file: Or a file of it.

  • database_name: One database.

  • sql_access: How to reach the SQL engine, overriding the connection's own sql_access block (an 8i bridge on this machine).

  • secrets: {ref: value} for exactly the secret refs the connection's sql_access names (an 8i bridge's signing secret) - never the whole store. The app that calls fills it from its own data/ (dbabrain.lib.data_sources.request_fil...

  • connection: The database login, complete: db_type, host, port, username, password - and, where they apply, database, instance_name, service_name, sqlserver_driver, sqlserver_tls_verify and sql_access (the 8i bridge); server_id an...

  • profile: What the target is.

  • driver: Which driver.

  • oracle_client_mode: thin | thick.

  • params: Bound parameters.

  • define: Oracle substitution variables.

  • defines: The same, plural.

  • prelude: SQL text prepended to each batch.

  • named_params: Values by name, bound where an Oracle or PostgreSQL statement says :name.

  • autocommit: Commit each statement.

  • commit: Commit at the end.

  • capture: Which result sets to keep: first (the default) or all.

  • max_rows: At most this many rows.

  • max_result_sets: At most this many result sets.

  • connect_timeout_seconds: How long connecting may take.

  • timeout_seconds: How long to wait.

  • output_path: Write the rows to a file.

  • format: json (default) | txt.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "run-sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
requestNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, and the description adds genuinely non-obvious behavior: the statement executes with the rights of the stored login (DML and DDL included), the SELECT check is textual only, the batch is rolled back, no password travels in the request, and secrets must be limited to the named refs. However, the stray line "Changes or removes something" sits awkwardly against the earlier claim that the statement is checked to be one SELECT, muddying rather than clarifying the risk profile.

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

Conciseness2/5

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

The text reads like a CLI manpage pasted into the description, with inline URLs, a stray sentence about destructive commands, and truncated field entries. Front-loading is decent in the first sentence, but much of the volume is exposition an agent cannot act on and the field list is cut off.

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

Completeness3/5

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

An output schema exists, so return values need not be described, and the credential/confirmation model is covered. Still, for a tool with a multi-engine, ~24-field request, the truncation and vague glosses on fields like `profile` and `driver` leave the calling agent without enough to construct a correct request in every case.

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

Parameters3/5

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

Schema coverage is 0% and the only parameter is an opaque `request` object, so the description must carry the full burden; it does enumerate roughly two dozen request fields with one-line meanings (sql_text, sql_file, database_name, autocommit, commit, capture, max_rows, timeout_seconds, output_path, format). But several glosses are vague ("profile: What the target is", "driver: Which driver") and two entries are truncated mid-sentence (`...request_fil`, `server_id an...`), leaving real gaps.

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

Purpose4/5

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

The opening line, "A statement to run on one target, and how," plus the later field `sql_text: The SQL` makes the verb and resource clear: execute a SQL statement against a named server. It never differentiates itself from siblings such as `store_query`, `db-activity`, or `query-plan`, and the core purpose is buried under credential-model exposition and four engine documentation links.

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

Usage Guidelines3/5

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

Usage is only implied (run arbitrary SQL when you need to execute rather than just inspect). The one real precondition is stated: a command on the emergency-operations list needs `confirm: "yes"` and a `reason`. There is no explicit when-not guidance and no routing to or away from any sibling tool.

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

Deploy Server

Other Tools