Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_data_write

Write time-series data to VictoriaMetrics database by specifying metrics, values, and timestamps for storage and analysis.

Instructions

Write data to the VM database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYestag of metric
valuesYesArray of metric values
timestampsYesArray of metric timestamps

Implementation Reference

  • Core handler function that performs the HTTP POST request to VictoriaMetrics /api/v1/import endpoint with the provided metric, values, and timestamps, returning success or error content.
    async function vmMetricsDataWrite(metric, values, timestamps) { let urlStr = VM_URL if (urlStr === "") { urlStr = VM_INSERT_URL } const url = new URL(urlStr + "/api/v1/import"); const data = { "metric": metric, "values": values, "timestamps": timestamps }; const response = await fetch(url.toString(), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); const status = response.status; if (status === 204) { return { content: [{ type: "text", text: response.text(), }], isError: false }; } else { return { content: [{ type: "text", text: response.text(), }], isError: true }; } }
  • Defines the tool schema including name, description, and input schema with required properties: metric (object), values (array of numbers), timestamps (array of numbers).
    const VM_DATA_WRITE_TOOL = { name: "vm_data_write", description: "Write data to the VM database", inputSchema: { type: "object", properties: { metric: { type: "object", description: "tag of metric", }, values: { type: "array", description: "Array of metric values", items: { "type": "number" }, }, timestamps: { type: "array", description: "Array of metric timestamps", items: { "type": "number" }, } }, required: ["metric", "values", "timestamps"], } };
  • src/index.js:127-134 (registration)
    Registers the vm_data_write tool (as VM_DATA_WRITE_TOOL) in the VM_TOOLS array, which is returned by the ListToolsRequestSchema 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 ];
  • Switch case in CallToolRequestSchema handler that destructures arguments and invokes the vmMetricsDataWrite handler function.
    case "vm_data_write": { const {metric, values, timestamps} = request.params.arguments; return await vmMetricsDataWrite(metric, values, timestamps); }

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