Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

get_alert_rule_by_uid

Retrieve the complete configuration and detailed status of a Grafana alert rule using its unique identifier to inspect rule settings and current state.

Instructions

Retrieves the full configuration and detailed status of a specific Grafana alert rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesThe uid of the alert rule

Implementation Reference

  • The main tool handler implementation, which creates a GrafanaClient and calls getAlertRuleByUid on it with the provided UID.
    export const getAlertRuleByUid: ToolDefinition = { name: 'get_alert_rule_by_uid', description: 'Retrieves the full configuration and detailed status of a specific Grafana alert rule', inputSchema: GetAlertRuleByUidSchema, handler: async (params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const rule = await client.getAlertRuleByUid(params.uid); return createToolResult(rule); } catch (error: any) { return createErrorResult(error.message); } }, };
  • Zod schema defining the input parameters for the tool (uid: string).
    const GetAlertRuleByUidSchema = z.object({ uid: z.string().describe('The uid of the alert rule'), });
  • Function that registers the alerting tools, including get_alert_rule_by_uid, to the MCP server.
    export function registerAlertingTools(server: any) { server.registerTool(listAlertRules); server.registerTool(getAlertRuleByUid); server.registerTool(listContactPoints); }
  • Helper method in GrafanaClient that performs the actual API call to retrieve the alert rule by UID.
    async getAlertRuleByUid(uid: string): Promise<AlertRule> { try { const response = await this.client.get(`/api/v1/provisioning/alert-rules/${uid}`); return response.data; } catch (error) { this.handleError(error); } }

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/0xteamhq/mcp-grafana'

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