Skip to main content
Glama
yanmxa

Prometheus MCP Server

by yanmxa

prom_range

Execute a PromQL range query to retrieve time-series data between specified start and end timestamps, with a defined step interval, using Prometheus MCP Server.

Instructions

Execute a PromQL range query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endYesEnd timestamp
includesNoMetric properties to include in response (optional)
queryYesPromQL query expression
startYesStart timestamp
stepYesStep interval (e.g., "15s", "1m")

Implementation Reference

  • Handler logic for the 'prom_range' tool in handleToolCall function: validates input and delegates to PrometheusClient.range.
    case 'prom_range': { if (!isPromRangeArgs(args)) { throw new Error('Invalid arguments for prom_range'); } const { query, start, end, step, includes } = args; result = await prometheusClient.range(query, start, end, step, includes); break;
  • Core execution logic for prom_range: performs HTTP GET to Prometheus /api/v1/query_range API with filtering.
    async range(query: string, start: string, end: string, step: string, includes?: string[]): Promise<PrometheusResponse<QueryResult>> { const response = await this.client.get<PrometheusResponse<QueryResult>>('/api/v1/query_range', { params: { query, start, end, step }, timeout: 30000, }); if (response.data.data && includes) { response.data.data = this.filterQueryResult(response.data.data, includes); } return response.data; }
  • TypeScript interface defining the structure of arguments for prom_range tool.
    export interface PromRangeArgs { query: string; start: string; end: string; step: string; includes?: string[]; }
  • src/tools.ts:24-37 (registration)
    Tool registration entry for 'prom_range' including name, description, and JSON input schema.
    { name: 'prom_range', description: 'Execute a PromQL range query', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'PromQL query expression' }, start: { type: 'string', description: 'Start timestamp' }, end: { type: 'string', description: 'End timestamp' }, step: { type: 'string', description: 'Step interval (e.g., "15s", "1m")' }, includes: { type: 'array', items: { type: 'string' }, description: 'Metric properties to include in response (optional)' }, }, required: ['query', 'start', 'end', 'step'], },
  • Type guard helper to validate if arguments match PromRangeArgs structure.
    function isPromRangeArgs(args: unknown): args is PromRangeArgs { return typeof args === 'object' && args !== null && 'query' in args && 'start' in args && 'end' in args && 'step' in args;

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/yanmxa/prometheus-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server