Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

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
NameRequiredDescriptionDefault
uidYesThe UID of the dashboard

Implementation Reference

  • 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); } },
  • Zod input schema validation for the tool, requiring a dashboard UID.
    const GetDashboardPanelQueriesSchema = z.object({ uid: z.string().describe('The UID of the dashboard'), });
  • 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); }

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/0xteamhq/mcp-grafana'

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