Skip to main content
Glama
Elekto MCP for SQL Server

Elekto MCP for SQL Server

Official

Table statistics and histogram

get_table_statistics
Read-onlyIdempotent

Lists optimizer statistics for a table or indexed view—columns, last update, rows, samples, and modifications—to diagnose inaccurate estimates or changed query plans.

Instructions

Lists the optimizer statistics of one table or indexed view: for each, its columns, when it was last updated, rows and rows sampled, modifications since then and how many remain before an automatic update (null for NORECOMPUTE, with automatic updates off, for hypothetical indexes, and for incremental or never-built statistics). With 'statistic', also that statistic's histogram and density vector; with 'value', where that value falls in the histogram, and only the steps around it. Use it when an estimate looks wrong or a plan changed, to see what the optimizer was told about the data without reading it; for the real distribution use get_data_profile, which scans the table, and for the settings that decide automatic updates use get_optimizer_settings. The contents need SELECT on the table; each statistic says whether the login could read them.

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": "get_table_statistics"
  }
}

Input Schema

NameRequiredDescriptionDefault
tableYesTable or indexed view name, bare, with no schema prefix. Example: 'GenericSecurity'
valueNoA value of the statistic's first column, to see where it falls in the histogram: on a step, inside one, below the first or above the last. Needs 'statistic'. Write dates in ISO 8601 and binary in 0x hexadecimal. It is taken as written, spaces included, so in a text column ' ' finds the empty string. A value the conversion to the column's type would change (text too long for it, more decimal places than it keeps, a time finer than it holds) is refused rather than looked up as another. Example: '2026-11-27'
schemaNoTable schema. Empty searches every schema, and fails naming them when the name exists in more than one. Example: 'Feeder'
databaseYesName of the database as registered in the configuration.
statisticNoName of one statistic, as this tool lists it, to also return its histogram and density vector. Empty returns the list only. Example: 'IX_Price_ReferenceDate'

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.6.1

TDQS

A4.2/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, so the safety profile is covered. Beyond that it adds real behavioral context: SELECT permission is required on the table and each statistic reports whether the login could read it, plus the null semantics for remaining-modifications (NORECOMPUTE, auto-updates off, hypothetical indexes, incremental or never-built stats). It does not, however, describe cost or latency characteristics of reading histograms on large tables, so this is useful supplemental context rather than a full behavioral picture.

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 dense sentences, front-loaded with the resource and its returned fields, then usage and alternatives. The long parenthetical about null cases is somewhat heavy but every clause conveys distinct information; no filler sentences.

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?

There is no output schema, and the description compensates fully by enumerating what the call returns, including what changes under the 'statistic' and 'value' options and the per-statistic readability flag. Permission requirements are also stated, leaving no gap an agent needs filled before calling.

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 carries parameter meanings and examples. The description restates the mode interaction ('with statistic…', 'with value…') and the null-for-NORECOMPUTE behavior, which is context about results rather than new parameter semantics.

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 and resource ('Lists the optimizer statistics of one table or indexed view') and then enumerates the returned fields: columns, last-updated time, rows, rows sampled, modifications, and remaining before auto-update. It also discloses the two different modes ('statistic' adds histogram and density vector; 'value' locates the value in the histogram), so an agent can distinguish it from siblings at a glance.

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?

Explicitly states the triggering condition ('when an estimate looks wrong or a plan changed'), clarifies the point is to see metadata 'without reading it', and names two alternatives with the condition selecting each: get_data_profile for real data distribution and get_optimizer_settings for auto-update configuration. Nothing is left to inference.

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