Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_query

Query current time series values using PromQL expressions to monitor system metrics and performance data from VictoriaMetrics.

Instructions

Query current value of a time series

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL expression to evaluate
timeNoEvaluation timestamp in Unix seconds (optional)

Implementation Reference

  • Core handler function for vm_query tool: queries VictoriaMetrics /api/v1/query endpoint and returns JSON response.
    async function vmDataQuery(query, step) {
      let urlStr = VM_URL
      if (urlStr === "") {
        urlStr = VM_SELECT_URL
      }
      const url = new URL(urlStr + "/api/v1/query");
      url.searchParams.append("query", query);
      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
        };
      }
    }
  • Dispatch handler in CallToolRequestSchema: calls vmDataQuery with tool arguments for vm_query.
    case "vm_query": {
      const {query, start, end, step} = request.params.arguments;
      return await vmDataQuery(query, start, end, step);
    }
  • Tool definition with input schema: PromQL 'query' required, optional 'time'.
    const VM_QUERY_TOOL = {
      name: "vm_query",
      description: "Query current value of a time series",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "PromQL expression to evaluate",
          },
          time: {
            type: "number",
            description: "Evaluation timestamp in Unix seconds (optional)",
          }
        },
        required: ["query"],
      }
    };
  • src/index.js:127-134 (registration)
    Registers vm_query tool (line 130) in VM_TOOLS array used for listing tools.
    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
    ];
  • src/index.js:341-385 (registration)
    Registers the call tool request handler with switch dispatch including vm_query case.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        switch (request.params.name) {
          case "vm_data_write": {
            const {metric, values, timestamps} = request.params.arguments;
            return await vmMetricsDataWrite(metric, values, timestamps);
          }
          case "vm_query_range": {
            const {query, start, end, step} = request.params.arguments;
            return await vmDataRangeQuery(query, start, end, step);
          }
          case "vm_query": {
            const {query, start, end, step} = request.params.arguments;
            return await vmDataQuery(query, start, end, step);
          }
          case "vm_labels": {
            return await vmLabels();
          }
          case "vm_label_values": {
            const {label} = request.params.arguments;
            return await vmLabelValues(label);
          }
          case "vm_prometheus_write": {
            const {data} = request.params.arguments;
            return await vmPrometheusWrite(data);
          }
          default:
            return {
              content: [{
                type: "text",
                text: `Unknown tool: ${request.params.name}`
              }],
              isError: true
            };
        }
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool queries 'current value' but doesn't explain what 'current' means (e.g., real-time vs. latest data), whether it's read-only or has side effects, error handling, rate limits, or authentication needs. For a query tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, clear sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for a simple query tool. Every word earns its place without redundancy or 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?

Given the complexity of a time-series query tool with no annotations, no output schema, and sibling tools for related operations, the description is incomplete. It doesn't cover return values, error cases, or how it differs from 'vm_query_range'. For a tool that likely returns structured data, more context is needed to use it effectively.

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 description coverage is 100%, so the schema already documents both parameters ('query' as PromQL expression and 'time' as optional Unix timestamp). The description adds no additional parameter semantics beyond what's in the schema, such as query format examples or time interpretation. Baseline 3 is appropriate when the 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 clearly states the tool's purpose as 'Query current value of a time series' with a specific verb ('Query') and resource ('current value of a time series'). It distinguishes from sibling tools like 'vm_query_range' (range queries) and 'vm_data_write' (write operations), though it doesn't explicitly mention these distinctions in the description text itself.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'vm_query_range' for range queries or 'vm_labels' for metadata queries, nor does it specify use cases, prerequisites, or exclusions. The agent must infer usage from the tool name and schema alone.

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