Skip to main content
Glama
yanmxa

Prometheus MCP Server

by yanmxa

prom_targets

Retrieve Prometheus scrape target details by specifying their state (active, dropped, or any) to monitor and analyze system performance metrics effectively.

Instructions

Get scrape target information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNo

Implementation Reference

  • Core implementation of the prom_targets tool logic: queries Prometheus /api/v1/targets API endpoint with optional 'state' parameter.
    async targets(state?: 'active' | 'dropped' | 'any'): Promise<PrometheusResponse<TargetsResult>> { const params: Record<string, string> = {}; if (state) params.state = state; const response = await this.client.get<PrometheusResponse<TargetsResult>>('/api/v1/targets', { params }); return response.data; }
  • Dispatch handler for prom_targets in handleToolCall: validates input args and delegates to PrometheusClient.targets().
    case 'prom_targets': { if (!isPromTargetsArgs(args)) { throw new Error('Invalid arguments for prom_targets'); } const { state } = args as PromTargetsArgs; result = await prometheusClient.targets(state); break; }
  • src/tools.ts:54-64 (registration)
    Registration of 'prom_targets' tool in the exported tools array, defining name, description, and input schema.
    { name: 'prom_targets', description: 'Get scrape target information', inputSchema: { type: 'object', properties: { state: { type: 'string', enum: ['active', 'dropped', 'any'] }, }, }, }, ];
  • TypeScript interface defining the expected input arguments for prom_targets tool.
    export interface PromTargetsArgs { state?: 'active' | 'dropped' | 'any'; }
  • Runtime type guard/validator for PromTargetsArgs used in the tool handler.
    function isPromTargetsArgs(args: unknown): args is PromTargetsArgs { return typeof args === 'object' && args !== null; }

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