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);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool retrieves configuration and status, implying a read-only operation, but doesn't disclose behavioral traits like authentication requirements, rate limits, error handling, or what 'detailed status' includes. The description is minimal and lacks context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key action ('Retrieves') and resource. There is no wasted language, and it directly communicates the tool's function without unnecessary elaboration, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no nested objects) and 100% schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it lacks details on return values, error cases, or operational constraints. For a retrieval tool, this leaves gaps in understanding the full context, though it meets basic requirements.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'uid' parameter documented as 'The uid of the alert rule'. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or where to obtain the UID. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieves') and resource ('full configuration and detailed status of a specific Grafana alert rule'), making the purpose unambiguous. It distinguishes from sibling 'list_alert_rules' by specifying retrieval of a single rule by UID rather than listing multiple rules. However, it doesn't explicitly contrast with other alert-related tools beyond the sibling list.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when detailed information about a specific alert rule is needed, as opposed to 'list_alert_rules' for multiple rules. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_assertions' or 'get_sift_investigation', nor does it mention prerequisites such as needing the rule's UID from prior listing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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