get_dashboard_panel_queries
Retrieve panel queries and information from a Grafana dashboard using its UID to access monitoring data and query configurations.
Instructions
Retrieve panel queries and information from a Grafana dashboard
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | The UID of the dashboard |
Implementation Reference
- src/tools/dashboard.ts:110-130 (handler)The handler function that executes the tool logic: fetches the dashboard by UID using GrafanaClient, extracts panels, maps them to titles, IDs, and their query targets (expr/query/rawSql, datasource, refId), and returns the structured queries.handler: async (params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const dashboard = await client.getDashboardByUid(params.uid); const panels = dashboard.panels || []; const queries = panels.map((panel: any) => ({ title: panel.title, panelId: panel.id, queries: panel.targets?.map((target: any) => ({ query: target.expr || target.query || target.rawSql || '', datasource: target.datasource, refId: target.refId, })) || [], })); return createToolResult(queries); } catch (error: any) { return createErrorResult(error.message); } },
- src/tools/dashboard.ts:20-22 (schema)Zod input schema validation for the tool, requiring a dashboard UID.const GetDashboardPanelQueriesSchema = z.object({ uid: z.string().describe('The UID of the dashboard'), });
- src/tools/dashboard.ts:190-196 (registration)Registration function that adds the getDashboardPanelQueries tool (along with other dashboard tools) to the MCP server instance.export function registerDashboardTools(server: any) { server.registerTool(getDashboardByUid); server.registerTool(getDashboardSummary); server.registerTool(getDashboardProperty); server.registerTool(getDashboardPanelQueries); server.registerTool(updateDashboard); }