Skip to main content
Glama
yincongcyincong

VictoriaMetrics-mcp-server

vm_prometheus_write

Import Prometheus exposition format data into VictoriaMetrics for efficient metric storage and analysis. Simplify data ingestion with structured JSON input.

Instructions

mport Prometheus exposition format data into VictoriaMetrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesMetrics data in Prometheus exposition format

Implementation Reference

  • The main handler function that sends the provided Prometheus exposition format data via POST to the VictoriaMetrics /api/v1/import/prometheus endpoint.
    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 }; } }
  • The tool definition object including name, description, and inputSchema requiring a 'data' string.
    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)
    The VM_TOOLS array that registers all tools, including VM_PROMETHEUS_WRITE_TOOL, returned by 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 ];
  • src/index.js:363-366 (registration)
    The switch case in the CallToolRequestSchema handler that dispatches to the vmPrometheusWrite function.
    case "vm_prometheus_write": { const {data} = request.params.arguments; return await vmPrometheusWrite(data); }
  • src/index.js:338-340 (registration)
    The request handler for listing tools, which returns the VM_TOOLS array containing this tool.
    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