Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_query_range

Query time series data over a specified time range using PromQL expressions to analyze historical metrics and performance trends.

Instructions

Query time series over a time range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL expression
startNoStart timestamp in Unix seconds
endNoEnd timestamp in Unix seconds
stepNoQuery resolution step width

Implementation Reference

  • Switch case handler for vm_query_range tool call, extracts arguments and invokes the query range function.
    case "vm_query_range": {
      const {query, start, end, step} = request.params.arguments;
      return await vmDataRangeQuery(query, start, end, step);
  • Core helper function that performs the HTTP range query to VictoriaMetrics API, handles response and formats output.
    async function vmDataRangeQuery(query, start, end, step) {
      let urlStr = VM_URL
      if (urlStr === "") {
        urlStr = VM_SELECT_URL
      }
      const url = new URL(urlStr + "/api/v1/query_range");
      url.searchParams.append("query", query);
      url.searchParams.append("start", start ?? "");
      url.searchParams.append("end", end ?? "");
      url.searchParams.append("step", step ?? "");
      const response = await fetch(url.toString());
      const data = await response.json();
    
      if (data.status === "success") {
        return {
          content: [{
            type: "text",
            text: JSON.stringify(data.data),
          }],
          isError: false
        };
      } else {
        return {
          content: [{
            type: "text",
            text: "range query fail:" + await response.text(),
          }],
          isError: true
        };
      }
    }
  • Tool schema definition specifying name, description, and input schema for vm_query_range.
    const VM_QUERY_RANGE_TOOL = {
      name: "vm_query_range",
      description: "Query time series over a time range",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "PromQL expression",
          },
          start: {
            type: "number",
            description: "Start timestamp in Unix seconds",
          },
          end: {
            type: "number",
            description: "End timestamp in Unix seconds",
          },
          step: {
            type: "string",
            description: "Query resolution step width",
          }
        },
        required: ["query"],
      }
    };
  • src/index.js:127-134 (registration)
    Registration of vm_query_range tool (as VM_QUERY_RANGE_TOOL) in the list of available tools returned by ListToolsRequestHandler.
    const VM_TOOLS = [
      VM_DATA_WRITE_TOOL,
      VM_QUERY_RANGE_TOOL,
      VM_QUERY_TOOL,
      VM_LABELS_TOOL,
      VM_LABEL_VALUES_TOOL,
      VM_PROMETHEUS_WRITE_TOOL
    ];
Behavior2/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral information. It states it's a query operation (implying read-only) but doesn't disclose rate limits, authentication requirements, error conditions, or what happens with invalid queries. For a time series query tool with 4 parameters, this leaves significant behavioral unknowns.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with good schema documentation and gets straight to the core functionality without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a time series query tool with 4 parameters and no annotations or output schema, the description is insufficient. It doesn't explain what the tool returns (time series data format), error handling, performance characteristics, or limitations. The combination of no annotations and no output schema means the description should provide more operational context than it does.

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 description coverage is 100%, so all parameters are documented in the schema. The description adds minimal value beyond the schema - it mentions 'time range' which aligns with 'start' and 'end' parameters, but doesn't provide additional context about parameter relationships or usage patterns. Baseline 3 is appropriate when schema does the heavy lifting.

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 'Query time series over a time range' clearly states the action (query) and resource (time series) with scope (over a time range). It distinguishes from sibling tools like 'vm_data_write' (write operation) and 'vm_labels' (metadata query), but doesn't explicitly differentiate from 'vm_query' which likely has different temporal parameters.

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?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention when to choose this over 'vm_query' (the most similar sibling) or other time series querying approaches. There's no context about appropriate use cases or limitations.

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/yincongcyincong/VictoriaMetrics-mcp-server'

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