Skip to main content
Glama
Elekto MCP for SQL Server

Elekto MCP for SQL Server

Official

Query a table or view

query_table
Read-onlyIdempotent

Runs read-only SELECT queries on a table or view with filters, ordering, grouping, aggregates, pagination and sampling. Returns rows with row_count and a truncated flag so partial results are never mistaken for complete ones.

Instructions

Runs a SELECT on one table or view, with optional column list, filter, ordering, grouping, aggregates (COUNT, SUM, AVG, MIN, MAX), pagination and random sampling, and returns the rows in an object with row_count and a measured 'truncated' flag, so a short result is never mistaken for a complete one. Rows are capped by the database's max_query_rows. Call get_table_schema first for exact column names; for null ratios, distinct counts and frequent values use get_data_profile instead of paging through rows. Reads actual data; never runs INSERT, UPDATE, DELETE or procedures.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "database": "<database>",
      "table": "<table>"
    },
    "name": "query_table"
  }
}

Input Schema

NameRequiredDescriptionDefault
topNoMaximum number of rows to return (default 100, capped by the per-database limit).
skipNoNumber of rows to skip before returning results (for pagination, default 0).
tableYesTable or view name, bare, with no schema prefix. Example: 'GenericSecurity'
whereNoWHERE clause without the WHERE keyword: one boolean expression, which may call functions and hold subqueries. Comments, ';', a second statement, tables on a linked server and system functions that read server files are refused. Example: "Source = 'BDS' AND ReferenceDate >= '2026-01-01'"
schemaNoTable/view schema. Empty means dbo. Example: 'Feeder'
columnsNoColumns as ONE comma-separated string, not a JSON array. Example: 'ReferenceDate, Source, Close'. Empty or '*' returns every column. Reserved words need no quoting or brackets.
databaseYesName of the database as registered in the configuration.
group_byNoGROUP BY columns as ONE comma-separated string. Example: 'Source, Name'
order_byNoORDER BY list without the ORDER BY keywords: columns or expressions separated by commas, each optionally followed by ASC or DESC. Example: 'ReferenceDate DESC, Name'
aggregatesNoAggregates as ONE comma-separated string of FUNC(column) [AS alias], with FUNC one of COUNT, SUM, AVG, MIN, MAX. Only a bare column name is allowed inside the parentheses. Example: 'COUNT(*) AS Total, MAX(ReferenceDate) AS Ultima'
sample_percentNoRandom sampling percentage, from 0.01 to 100. Zero (the default) means no sampling.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.3.6
    • changedInput schema / properties / order_by / description
      Previous value: -"ORDER BY clause without the ORDER BY keyword. Example: 'ReferenceDate DESC, Name'"New value: +"ORDER BY list without the ORDER BY keywords: columns or expressions separated by commas, each optionally followed by ASC or DESC. Example: 'ReferenceDate DESC, Name'"
    • changedInput schema / properties / where / description
      Previous value: -"WHERE clause without the WHERE keyword, as SQL. Example: \"Source = 'BDS' AND ReferenceDate >= '2026-01-01'\""New value: +"WHERE clause without the WHERE keyword: one boolean expression, which may call functions and hold subqueries. Comments, ';', a second statement, tables on a linked server and system functions that read server files are refused. Example: \"Source = 'BDS' AND ReferenceDate >= '2026-01-01'\""
  2. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, so the description's job is to add what the annotations cannot. It does: rows are capped by the database's max_query_rows, the response carries a measured 'truncated' flag so short results aren't misread as complete, and specific WHERE constructs (comments, ';', second statements, linked-server tables, file-reading system functions) are refused.

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?

Two sentences, front-loaded with the core action and returning constraints, then routing advice. The first sentence is long and clause-dense but each clause carries real information; nothing is padded or redundant.

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 an 11-parameter tool with no output schema, the description still explains the return shape (an object with row_count and a truncated flag) and the row cap. Combined with fully described parameters and read-only annotations, an agent has everything needed to invoke it correctly and interpret results.

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 coverage is 100% and the schema itself documents syntax, defaults, and examples for every parameter, including the comma-separated-string quirk for columns and aggregates. The description adds only marginal meaning beyond that, notably the note that results are capped by the database's max_query_rows, which clarifies how `top` interacts with a server-side limit.

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?

Opens with a specific verb and resource ("Runs a SELECT on one table or view") and enumerates the exact capabilities: column list, filter, ordering, grouping, aggregates, pagination, sampling. It also names the operation's boundary ("never runs INSERT, UPDATE, DELETE or procedures"), which separates it from write tools in the catalog.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit sequencing advice ("Call get_table_schema first for exact column names") and an explicit alternative with the condition that selects it ("for null ratios, distinct counts and frequent values use get_data_profile instead of paging through rows"). An agent knows both when to use this and when to route elsewhere.

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