Skip to main content
Glama
DrDroidLab

Grafana MCP Server

grafana_fetch_datasources

Retrieve all configured data sources and their settings from Grafana to manage connections and monitor data integrations.

Instructions

Fetches all datasources from Grafana with their configuration details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation that makes the HTTP request to the Grafana API to fetch datasources.
    def grafana_fetch_datasources(self) -> dict[str, Any]:
        """
        Fetches all datasources from Grafana.
    
        Returns:
            Dict containing list of datasources
        """
        try:
            url = f"{self.__host}/api/datasources"
            logger.info("Fetching all datasources")
    
            response = requests.get(url, headers=self.headers, verify=self.__ssl_verify, timeout=20)
    
            if response.status_code == 200:
  • The wrapper function in the MCP server that interfaces with the processor to call the tool.
    def grafana_fetch_datasources():
        """Fetch all datasources from Grafana"""
        try:
            grafana_processor = current_app.config.get("grafana_processor")
            if not grafana_processor:
                return {
                    "status": "error",
                    "message": "Grafana processor not initialized. Check configuration.",
                }
    
            result = grafana_processor.grafana_fetch_datasources()
            return result
        except Exception as e:
            logger.error(f"Error fetching datasources: {e!s}")
            return {"status": "error", "message": f"Failed to fetch datasources: {e!s}"}
  • The tool definition/registration in the MCP server list.
    {
        "name": "grafana_fetch_datasources",
        "description": "Fetches all datasources from Grafana with their configuration details.",
        "inputSchema": {"type": "object", "properties": {}, "required": []},
    },

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