Skip to main content
Glama

Query topic messages with SQL

query_messages
Read-onlyIdempotent

Run read-only SQL queries over a single topic to filter, aggregate, downsample, and retrieve event evidence from physical-world data. Returns rows as dictionaries for analysis.

Instructions

Answer quantitative questions with read-only DuckDB SQL over one topic: filtering, aggregates, downsampling, and event evidence. Call describe_data_source and describe_topic first; use the returned schema and show the SQL to the user. Returns rows as dictionaries. Use read_loggings for textual diagnostics. Time bounds are inclusive source timestamps in seconds, not offsets from the first message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argsNo
pathYes
topicYes
end_secondsNo
sql_statementYes
start_secondsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.1

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare read-only, idempotent, and non-destructive behavior. The description adds valuable context beyond that: time bounds are 'inclusive source timestamps in seconds, not offsets from the first message,' and the return format is 'rows as dictionaries.' It also mandates showing the SQL to the user, which is a behavioral requirement not captured in annotations. No contradiction exists.

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 three packed sentences, front-loaded with purpose, then usage prerequisites, then time semantics. Every sentence earns its place; there is no filler or redundant restatement of the title or annotations. It is concise without sacrificing critical 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?

Given the tool's complexity (SQL over messages, six parameters) and that an output schema exists, the description covers the essential context: prerequisites, output format, usage pattern, and time semantics. It does not explain 'path' or 'args', which might be non-obvious, but the presence of an output schema reduces the need to describe return structure. Overall, it is fairly complete for a read-only query tool.

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?

With schema description coverage at 0%, the description must compensate for parameter meaning. It clarifies start_seconds and end_seconds as inclusive source timestamps in seconds, and implies topic is the single topic being queried. However, it leaves 'path' and 'args' unexplained. This is partial compensation but not complete, so a mid-range score is appropriate.

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?

The description states a specific verb and resource: 'Answer quantitative questions with read-only DuckDB SQL over one topic.' It clearly distinguishes from siblings like read_loggings (textual diagnostics) and describe_topic (schema description) by emphasizing quantitative SQL querying on a single topic. The mention of 'filtering, aggregates, downsampling, and event evidence' further specifies the tool's scope.

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?

The description gives explicit, actionable usage guidance: 'Call describe_data_source and describe_topic first; use the returned schema and show the SQL to the user.' It also provides an explicit alternative: 'Use read_loggings for textual diagnostics.' This tells the agent exactly when to use this tool versus a specific sibling, and the prerequisite sequence is clear.

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