Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

get_incident

Retrieve detailed information about a specific Grafana incident using its unique ID to access full incident data for monitoring and analysis.

Instructions

Get a single incident by ID. Returns the full incident details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the incident to retrieve

Implementation Reference

  • The main handler for the 'get_incident' tool, which creates an API client and fetches the incident details by ID using Grafana IncidentService.
    export const getIncident: ToolDefinition = {
      name: 'get_incident',
      description: 'Get a single incident by ID. Returns the full incident details',
      inputSchema: GetIncidentSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = createIncidentClient(context.config.grafanaConfig);
          const response = await client.get(`/IncidentService.GetIncident`, {
            params: { incidentID: params.id },
          });
          
          return createToolResult(response.data.incident);
        } catch (error: any) {
          return createErrorResult(error.response?.data?.message || error.message);
        }
      },
    };
  • Zod input schema for 'get_incident' tool, defining the required 'id' parameter.
    const GetIncidentSchema = z.object({
      id: z.string().describe('The ID of the incident to retrieve'),
    });
  • Registration function that registers the 'getIncident' tool (and others) 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 the Axios client for Grafana Incident API, used by the get_incident handler.
    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,
      });
    }

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