get-monitor
Retrieve detailed configuration, status, and information for a specific Datadog monitor using its unique ID to manage monitoring settings.
Instructions
Get detailed information about a specific Datadog monitor by its ID. Use this to retrieve the complete configuration, status, and other details of a single monitor.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| monitorId | Yes |
Implementation Reference
- src/tools/getMonitor.ts:27-43 (handler)The core handler function that performs the API call to retrieve details of a specific Datadog monitor by its ID using the Datadog API client.execute: async (params: GetMonitorParams) => { try { const { monitorId } = params; const apiInstance = new v1.MonitorsApi(configuration); const apiParams: v1.MonitorsApiGetMonitorRequest = { monitorId: monitorId }; const response = await apiInstance.getMonitor(apiParams); return response; } catch (error) { console.error(`Error fetching monitor ${params.monitorId}:`, error); throw error; } }
- src/index.ts:105-117 (registration)Registers the 'get-monitor' tool with the MCP server, defining its name, description, input schema, and handler that delegates to getMonitor.execute.server.tool( "get-monitor", "Get detailed information about a specific Datadog monitor by its ID. Use this to retrieve the complete configuration, status, and other details of a single monitor.", { monitorId: z.number() }, async (args) => { const result = await getMonitor.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
- src/index.ts:108-110 (schema)Zod input schema for the 'get-monitor' tool, validating the monitorId parameter as a number.{ monitorId: z.number() },
- src/tools/getMonitor.ts:3-5 (schema)TypeScript type definition for the input parameters of the getMonitor tool.type GetMonitorParams = { monitorId: number; };
- src/tools/getMonitor.ts:10-25 (helper)Initialization function that sets up the Datadog API client configuration with API keys and site variables.initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_METRICS_SITE) { configuration.setServerVariables({ site: process.env.DD_METRICS_SITE }); } },