Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

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

NameRequiredDescriptionDefault
uidYesThe UID of the dashboard

Input Schema (JSON Schema)

{ "properties": { "uid": { "description": "The UID of the dashboard", "type": "string" } }, "required": [ "uid" ], "type": "object" }

Implementation Reference

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

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