Skip to main content
Glama
DrDroidLab

Grafana MCP Server

grafana_fetch_all_dashboards

Retrieve all dashboards from Grafana with key details including title, UID, folder, and tags to manage and analyze monitoring setups.

Instructions

Fetches all dashboards from Grafana with basic information like title, UID, folder, tags, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of dashboards to return

Implementation Reference

  • The core implementation of the dashboard fetching logic.
    def grafana_fetch_all_dashboards(self, limit: int = 100) -> dict[str, Any]:
        """
        Fetches all dashboards from Grafana.
    
        Args:
            limit: Maximum number of dashboards to return
    
        Returns:
            Dict containing list of dashboards with basic information
        """
        try:
            url = f"{self.__host}/api/search"
            params = {"limit": limit}
            logger.info(f"Fetching all dashboards (limit: {limit})")
    
            response = requests.get(
                url,
                headers=self.headers,
                params=params,
                verify=self.__ssl_verify,
                timeout=20,
            )
    
            if response.status_code == 200:
                dashboards = response.json()
                # Extract relevant information
                dashboard_list = []
                for dashboard in dashboards:
                    dashboard_list.append(
                        {
                            "uid": dashboard.get("uid"),
                            "title": dashboard.get("title"),
                            "type": dashboard.get("type"),
                            "url": dashboard.get("url"),
                            "folder_title": dashboard.get("folderTitle"),
                            "folder_uid": dashboard.get("folderUid"),
                            "tags": dashboard.get("tags", []),
                            "is_starred": dashboard.get("isStarred", False),
                        }
                    )
    
                return {
                    "status": "success",
                    "total_count": len(dashboard_list),
                    "limit": limit,
                    "dashboards": dashboard_list,
                }
            else:
                raise Exception(f"Failed to fetch dashboards. Status: {response.status_code}, Response: {response.text}")
    
        except Exception as e:
            logger.error(f"Error fetching dashboards: {e!s}")
            raise e
  • Tool registration mapping the tool name to its handler function.
    "grafana_fetch_all_dashboards": grafana_fetch_all_dashboards,

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