get-monitor
Retrieve detailed configuration, status, and information for a specific Datadog monitor by its ID. Use this to access and manage individual monitor data efficiently.
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)Core handler logic for the 'get-monitor' tool: destructures monitorId, creates MonitorsApi instance, calls getMonitor API, and returns the response or throws error.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' MCP tool with name, description, input schema (monitorId: number), and thin wrapper that calls getMonitor.execute and formats response.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/tools/getMonitor.ts:3-5 (schema)TypeScript type definition for input parameters used in the handler.type GetMonitorParams = { monitorId: number; };
- src/tools/getMonitor.ts:10-25 (helper)Initialization function sets up Datadog 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_METRICS_SITE) { configuration.setServerVariables({ site: process.env.DD_METRICS_SITE }); } },
- src/index.ts:69-69 (registration)Calls initialize on getMonitor during server setup.getMonitor.initialize();