get_dashboard_by_uid
Retrieve a complete Grafana dashboard with all panels, variables, and settings using the dashboard's unique identifier (UID).
Instructions
Retrieves the complete dashboard, including panels, variables, and settings, for a specific dashboard identified by its UID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | The UID of the dashboard |
Input Schema (JSON Schema)
{
"properties": {
"uid": {
"description": "The UID of the dashboard",
"type": "string"
}
},
"required": [
"uid"
],
"type": "object"
}
Implementation Reference
- src/tools/dashboard.ts:38-51 (handler)The main handler implementation for the get_dashboard_by_uid tool, which creates a GrafanaClient instance and fetches the dashboard by UID.export const getDashboardByUid: ToolDefinition = { name: 'get_dashboard_by_uid', description: 'Retrieves the complete dashboard, including panels, variables, and settings, for a specific dashboard identified by its UID', inputSchema: GetDashboardByUidSchema, handler: async (params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const dashboard = await client.getDashboardByUid(params.uid); return createToolResult(dashboard); } catch (error: any) { return createErrorResult(error.message); } }, };
- src/tools/dashboard.ts:7-9 (schema)Zod schema defining the input parameters for the tool (uid: string).const GetDashboardByUidSchema = z.object({ uid: z.string().describe('The UID of the dashboard'), });
- src/tools/dashboard.ts:190-196 (registration)Registration function that registers the get_dashboard_by_uid tool (and others) with the MCP server. Called from src/cli.ts.export function registerDashboardTools(server: any) { server.registerTool(getDashboardByUid); server.registerTool(getDashboardSummary); server.registerTool(getDashboardProperty); server.registerTool(getDashboardPanelQueries); server.registerTool(updateDashboard); }
- src/clients/grafana-client.ts:65-72 (helper)GrafanaClient helper method that performs the actual API call to retrieve the dashboard by UID from Grafana.async getDashboardByUid(uid: string): Promise<Dashboard> { try { const response = await this.client.get(`/api/dashboards/uid/${uid}`); return response.data.dashboard; } catch (error) { this.handleError(error); } }
- src/cli.ts:101-102 (registration)Call to registerDashboardTools in the main CLI entrypoint, conditionally enabling dashboard tools including get_dashboard_by_uid.if (enabledTools.has('dashboard')) { registerDashboardTools(server);