Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_prometheus_write

Import Prometheus exposition format metrics data into VictoriaMetrics for monitoring and analysis.

Instructions

mport Prometheus exposition format data into VictoriaMetrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesMetrics data in Prometheus exposition format

Implementation Reference

  • The core handler function that receives Prometheus exposition format data and POSTs it to the VictoriaMetrics /api/v1/import/prometheus endpoint as text/plain, returning success or error response.
    async function vmPrometheusWrite(data) { let urlStr = VM_URL if (urlStr === "") { urlStr = VM_INSERT_URL } const url = new URL(urlStr + "/api/v1/import/prometheus"); const response = await fetch(url.toString(), { method: 'POST', headers: { 'Content-Type': 'text/plain' }, body: 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 }; } }
  • Tool schema definition including name, description, and inputSchema requiring a 'data' string in Prometheus format.
    const VM_PROMETHEUS_WRITE_TOOL = { name: "vm_prometheus_write", description: "mport Prometheus exposition format data into VictoriaMetrics", inputSchema: { type: "object", properties: { data: { type: "string", description: "Metrics data in Prometheus exposition format", }, }, required: ["data"], } };
  • src/index.js:127-134 (registration)
    Registration of the 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 ];
  • src/index.js:363-366 (registration)
    Dispatch case in the CallToolRequestSchema handler that extracts arguments and calls the vmPrometheusWrite handler.
    case "vm_prometheus_write": { const {data} = request.params.arguments; return await vmPrometheusWrite(data); }

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