Skip to main content
Glama

mcp-server-datadog

Apache 2.0
4,489
103
  • Apple
tool.ts1.86 kB
import { ExtendedTool, ToolHandlers } from '../../utils/types' import { v2 } from '@datadog/datadog-api-client' import { createToolSchema } from '../../utils/tool' import { ListTracesZodSchema } from './schema' type TracesToolName = 'list_traces' type TracesTool = ExtendedTool<TracesToolName> export const TRACES_TOOLS: TracesTool[] = [ createToolSchema( ListTracesZodSchema, 'list_traces', 'Get APM traces from Datadog', ), ] as const type TracesToolHandlers = ToolHandlers<TracesToolName> export const createTracesToolHandlers = ( apiInstance: v2.SpansApi, ): TracesToolHandlers => { return { list_traces: async (request) => { const { query, from, to, limit = 100, sort = '-timestamp', service, operation, } = ListTracesZodSchema.parse(request.params.arguments) const response = await apiInstance.listSpans({ body: { data: { attributes: { filter: { query: [ query, ...(service ? [`service:${service}`] : []), ...(operation ? [`operation:${operation}`] : []), ].join(' '), from: new Date(from * 1000).toISOString(), to: new Date(to * 1000).toISOString(), }, sort: sort as 'timestamp' | '-timestamp', page: { limit }, }, type: 'search_request', }, }, }) if (!response.data) { throw new Error('No traces data returned') } return { content: [ { type: 'text', text: `Traces: ${JSON.stringify({ traces: response.data, count: response.data.length, })}`, }, ], } }, } }

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