Skip to main content
Glama
yanmxa

Prometheus MCP Server

by yanmxa

prom_query

Execute PromQL instant queries to retrieve real-time Prometheus metrics for system monitoring and performance analysis.

Instructions

Execute a PromQL instant query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL query expression
timeNoEvaluation timestamp (optional)
includesNoMetric properties to include in response (optional)

Implementation Reference

  • Handler logic for 'prom_query' tool: validates input arguments using isPromQueryArgs and executes the query via prometheusClient.query.
    case 'prom_query': {
      if (!isPromQueryArgs(args)) {
        throw new Error('Invalid arguments for prom_query');
      }
      const { query, time, includes } = args;
      result = await prometheusClient.query(query, time, includes);
      break;
  • src/tools.ts:11-23 (registration)
    Registration of the 'prom_query' tool in the exported tools array, defining name, description, and input schema.
    {
      name: 'prom_query',
      description: 'Execute a PromQL instant query',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'PromQL query expression' },
          time: { type: 'string', description: 'Evaluation timestamp (optional)' },
          includes: { type: 'array', items: { type: 'string' }, description: 'Metric properties to include in response (optional)' },
        },
        required: ['query'],
      },
    },
  • TypeScript interface defining the expected arguments for prom_query, matching the input schema.
    export interface PromQueryArgs {
      query: string;
      time?: string;
      includes?: string[];
    }
  • Type guard helper function to validate if arguments match PromQueryArgs structure.
    function isPromQueryArgs(args: unknown): args is PromQueryArgs {
      return typeof args === 'object' && args !== null && 'query' in args;
    }

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