Skip to main content
Glama
GreptimeDB MCP Server

GreptimeDB MCP Server

Official
by GreptimeTeam

query_range

Run time-window aggregation queries on non-metric tables using RANGE syntax, with alignment steps, group-by columns, fill strategies, and filters to summarize data over intervals.

Instructions

Execute time-window aggregation query using GreptimeDB's RANGE query syntax.

The narrowest of the three query entry points. Use it for a window
aggregation over a non-metric table, or an alignment PromQL cannot state;
a metric time series is better served by execute_tql and anything else by
execute_sql.

`select` must carry at least one aggregate with its own RANGE, such as
`avg(cpu) RANGE '5m'`, and `align` supplies the step between windows. A
plain column list does not plan. `table` accepts `schema.table` to read a
database other than the connected one.

A larger align lowers resolution; tighter filters or a lower limit return
a subset. An untruncated retry with those changes does not cover the
original query.

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": {
      "table": "<table>",
      "select": "<select>",
      "align": "<align>"
    },
    "name": "query_range"
  }
}

Input Schema

NameRequiredDescriptionDefault
byNoGroup by columns, e.g., 'host'
fillNoFill strategy: NULL, PREV, LINEAR, or a value
alignYesAlignment interval, e.g., '1m', '5m'
limitNoMaximum rows to return, clamped to 1-10000
tableYesTable name to query (supports schema.table format)
whereNoWHERE clause conditions
formatNoOutput format: csv, json, or markdown (default: json)json
selectYesColumns and aggregations, e.g., ts, host, avg(cpu) RANGE '5m'
order_byNoORDER BY clause (e.g., 'ts DESC')

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changedv0.6.2
    • addedInput schema / properties / align / description
      Added value: +"Alignment interval, e.g., '1m', '5m'"
    • addedInput schema / properties / by / description
      Added value: +"Group by columns, e.g., 'host'"
    • addedInput schema / properties / fill / description
      Added value: +"Fill strategy: NULL, PREV, LINEAR, or a value"
    • addedInput schema / properties / format / description
      Added value: +"Output format: csv, json, or markdown (default: json)"
    • addedInput schema / properties / limit / description
      Added value: +"Maximum rows to return, clamped to 1-10000"
    • addedInput schema / properties / order_by / description
      Added value: +"ORDER BY clause (e.g., 'ts DESC')"
    • addedInput schema / properties / select / description
      Added value: +"Columns and aggregations, e.g., ts, host, avg(cpu) RANGE '5m'"
    • addedInput schema / properties / table / description
      Added value: +"Table name to query (supports schema.table format)"
    • addedInput schema / properties / where / description
      Added value: +"WHERE clause conditions"
    • changedOutput schema / (root)
      Previous value: -{
      -  "properties": {
      -    "result": {
      -      "title": "Result",
      -      "type": "string"
      -    }
      -  },
      -  "required": [
      -    "result"
      -  ],
      -  "title": "query_rangeOutput",
      -  "type": "object"
      -}New value: +null
  2. Addedv0.5.0

TDQS

A4.5/5.0
Behavior4/5

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

No annotations are supplied, so the description carries the full burden, and it does substantial work: it warns that `select` must contain an aggregate with its own RANGE ('a plain column list does not plan'), explains that `align` sets the step, discloses cross-database reads via `schema.table`, and states that larger align lowers resolution and that an untruncated retry does not cover the original query. It stops short of stating that this is a read-only operation or describing the result envelope (rows vs. truncation signal), which keeps it off a 5.

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?

Front-loaded with purpose and routing before constraints, and every paragraph carries information. A few sentences are terse to the point of obscurity ('A plain column list does not plan', 'An untruncated retry with those changes does not cover the original query'), which costs a little clarity for the compression gained.

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?

For a 9-parameter, no-annotation, no-output-schema tool this covers the load-bearing semantics: query shape requirements, alignment behavior, cross-database reads, and result-set narrowing. It leaves the read-only nature and the returned row/truncation signal implicit, which is a modest but real gap for an unannotated tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: the constraint that `select` must include at least one RANGE-bearing aggregate, that `align` is the inter-window step, and that `table` accepts `schema.table` for a different database. It does not add semantics for `by`, `fill`, `where`, `order_by`, `limit`, or `format`, relying on the schema for those.

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 ('Execute time-window aggregation query using GreptimeDB's RANGE query syntax') and immediately positions itself as 'the narrowest of the three query entry points', naming execute_tql and execute_sql as the alternatives. An agent can distinguish it from siblings without opening any schema.

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 positive selection criteria (window aggregation over a non-metric table, or an alignment PromQL cannot state) and explicit negative routing (metric time series → execute_tql, anything else → execute_sql). Both when-to-use and when-not-to-use are covered with named alternatives.

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