Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_query_range

Execute PromQL queries to retrieve time series data within a specified time range. Provide start, end timestamps, and step width to analyze metrics efficiently using VictoriaMetrics-mcp-server.

Instructions

Query time series over a time range

Input Schema

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

Implementation Reference

  • The core handler function that executes the vm_query_range tool by calling the VictoriaMetrics /api/v1/query_range endpoint with the provided query, start, end, and step parameters.
    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 }; } }
  • Dispatch handler in the CallToolRequestSchema switch statement that extracts arguments and calls the vmDataRangeQuery function for vm_query_range.
    case "vm_query_range": { const {query, start, end, step} = request.params.arguments; return await vmDataRangeQuery(query, start, end, step); }
  • Schema definition for the vm_query_range tool, specifying input parameters and validation.
    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 the vm_query_range tool (as VM_QUERY_RANGE_TOOL) in the array of available 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:338-340 (registration)
    Registration handler for ListToolsRequestSchema that exposes the tools list including vm_query_range.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: VM_TOOLS, }));

Other Tools

Related 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