Skip to main content
Glama
jesse-smith
by jesse-smith

execute_query

Execute read-only SQL SELECT queries against SQL Server databases, returning structured JSON results with columns, rows, and automatic row limiting.

Instructions

Execute a SQL SELECT query and return results.

Executes ad-hoc SELECT queries with automatic row limiting for safety. Write operations (INSERT, UPDATE, DELETE) are blocked. Results are returned as a structured JSON with columns and rows.

Large text values (>1000 chars) and binary data are automatically truncated to keep responses token-efficient.

Args: connection_id: Connection ID from connect_database query_text: SQL query to execute (SELECT only) row_limit: Maximum rows to return, 1-10000 (default: 1000)

Returns: TOON-encoded string with query results:

    status: "success" | "blocked" | "error"
    query_id: string                   // on success only
    query_type: string                 // on success only
    columns: list of string            // on success only
    rows: list of object               // on success only
    rows_returned: int                 // on success only
    rows_available: int                // on success only
    limited: bool                      // on success only
    execution_time_ms: float           // on success only
    error_message: string              // on error/blocked only

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
row_limitNo
query_textYes
connection_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It covers blocking of writes, automatic row limiting, truncation of large text and binary data, and the status/error model. This is far beyond a minimal description and gives the agent a realistic picture of side effects and constraints.

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?

The description is well-structured with a purpose, behavior notes, Args, and Returns sections. Every section earns its place; the detailed return format is useful given the tool's output complexity. No filler or redundant restating of the tool name.

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 query-execution tool with no annotations and low schema coverage, this description is essentially complete. It covers input semantics, safety behavior, output encoding, statuses, and error/blocked cases. An agent has enough information to call and interpret the tool correctly.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate for all three parameters. It does so clearly: connection_id comes from connect_database, query_text is SELECT-only, and row_limit has an explicit range and default. This adds meaningful semantics that the raw schema lacks.

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?

The description opens with a specific verb and resource: 'Execute a SQL SELECT query and return results.' It further clarifies scope with 'ad-hoc SELECT queries' and explicitly excludes write operations, making it clearly distinct from the sibling schema/metadata tools.

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?

It provides clear context: this tool is for ad-hoc SELECT queries against an existing connection, with a prerequisite indicated via 'connection_id: Connection ID from connect_database.' It also states when not to use it by noting write operations are blocked. It does not explicitly name sibling alternatives, but the usage context is clear enough.

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