Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_incidents

Retrieve Grafana incidents with filtering options for status and drill incidents to monitor and manage system alerts effectively.

Instructions

List Grafana incidents. Allows filtering by status and optionally including drill incidents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drillNoWhether to include drill incidents
limitNoMaximum number of incidents to return
statusNoThe status of incidents to include

Implementation Reference

  • The listIncidents tool definition, including the async handler function that creates an API client, queries incidents with optional filters, formats the response, and handles errors.
    export const listIncidents: ToolDefinition = {
      name: 'list_incidents',
      description: 'List Grafana incidents. Allows filtering by status and optionally including drill incidents',
      inputSchema: ListIncidentsSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = createIncidentClient(context.config.grafanaConfig);
          
          const queryParams: any = {};
          if (params.status) queryParams.status = params.status;
          if (params.drill !== undefined) queryParams.includeDrills = params.drill;
          if (params.limit) queryParams.limit = params.limit;
          
          const response = await client.get('/IncidentService.QueryIncidents', { params: queryParams });
          
          const incidents = response.data.incidents || [];
          
          // Format the response
          const formatted = incidents.map((incident: any) => ({
            incidentID: incident.incidentID,
            title: incident.title,
            status: incident.status,
            severity: incident.severity,
            createdTime: incident.createdTime,
            modifiedTime: incident.modifiedTime,
            labels: incident.labels,
          }));
          
          return createToolResult(formatted);
        } catch (error: any) {
          return createErrorResult(error.response?.data?.message || error.message);
        }
      },
    };
  • Zod input schema defining optional parameters for filtering incidents by status, drill flag, and limit.
    const ListIncidentsSchema = z.object({
      status: z.enum(['active', 'resolved']).optional().describe('The status of incidents to include'),
      drill: z.boolean().optional().describe('Whether to include drill incidents'),
      limit: z.number().optional().describe('Maximum number of incidents to return'),
    });
  • Function to register the list_incidents tool (along with related incident tools) with the MCP server.
    export function registerIncidentTools(server: any) {
      server.registerTool(listIncidents);
      server.registerTool(getIncident);
      server.registerTool(createIncident);
      server.registerTool(addActivityToIncident);
    }
  • Helper function to create a configured axios client for making requests to the Grafana Incident API.
    function createIncidentClient(config: any) {
      const headers: any = {
        'User-Agent': 'mcp-grafana/1.0.0',
      };
      
      if (config.serviceAccountToken) {
        headers['Authorization'] = `Bearer ${config.serviceAccountToken}`;
      } else if (config.apiKey) {
        headers['Authorization'] = `Bearer ${config.apiKey}`;
      }
      
      return axios.create({
        baseURL: `${config.url}/api/plugins/grafana-incident-app/resources/api/v1`,
        headers,
        timeout: 30000,
      });
    }
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 of behavioral disclosure. It mentions filtering capabilities (status, drill incidents) and implies a listing operation, but fails to describe critical behaviors such as pagination (though 'limit' parameter hints at it), return format, ordering, error handling, or any rate limits. For a list tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 core purpose ('List Grafana incidents') and immediately adds key filtering details. Every word earns its place, with no redundant or vague phrasing, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity of a list operation with filtering, no annotations, and no output schema, the description is incomplete. It lacks information on return values (e.g., structure of incident objects), pagination beyond the 'limit' parameter, error cases, or any behavioral nuances. While it covers basic filtering, it doesn't compensate for the absence of structured output or annotation data, leaving the agent with insufficient context for reliable use.

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?

Schema description coverage is 100%, so the input schema already documents all parameters (drill, limit, status) with descriptions and enums. The description adds marginal value by mentioning 'filtering by status and optionally including drill incidents,' which aligns with the schema but doesn't provide additional syntax, format details, or context beyond what's already structured. Baseline 3 is appropriate when the schema does the heavy lifting.

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 ('List') and resource ('Grafana incidents'), making the purpose immediately understandable. It distinguishes itself from sibling tools like 'get_incident' (singular retrieval) by indicating it returns multiple incidents. However, it doesn't explicitly differentiate from other list tools (e.g., 'list_alert_rules') beyond the resource type.

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 context through 'Allows filtering by status and optionally including drill incidents,' suggesting when to use it for filtered listings. However, it doesn't provide explicit guidance on when to choose this tool over alternatives like 'get_incident' for single incidents or other list tools for different resources, nor does it mention any exclusions or prerequisites.

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