Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_sift_investigations

Retrieve Sift investigations from Grafana to monitor and analyze incident data, with optional limits for focused results.

Instructions

Retrieves a list of Sift investigations with an optional limit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of investigations to return

Implementation Reference

  • The handler function implementing the tool logic: creates Sift client, fetches investigations from /api/v1/investigations endpoint, formats the response, and returns it using createToolResult.
    handler: async (params, context: ToolContext) => {
      try {
        const client = createSiftClient(context.config.grafanaConfig);
        
        const response = await client.get('/api/v1/investigations', {
          params: { limit: params.limit || 10 },
        });
        
        const investigations = response.data.investigations || [];
        
        // Format the response
        const formatted = investigations.map((inv: any) => ({
          id: inv.id,
          name: inv.name,
          status: inv.status,
          createdAt: inv.created_at,
          updatedAt: inv.updated_at,
          analyses: inv.analyses?.length || 0,
        }));
        
        return createToolResult(formatted);
      } catch (error: any) {
        return createErrorResult(error.response?.data?.message || error.message);
      }
    },
  • Zod input schema for the list_sift_investigations tool, defining optional 'limit' parameter.
    const ListSiftInvestigationsSchema = z.object({
      limit: z.number().optional().describe('Maximum number of investigations to return'),
    });
  • Registers the list_sift_investigations ToolDefinition with the MCP server inside registerSiftTools function.
    server.registerTool(listSiftInvestigations);
  • Helper function used by the handler to create an Axios client instance configured for Sift API with proper auth and base URL.
    function createSiftClient(config: any) {
      const headers: any = {
        'User-Agent': 'mcp-grafana/1.0.0',
        'Content-Type': 'application/json',
      };
      
      if (config.serviceAccountToken) {
        headers['Authorization'] = `Bearer ${config.serviceAccountToken}`;
      } else if (config.apiKey) {
        headers['Authorization'] = `Bearer ${config.apiKey}`;
      }
      
      // Sift uses a different base URL pattern
      const baseUrl = config.url.replace(/\/$/, '');
      const siftUrl = baseUrl.includes('grafana.net') 
        ? baseUrl.replace('grafana.net', 'sift.grafana.net')
        : `${baseUrl}/api/plugins/grafana-sift-app/resources`;
      
      return axios.create({
        baseURL: siftUrl,
        headers,
        timeout: 60000, // Longer timeout for investigations
      });
    }
  • src/cli.ts:126-126 (registration)
    Invocation of registerSiftTools in the main CLI entrypoint, conditionally enabling and registering Sift tools including list_sift_investigations.
    registerSiftTools(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 of behavioral disclosure. It states 'Retrieves a list' but doesn't clarify if this is a read-only operation, what permissions are required, whether results are paginated, the default ordering, or error conditions. For a list tool with zero annotation coverage, this is a significant gap in transparency.

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 ('Retrieves a list of Sift investigations') and includes the key constraint ('with an optional limit'). There is no wasted verbiage, making it highly concise and well-structured for quick comprehension.

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 listing investigations (which may involve permissions, pagination, or filtering) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what an investigation entails, the return format, or behavioral aspects like rate limits. For a tool with no structured support, the description should provide more contextual detail to guide effective 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?

The description mentions an 'optional limit', which aligns with the single parameter in the input schema. Since schema description coverage is 100% (the 'limit' parameter is fully documented in the schema), the description adds minimal value beyond what the schema provides. The baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 ('Retrieves') and resource ('list of Sift investigations'), distinguishing it from sibling tools like 'get_sift_investigation' (singular) and 'get_sift_analysis'. However, it doesn't specify what 'Sift investigations' are or how they differ from general 'incidents' (e.g., in 'list_incidents'), leaving some ambiguity about the resource scope.

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 mentions an 'optional limit' but provides no guidance on when to use this tool versus alternatives like 'list_incidents' or 'get_sift_investigation'. It lacks context on prerequisites, filtering criteria, or typical use cases, leaving the agent to infer usage from the name alone.

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