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
| Name | Required | Description | Default |
|---|---|---|---|
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}"} - src/grafana_mcp_server/mcp_server.py:263-267 (registration)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": []}, },