Skip to main content
Glama

Execute SELECT Query

mysql_query
Read-only

Execute read-only SELECT queries against MySQL databases using parameter binding and output as JSON or markdown.

Instructions

Execute a read-only SELECT query against MySQL.

Only SELECT and SHOW/EXPLAIN statements are permitted. Use mysql_execute for write operations.

Args:

  • sql (string, required): SQL SELECT statement. Use ? placeholders for params.

  • params (array, optional): Bind parameters corresponding to ? placeholders.

  • database (string, optional): Database name. Uses MYSQL_DATABASE if omitted.

  • limit (number, optional): Max rows to return (default: 100, max: 1000).

  • response_format ('markdown' | 'json'): Output format (default: 'json')

Returns:

  • json: { rows: object[], count: number, has_more: boolean }

  • markdown: formatted table

Examples:

  • sql: "SELECT * FROM biz_exhaust_yg WHERE jcrq = ? LIMIT 10", params: ["2026-03"]

  • sql: "SELECT COUNT(*) as cnt FROM biz_exhaust_hy"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSELECT SQL statement. Use ? for bind parameters.
paramsNoBind parameters for ? placeholders
databaseNoDatabase name (uses MYSQL_DATABASE env var if omitted)
limitNoMaximum rows to return (default 100)
response_formatNoOutput format: 'markdown' or 'json'json
Behavior5/5

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

Annotations already set readOnlyHint=true and destructiveHint=false. Description adds behavioral details: only SELECT/SHOW/EXPLAIN allowed, limit defaults (100, max 1000), optional database fallback, response formats (json/markdown) with has_more flag. No contradictions.

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

Conciseness5/5

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

Structured into clear sections (purpose, args, returns, examples). Each sentence is informative with no redundancy. Efficiently covers all necessary information.

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?

Thoroughly covers all 5 parameters, return formats, and edge cases (defaults, optional params). Includes examples. No output schema needed as returns are described. Complete for a read-only query tool.

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% with good descriptions. Description adds examples of ? placeholders, clarifies bind parameters, and notes default database from env var. Adds value beyond schema.

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?

Clearly states 'Execute a read-only SELECT query against MySQL' and explicitly lists permitted statements (SELECT, SHOW, EXPLAIN). Differentiates from sibling mysql_execute for write operations.

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?

Provides explicit guidance: 'Use mysql_execute for write operations.' Includes parameter roles, defaults, and examples. Lacks explicit mention of when to use other siblings like mysql_describe_table, but the distinction is clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/donald-ada/mysql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server