Skip to main content
Glama
DrDroidLab

Grafana MCP Server

test_connection

Verify Grafana API connectivity and configuration to ensure proper integration with the MCP server.

Instructions

Test connection to Grafana API to verify configuration and connectivity. Requires API key or open Grafana instance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the `test_connection` method within the `GrafanaApiProcessor` class, which verifies connectivity to the Grafana API by querying the `/api/datasources` endpoint.
    def test_connection(self):
        """
        Test connection to Grafana API to verify configuration and connectivity.
        Uses the /api/datasources endpoint to verify API access.
    
        Returns:
            bool: True if connection successful
    
        Raises:
            Exception: If connection fails with details about the failure
        """
        try:
            url = f"{self.__host}/api/datasources"
            logger.info(f"Testing Grafana connection to: {url}")
    
            response = requests.get(url, headers=self.headers, verify=self.__ssl_verify, timeout=20)
            if response and response.status_code == 200:
                logger.info("Successfully connected to Grafana API")
                return True
            else:
                status_code = response.status_code if response else None
                raise Exception(f"Failed to connect with Grafana. Status Code: {status_code}. Response Text: {response.text}")
        except Exception as e:
            logger.error(f"Exception occurred while fetching grafana data sources with error: {e}")
            raise e
Behavior3/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 discloses that authentication ('API key or open Grafana instance') is required, which is useful behavioral context. However, it doesn't describe what the tool actually does behaviorally (e.g., makes a test request, returns success/failure, handles errors) or any other traits like rate limits or side effects, leaving gaps 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 two concise sentences that are front-loaded with the core purpose and essential requirement. Every sentence earns its place by providing critical information without redundancy or fluff, making it efficient and well-structured.

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?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is somewhat complete but lacks details on behavioral aspects. It covers the purpose and authentication need but doesn't explain what the test entails or what to expect in return, which could be helpful for an agent to understand the tool's operation fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description adds no parameter information, which is appropriate here. Baseline is 4 for 0 parameters, as no compensation is needed, and the description doesn't detract from the schema.

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 tool's purpose: 'Test connection to Grafana API to verify configuration and connectivity.' It specifies the verb ('test connection'), resource ('Grafana API'), and goal ('verify configuration and connectivity'). However, it doesn't explicitly differentiate from sibling tools, which are all data-fetching operations, making this a distinct connectivity check tool.

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 by stating 'Requires API key or open Grafana instance,' suggesting it should be used when authentication or connectivity needs verification. However, it doesn't provide explicit guidance on when to use this tool versus alternatives (e.g., before invoking other Grafana tools) or any exclusions, leaving usage somewhat inferred rather than clearly defined.

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

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