mcp-server-datadog

by winor30
Verified
import { ExtendedTool, ToolHandlers } from '../../utils/types' import { client, v1 } from '@datadog/datadog-api-client' import { createToolSchema } from '../../utils/tool' import { GetMetricsZodSchema } from './schema' type MetricsToolName = 'get_metrics' type MetricsTool = ExtendedTool<MetricsToolName> export const METRICS_TOOLS: MetricsTool[] = [ createToolSchema( GetMetricsZodSchema, 'get_metrics', 'Get metrics data from Datadog', ), ] as const type MetricsToolHandlers = ToolHandlers<MetricsToolName> export const createMetricsToolHandlers = ( config: client.Configuration, ): MetricsToolHandlers => { const apiInstance = new v1.MetricsApi(config) return { get_metrics: async (request) => { const { from, to, query } = GetMetricsZodSchema.parse( request.params.arguments, ) const response = await apiInstance.queryMetrics({ from, to, query, }) return { content: [ { type: 'text', text: `Metrics data: ${JSON.stringify({ response })}`, }, ], } }, } }