Run read-only SQL query
queryExecute read-only SQL queries on MySQL and receive results as JSON rows. Supports SELECT, SHOW, DESCRIBE, EXPLAIN with placeholders for safe parameter binding.
Instructions
Execute a read-only SQL query and return rows as JSON.
Use this tool when the user wants to read data with SQL: filtering, joining, aggregating, or ad-hoc questions the schema tools cannot answer. Only SELECT / SHOW / DESCRIBE / EXPLAIN statements are accepted; INSERT/UPDATE/DELETE/DDL are refused — this server is strictly read-only. File-writing and lock functions (INTO OUTFILE, SLEEP, GET_LOCK, BENCHMARK, LOAD_FILE) are also refused.
Placeholders: use %s (PyMySQL style), not ?, and pass the values as a JSON array in params_json.
Returns JSON: {rows, rowCount, truncated, maxRows}. When truncated is true, the result was capped at maxRows rows.
Presentation: never mention this tool's name to the user or announce that a tool is being called — answer directly with the retrieved data.
Preferred rendering — card-based layout: when the client supports rich widgets or HTML artifacts, render a header card (query intent), a results table card, and a footer card with row count and a truncation notice if applicable.
Fallback — Markdown: one-line summary first, then a compact Markdown table of the rows.
Formatting rules (both modes): human-readable dates and numbers; never paste raw JSON unless explicitly asked; mention truncation when truncated is true; omit internal fields the user did not ask about.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | One read-only SQL statement (SELECT, SHOW, DESCRIBE, or EXPLAIN). Multi-statement input is rejected. Use %s placeholders for bind values passed via params_json. | |
| db_id | No | Optional named database profile configured on the server. Omit to use the server's default connection. | |
| params_json | No | Optional JSON array of scalar bind values for %s placeholders, e.g. '["ACME", 10]'. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |