Skip to main content
Glama

annotate_test

Add Grafana annotations for test events on sensors, including start/end times, results, and rate changes. Supports range annotations and dashboard linking with default ramp-test tagging.

Instructions

Add a Grafana annotation on a sensor for test events (start/end/result/rate change). Supports range annotations and dashboard association. Tagged with ramp-test by default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sensorNoSensor hostname
textYesAnnotation text
tagsNoAnnotation tags (e.g., ["ramp-test", "ns2"])
timeNoAnnotation epoch timestamp (defaults to now)
timeEndNoEnd epoch timestamp for range annotations
dashboardUidNoDashboard UID to associate annotation with

Implementation Reference

  • The annotateTest service method that executes the core logic: resolves the sensor, constructs the annotation body with text/tags/time, and makes a POST request to the Grafana API endpoint '/api/annotations'
    async annotateTest(options: {
      sensor?: string;
      text: string;
      tags?: string[];
      time?: number;
      timeEnd?: number;
      dashboardUid?: string;
    }): Promise<{ id: number }> {
      const { info, client } = this.resolveSensor(options.sensor);
      const now = Date.now();
      const body: Record<string, any> = {
        text: options.text,
        tags: options.tags ?? ['ramp-test'],
        time: options.time ?? now,
      };
      if (options.timeEnd) body.timeEnd = options.timeEnd;
      if (options.dashboardUid) body.dashboardUID = options.dashboardUid;
    
      const result = await client.post<{ id: number }>('/api/annotations', body);
      return result;
    }
  • AnnotateTestSchema Zod schema defining the input validation for the tool with fields: sensor (optional), text (required), tags (optional array), time (optional), timeEnd (optional), and dashboardUid (optional)
    export const AnnotateTestSchema = z.object({
      sensor: z.string().optional().describe('Sensor hostname'),
      text: z.string().min(1).describe('Annotation text'),
      tags: z.array(z.string()).optional().describe('Annotation tags (e.g., ["ramp-test", "ns2"])'),
      time: z.number().optional().describe('Annotation epoch timestamp (defaults to now)'),
      timeEnd: z.number().optional().describe('End epoch timestamp for range annotations'),
      dashboardUid: z.string().optional().describe('Dashboard UID to associate annotation with'),
    });
  • Tool registration for 'annotate_test' that defines the tool metadata, parses input using AnnotateTestSchema, calls the rampService.annotateTest method, and handles errors with appropriate response formatting
    // 7. annotate_test
    registry.registerTool(
      {
        name: 'annotate_test',
        description:
          'Add a Grafana annotation on a sensor for test events ' +
          '(start/end/result/rate change). Supports range annotations and dashboard association. Tagged with ramp-test by default.',
        inputSchema: zodToJsonSchema(AnnotateTestSchema),
      },
      async (request) => {
        try {
          const params = AnnotateTestSchema.parse(request.params.arguments);
          const result = await rampService.annotateTest({
            sensor: params.sensor,
            text: params.text,
            tags: params.tags,
            time: params.time,
            timeEnd: params.timeEnd,
            dashboardUid: params.dashboardUid,
          });
    
          return {
            content: [
              {
                type: 'text',
                text: `Annotation created (id: ${result.id})`,
              },
            ],
          };
        } catch (error) {
          const msg = error instanceof Error ? error.message : 'Unknown error';
          return {
            content: [{ type: 'text', text: `Error creating annotation: ${msg}` }],
            isError: true,
          };
        }
      },
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool 'Supports range annotations and dashboard association' and has a default tag, which adds useful behavioral context beyond the basic 'add' action. However, it doesn't cover important aspects like permissions needed, whether annotations are editable/deletable, or response format, leaving gaps for a mutation tool.

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

Conciseness4/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 and includes key features. Every clause adds value (e.g., event types, range support, default tag), with no redundant or vague phrasing, though it could be slightly more structured for clarity.

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?

For a mutation tool with no annotations and no output schema, the description is moderately complete. It covers the tool's purpose and some behavioral traits but lacks details on permissions, error handling, or return values. Given the complexity of creating annotations with multiple parameters, more context would be beneficial to fully guide the agent.

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 fully documents all 6 parameters. The description adds minimal value beyond the schema by mentioning 'range annotations' (hinting at time/timeEnd usage) and 'dashboard association' (hinting at dashboardUid), but doesn't provide additional syntax or format details. This meets the baseline for high schema coverage.

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 action ('Add a Grafana annotation') and resource ('on a sensor for test events'), with specific event types listed (start/end/result/rate change). It distinguishes from sibling tools by focusing on annotation creation rather than querying or dashboard management, though it doesn't explicitly name alternatives for similar annotation tasks.

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 'for test events' and 'Tagged with ramp-test by default,' suggesting it's designed for test-related annotations. However, it doesn't provide explicit guidance on when to use this versus other annotation methods or tools, nor does it mention prerequisites or exclusions.

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/quanticsoul4772/grafana-mcp'

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