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);
    }
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 this adds a note to an incident's timeline, implying a write/mutation operation, but lacks details on permissions required, whether the operation is idempotent, rate limits, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is insufficient.

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 ('Add a note') and resource details. There is no wasted wording, 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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., side effects, error handling) and does not explain return values or success indicators, which are critical for an agent to use this tool effectively.

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 schema already documents all three parameters (incidentId, body, eventTime) with their types and requirements. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, meeting the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('Add a note'), the resource type ('userNote activity'), and the target ('to an existing incident's timeline'). It distinguishes this from sibling tools like 'create_incident' (which creates incidents) and 'get_incident' (which retrieves incidents), making the purpose unambiguous.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., incident must exist), exclusions, or compare it to other note-adding or incident-update tools, leaving usage context unclear.

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