get-dashboard
Retrieve the full definition of a Datadog dashboard, including widgets, layout, and configuration details, using the dashboard ID for precise monitoring and tracing.
Instructions
Get the complete definition of a specific Datadog dashboard by its ID. Returns all widgets, layout, and configuration details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboardId | Yes |
Implementation Reference
- src/tools/getDashboard.ts:27-43 (handler)The core execute function that handles the tool logic: extracts dashboardId, creates DashboardsApi instance, calls getDashboard API, and returns the response.execute: async (params: GetDashboardParams) => { try { const { dashboardId } = params; const apiInstance = new v1.DashboardsApi(configuration); const apiParams: v1.DashboardsApiGetDashboardRequest = { dashboardId: dashboardId }; const response = await apiInstance.getDashboard(apiParams); return response; } catch (error) { console.error(`Error fetching dashboard ${params.dashboardId}:`, error); throw error; } }
- src/index.ts:134-146 (registration)Registers the 'get-dashboard' tool with MCP server, providing name, description, Zod input schema, and wrapper async handler that calls getDashboard.execute and formats response.server.tool( "get-dashboard", "Get the complete definition of a specific Datadog dashboard by its ID. Returns all widgets, layout, and configuration details.", { dashboardId: z.string() }, async (args) => { const result = await getDashboard.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
- src/tools/getDashboard.ts:3-5 (schema)TypeScript type definition for the input parameters used by the getDashboard tool.type GetDashboardParams = { dashboardId: string; };
- src/tools/getDashboard.ts:10-25 (helper)Initialization function that sets up the Datadog API client configuration with API keys and site.initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_SITE) { configuration.setServerVariables({ site: process.env.DD_SITE }); } },
- src/index.ts:71-71 (registration)Calls initialize on getDashboard to setup the API client before tool usage.getDashboard.initialize();