Skip to main content
Glama

get_top_cached_queries

Read-onlyIdempotent

Retrieve top cached SQL statements from Azure SQL Database, showing execution counts, CPU time, and logical reads. Pinpoint resource-intensive queries for performance tuning.

Instructions

Get top cached statements from sys.dm_exec_query_stats. Returns bounded text previews and plan-cache metrics without raw plan XML.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum cached queries to return.
sort_byNoSort by execution_count, total_worker_time, avg_worker_time, total_elapsed_time, avg_elapsed_time, total_logical_reads, total_physical_reads, or total_logical_writes.total_worker_time
database_nameNoOptional database name. Defaults to AZURE_SQL_DEFAULT_DATABASE.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

Annotations already indicate read-only, idempotent, and non-destructive behavior. The description adds valuable behavioral context by noting that it returns bounded text previews and omits raw plan XML, which clarifies output format and potential limitations. No contradiction with annotations.

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 two sentences, front-loaded with the primary action, and contains no filler. Every word contributes to understanding the tool's purpose and output constraints.

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?

Given the presence of a full output schema and annotations, the description adequately covers the tool's purpose and key behavioral traits. It misses context about typical use cases or relationship to siblings, but for a read-only query tool with good schema coverage, it is sufficiently 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?

The schema covers all parameters with descriptions and defaults, so the baseline is 3. The description does not add further semantic detail about how parameters interact with the returned data, but the schema already provides sufficient guidance.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool fetches top cached statements from sys.dm_exec_query_stats, which is a specific verb-resource combination. It does not explicitly distinguish itself from sibling tools like get_top_queries or get_plan_cache_analysis, but the mention of the system view and output specifics provides clarity.

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

Usage Guidelines2/5

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

The description does not provide any guidance on when to use this tool versus alternatives. It merely states what it does, leaving the agent to infer suitability. No exclusions, prerequisites, or conditional usage are mentioned.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/akaalholdings/azure-sql-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server