Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

add_activity_to_incident

Add a note to an existing incident's timeline to document updates, observations, or actions taken during incident management.

Instructions

Add a note (userNote activity) to an existing incident's timeline

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyYesThe body of the activity
eventTimeNoThe time that the activity occurred
incidentIdYesThe ID of the incident to add activity to

Implementation Reference

  • The ToolDefinition object for 'add_activity_to_incident', including the async handler function that uses an axios client to POST activity data to the Grafana IncidentService.AddActivity API endpoint.
    export const addActivityToIncident: ToolDefinition = { name: 'add_activity_to_incident', description: 'Add a note (userNote activity) to an existing incident\'s timeline', inputSchema: AddActivityToIncidentSchema, handler: async (params, context: ToolContext) => { try { const client = createIncidentClient(context.config.grafanaConfig); const activityData: any = { incidentID: params.incidentId, activityKind: 'userNote', body: params.body, }; if (params.eventTime) { activityData.eventTime = params.eventTime; } const response = await client.post('/IncidentService.AddActivity', activityData); return createToolResult({ success: true, message: 'Activity added to incident', activityID: response.data.activityID, }); } catch (error: any) { return createErrorResult(error.response?.data?.message || error.message); } }, };
  • Zod input schema defining parameters for the tool: incidentId (required), body (required), eventTime (optional).
    const AddActivityToIncidentSchema = z.object({ incidentId: z.string().describe('The ID of the incident to add activity to'), body: z.string().describe('The body of the activity'), eventTime: z.string().optional().describe('The time that the activity occurred'), });
  • Function that registers the 'add_activity_to_incident' tool (along with related incident tools) by calling server.registerTool.
    export function registerIncidentTools(server: any) { server.registerTool(listIncidents); server.registerTool(getIncident); server.registerTool(createIncident); server.registerTool(addActivityToIncident); }
  • Helper function to create an authenticated axios HTTP client for the Grafana Incident API, used by the tool 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, }); }
  • src/cli.ts:113-115 (registration)
    Call to registerIncidentTools in the main server startup code when the 'incident' tool category is enabled.
    if (enabledTools.has('incident')) { registerIncidentTools(server); }

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