Skip to main content
Glama

rails_query

Read-only

Run read-only SQL SELECT queries against a Rails app database to inspect data patterns, verify migrations, and debug data issues, with validation, timeouts, and row limits.

Instructions

Execute read-only SQL queries against the database. Use when: checking data patterns, verifying migrations, debugging data issues. Safety: SQL validation + database-level READ ONLY + statement timeout + row limit. Development/test only by default. Key params: sql (SELECT only), limit (default 100), format (table/csv).

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL query to execute. Only SELECT, WITH, SHOW, EXPLAIN, DESCRIBE allowed, and no UNION.
limitNoMax rows to return. Default: 100, hard cap: 1000.
formatNoOutput format. table: markdown table (default). csv: comma-separated values.
explainNoRun EXPLAIN on the query. Returns execution plan analysis instead of data. SELECT only.
databaseNoThe app database to query, by its config/database.yml name (for example queue). Default: the primary.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv5.39.1

TDQS

A4.1/5.0
Behavior5/5

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

Annotations already declare readOnlyHint and destructiveHint=false, yet the description adds real context beyond them: SQL validation, a database-level READ ONLY session, statement timeout, row limit, and dev/test environment gating. These are exactly the operational constraints an agent needs before calling a raw-SQL tool.

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 purpose, then use cases, then safety, then params — good ordering with no filler. The trailing 'Key params' clause largely duplicates the schema and is the one part that does not earn its place.

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

Completeness4/5

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

With five parameters, full schema coverage, rich annotations, and no output schema, the description covers purpose, timing, and safety adequately. What is missing is behavior of the less obvious options (explain, database) and error/result semantics, which keeps it from a 5.

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 description coverage is 100%, so the schema already documents sql, limit, format, explain, and database in detail. The description's 'Key params' line restates schema content (SELECT only, default 100, table/csv) without adding syntax or format detail, and ignores explain and database entirely.

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 description opens with a specific verb+resource ('Execute read-only SQL queries against the database'), which cleanly separates this tool from the introspection siblings like rails_get_schema or rails_search_code. It does not explicitly name a sibling as the alternative, so it stops short of a 5.

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?

'Use when: checking data patterns, verifying migrations, debugging data issues' gives concrete triggering scenarios, and 'Development/test only by default' sets an environment boundary. It lacks explicit when-not guidance or a pointer to the introspection siblings for schema questions.

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