Skip to main content
Glama
shadow-dba

mssql-dba-mcp

by shadow-dba

Get Top Resource Queries

mssql_top_queries
Read-onlyIdempotent

Rank SQL Server queries by CPU, logical reads, memory grants, spills, duration, or executions from the plan cache, and return statement text with plan handles for deeper analysis.

Instructions

Top queries by CPU, logical reads, memory grant, spills, duration or executions, from the plan cache (sys.dm_exec_query_stats), with statement text and the Plan Handle for mssql_execution_plan. topN default 25, max 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topNNoNumber of queries to return (1–100).
sortByNoResource dimension to sort by.cpu

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so the safety profile is covered. The description adds genuinely useful behavior beyond that: results come specifically from the plan cache (sys.dm_exec_query_stats), so only cached statements appear, and it discloses the return payload (statement text and Plan Handle).

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?

Two dense sentences with the sortable dimensions and data source front-loaded and no wasted wording. Every clause (dimensions, source, output payload, handoff, topN bound) carries information.

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 no output schema, the description correctly compensates by naming the returned fields (statement text, Plan Handle) and the data source. It omits any note on the cost/scope of scanning the plan cache or how stale cache entries affect results, but for a two-param read tool with full annotations it is essentially complete.

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% – both topN (default 25, range 1-100) and sortBy (full enum) are documented in the schema itself. The description's restatement of 'topN default 25, max 100' duplicates the schema without adding format or behavioral nuance, so the baseline 3 applies.

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+resource ('top queries') and enumerates the sortable dimensions (CPU, logical reads, memory grant, spills, duration, executions). It names the sibling it feeds into (mssql_execution_plan via Plan Handle) and the data source, so an agent can distinguish it from mssql_running_requests or mssql_wait_stats without opening a schema.

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

Usage Guidelines3/5

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

The description implies usage context (top resource consumers from the plan cache) and gives a clear downstream handoff to mssql_execution_plan, but it never states when to prefer this over alternatives like mssql_running_requests or mssql_wait_stats, nor any exclusions. Usage is implied rather than spelled out.

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