Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_query

Evaluate PromQL expressions to retrieve current time series data using a specified timestamp with VictoriaMetrics-mcp-server.

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

  • Handler case in the callTool request handler that extracts arguments and delegates to vmDataQuery for executing the vm_query tool.
    case "vm_query": { const {query, start, end, step} = request.params.arguments; return await vmDataQuery(query, start, end, step); }
  • Tool definition including name, description, and input schema for the vm_query tool.
    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)
    Registration of vm_query tool (VM_QUERY_TOOL) in the VM_TOOLS array, which is returned by the listTools handler.
    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 ];
  • Helper function that performs the actual API call to VictoriaMetrics /api/v1/query endpoint with the PromQL query and returns the result or error.
    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 }; } }

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