Skip to main content
Glama

Read Data from SQL Server

read_data
Read-onlyIdempotent

Execute read-only SELECT or WITH queries against a named SQL Server instance; small results return inline JSON, large results write to CSV for code processing.

Instructions

Execute a read-only SQL SELECT query against a named SQL Server instance. Only SELECT and WITH (CTE) queries are allowed. Use list_servers first to discover available server names. Small results are returned inline as JSON {truncated, rows}. Large results (over the configured row threshold, 500 by default, or about 40,000 characters) are written to a CSV file instead, and the response gives the file path, row count, column names and types, and a 10-row preview. Process a result file with code (e.g. Python csv/pandas, PowerShell Import-Csv) rather than reading it into context.

Input Schema

NameRequiredDescriptionDefault
queryYesSQL SELECT query to execute. Only SELECT and WITH (CTE) queries are permitted.
toFileNoWrite the full result to a CSV file and return its path and a preview, whatever its size. Use when the rows will be processed with code.
serverNameYesName of the SQL Server to query (use list_servers to see available names)
databaseNameYesName of the database to query (use list_databases to see available databases)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.7.0
    • addedInput schema / properties / toFile
      Added value: +{
      +  "default": false,
      +  "description": "Write the full result to a CSV file and return its path and a preview, whatever its size. Use when the rows will be processed with code.",
      +  "type": "boolean"
      +}
  2. First observedv1.3.1

TDQS

A4.7/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnlyHint, idempotentHint), but the description goes well beyond them: it discloses the row threshold (~500 rows / ~40,000 chars) that triggers CSV output, the exact response shapes (JSON {truncated, rows} vs. file path + row count + column names/types + 10-row preview), and instructs the agent to process files with code rather than into context. This is exactly the operational context an agent needs.

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?

Front-loaded with purpose and constraint, then prerequisites, then the two return paths in order of relevance. Every sentence carries distinct information (constraint, prerequisite, small-result shape, large-result shape, downstream handling) with no filler.

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?

With no output schema present, the description carries the return-value burden and does so fully, describing both the inline JSON and CSV-file response formats plus guidance on handling each. Nothing an agent needs to call this correctly and interpret results is missing.

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 description coverage is 100%, so the baseline is 3, but the description adds meaning beyond the schema by explaining the automatic large-result-to-file fallback (whose threshold the schema's toFile description doesn't mention) and by reiterating the SELECT/WITH restriction on query. It meaningfully clarifies the consequence of toFile above what the schema states.

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?

States a specific verb (execute) and resource (read-only SELECT against a named SQL Server instance) plus the hard constraint that only SELECT/WITH queries are permitted. This clearly separates it from siblings like describe_table, get_object_definition, and get_query_plan, which inspect schema/definitions rather than return rows.

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?

Gives concrete prerequisites and routing ("Use list_servers first", "use list_databases to see available databases") and tells the agent when to prefer toFile and to process large results with code. It does not explicitly contrast against sibling tools that also read data, but the when-to-use context is clear.

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