Skip to main content
Glama

mcp-server-datadog

Apache 2.0
4,489
103
  • Apple
tool.ts2.84 kB
import { ExtendedTool, ToolHandlers } from '../../utils/types' import { v1 } from '@datadog/datadog-api-client' import { createToolSchema } from '../../utils/tool' import { ListDowntimesZodSchema, ScheduleDowntimeZodSchema, CancelDowntimeZodSchema, } from './schema' type DowntimesToolName = | 'list_downtimes' | 'schedule_downtime' | 'cancel_downtime' type DowntimesTool = ExtendedTool<DowntimesToolName> export const DOWNTIMES_TOOLS: DowntimesTool[] = [ createToolSchema( ListDowntimesZodSchema, 'list_downtimes', 'List scheduled downtimes from Datadog', ), createToolSchema( ScheduleDowntimeZodSchema, 'schedule_downtime', 'Schedule a downtime in Datadog', ), createToolSchema( CancelDowntimeZodSchema, 'cancel_downtime', 'Cancel a scheduled downtime in Datadog', ), ] as const type DowntimesToolHandlers = ToolHandlers<DowntimesToolName> export const createDowntimesToolHandlers = ( apiInstance: v1.DowntimesApi, ): DowntimesToolHandlers => { return { list_downtimes: async (request) => { const { currentOnly } = ListDowntimesZodSchema.parse( request.params.arguments, ) const res = await apiInstance.listDowntimes({ currentOnly, }) return { content: [ { type: 'text', text: `Listed downtimes:\n${JSON.stringify(res, null, 2)}`, }, ], } }, schedule_downtime: async (request) => { const params = ScheduleDowntimeZodSchema.parse(request.params.arguments) // Convert to the format expected by Datadog client const downtimeData: v1.Downtime = { scope: [params.scope], start: params.start, end: params.end, message: params.message, timezone: params.timezone, monitorId: params.monitorId, monitorTags: params.monitorTags, } // Add recurrence configuration if provided if (params.recurrence) { downtimeData.recurrence = { type: params.recurrence.type, period: params.recurrence.period, weekDays: params.recurrence.weekDays, } } const res = await apiInstance.createDowntime({ body: downtimeData, }) return { content: [ { type: 'text', text: `Scheduled downtime: ${JSON.stringify(res, null, 2)}`, }, ], } }, cancel_downtime: async (request) => { const { downtimeId } = CancelDowntimeZodSchema.parse( request.params.arguments, ) await apiInstance.cancelDowntime({ downtimeId, }) return { content: [ { type: 'text', text: `Cancelled downtime with ID: ${downtimeId}`, }, ], } }, } }

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/winor30/mcp-server-datadog'

If you have feedback or need assistance with the MCP directory API, please join our Discord server