datadog-mcp 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21,7 +21,8 @@ var ALL_TOOLS = [
21
21
  "teams",
22
22
  "tags",
23
23
  "usage",
24
- "auth"
24
+ "auth",
25
+ "schema"
25
26
  ];
26
27
  var configSchema = z.object({
27
28
  datadog: z.object({
@@ -1248,8 +1249,8 @@ async function enrichWithMonitorMetadata(events, monitorsApi) {
1248
1249
  const response = await monitorsApi.listMonitors({
1249
1250
  pageSize: 1e3
1250
1251
  });
1251
- const monitors = response ?? [];
1252
- for (const monitor of monitors) {
1252
+ const monitors2 = response ?? [];
1253
+ for (const monitor of monitors2) {
1253
1254
  if (monitor.id && monitorIds.has(monitor.id)) {
1254
1255
  monitorCache.set(monitor.id, monitor);
1255
1256
  }
@@ -1525,7 +1526,7 @@ async function listMonitors(api, params, limits, site) {
1525
1526
  tags: params.tags?.join(","),
1526
1527
  groupStates: params.groupStates?.join(",")
1527
1528
  });
1528
- const monitors = response.slice(0, effectiveLimit).map((m) => formatMonitor(m, site));
1529
+ const monitors2 = response.slice(0, effectiveLimit).map((m) => formatMonitor(m, site));
1529
1530
  const statusCounts = {
1530
1531
  total: response.length,
1531
1532
  alert: response.filter((m) => m.overallState === "Alert").length,
@@ -1534,7 +1535,7 @@ async function listMonitors(api, params, limits, site) {
1534
1535
  noData: response.filter((m) => m.overallState === "No Data").length
1535
1536
  };
1536
1537
  return {
1537
- monitors,
1538
+ monitors: monitors2,
1538
1539
  summary: statusCounts,
1539
1540
  datadog_url: buildMonitorsListUrl(
1540
1541
  { name: params.name, tags: params.tags, groupStates: params.groupStates },
@@ -1555,7 +1556,7 @@ async function getMonitor(api, id, site) {
1555
1556
  }
1556
1557
  async function searchMonitors(api, query, limits, site) {
1557
1558
  const response = await api.searchMonitors({ query });
1558
- const monitors = (response.monitors ?? []).map((m) => ({
1559
+ const monitors2 = (response.monitors ?? []).map((m) => ({
1559
1560
  id: m.id ?? 0,
1560
1561
  name: m.name ?? "",
1561
1562
  status: String(m.status ?? "unknown"),
@@ -1564,9 +1565,9 @@ async function searchMonitors(api, query, limits, site) {
1564
1565
  url: buildMonitorUrl(m.id ?? 0, site)
1565
1566
  }));
1566
1567
  return {
1567
- monitors,
1568
+ monitors: monitors2,
1568
1569
  metadata: {
1569
- totalCount: response.metadata?.totalCount ?? monitors.length,
1570
+ totalCount: response.metadata?.totalCount ?? monitors2.length,
1570
1571
  pageCount: response.metadata?.pageCount ?? 1,
1571
1572
  page: response.metadata?.page ?? 0
1572
1573
  },
@@ -1908,12 +1909,12 @@ async function listDashboards(api, params, limits) {
1908
1909
  const response = await api.listDashboards({
1909
1910
  filterShared: false
1910
1911
  });
1911
- let dashboards = response.dashboards ?? [];
1912
+ let dashboards2 = response.dashboards ?? [];
1912
1913
  if (params.name) {
1913
1914
  const lowerName = params.name.toLowerCase();
1914
- dashboards = dashboards.filter((d) => d.title?.toLowerCase().includes(lowerName));
1915
+ dashboards2 = dashboards2.filter((d) => d.title?.toLowerCase().includes(lowerName));
1915
1916
  }
1916
- const result = dashboards.slice(0, effectiveLimit).map(formatDashboardSummary);
1917
+ const result = dashboards2.slice(0, effectiveLimit).map(formatDashboardSummary);
1917
1918
  return {
1918
1919
  dashboards: result,
1919
1920
  total: response.dashboards?.length ?? 0
@@ -2543,9 +2544,9 @@ async function listMetrics(api, params, _limits) {
2543
2544
  host: void 0,
2544
2545
  tagFilter: params.query
2545
2546
  });
2546
- const metrics = response.metrics ?? [];
2547
+ const metrics2 = response.metrics ?? [];
2547
2548
  return {
2548
- metrics,
2549
+ metrics: metrics2,
2549
2550
  total: response.metrics?.length ?? 0
2550
2551
  };
2551
2552
  }
@@ -3202,9 +3203,9 @@ async function listSlos(api, params, limits) {
3202
3203
  tagsQuery: params.tags?.join(","),
3203
3204
  limit: effectiveLimit
3204
3205
  });
3205
- const slos = (response.data ?? []).map(formatSlo);
3206
+ const slos2 = (response.data ?? []).map(formatSlo);
3206
3207
  return {
3207
- slos,
3208
+ slos: slos2,
3208
3209
  total: response.data?.length ?? 0
3209
3210
  };
3210
3211
  }
@@ -4121,23 +4122,23 @@ async function getPerformanceMetrics(api, params, _limits, site) {
4121
4122
  });
4122
4123
  const buckets = (response.data?.buckets ?? []).map((bucket) => {
4123
4124
  const computes = bucket.computes ?? {};
4124
- const metrics = {};
4125
+ const metrics2 = {};
4125
4126
  for (const metricName of requestedMetrics) {
4126
4127
  const config = METRIC_CONFIGS[metricName];
4127
4128
  if (!config) continue;
4128
- metrics[metricName] = {};
4129
+ metrics2[metricName] = {};
4129
4130
  for (const aggregation of config.aggregations) {
4130
4131
  const computeIndex = computeConfigs.findIndex(
4131
4132
  (c) => c.metric === config.field && c.aggregation === aggregation
4132
4133
  );
4133
4134
  const key = `c${computeIndex}`;
4134
4135
  const value = computes[key]?.value;
4135
- metrics[metricName][String(aggregation)] = value ?? null;
4136
+ metrics2[metricName][String(aggregation)] = value ?? null;
4136
4137
  }
4137
4138
  }
4138
4139
  return {
4139
4140
  by: bucket.by ?? {},
4140
- metrics
4141
+ metrics: metrics2
4141
4142
  };
4142
4143
  });
4143
4144
  return {
@@ -4239,7 +4240,7 @@ function registerRumTool(server, api, limits, site = "datadoghq.com") {
4239
4240
  limit,
4240
4241
  groupBy,
4241
4242
  compute,
4242
- metrics,
4243
+ metrics: metrics2,
4243
4244
  applicationId,
4244
4245
  sessionId,
4245
4246
  viewId
@@ -4258,7 +4259,7 @@ function registerRumTool(server, api, limits, site = "datadoghq.com") {
4258
4259
  );
4259
4260
  case "performance":
4260
4261
  return toolResult(
4261
- await getPerformanceMetrics(api, { query, from, to, groupBy, metrics }, limits, site)
4262
+ await getPerformanceMetrics(api, { query, from, to, groupBy, metrics: metrics2 }, limits, site)
4262
4263
  );
4263
4264
  case "waterfall":
4264
4265
  if (!applicationId || !sessionId) {
@@ -5274,6 +5275,224 @@ async function validateCredentials(clients) {
5274
5275
  }
5275
5276
  }
5276
5277
 
5278
+ // src/tools/schema.ts
5279
+ import { z as z21 } from "zod";
5280
+
5281
+ // src/schema/dashboards.ts
5282
+ var dashboards = {
5283
+ palettes: [
5284
+ "blue",
5285
+ "custom_bg",
5286
+ "custom_image",
5287
+ "custom_text",
5288
+ "gray_on_white",
5289
+ "grey",
5290
+ "green",
5291
+ "orange",
5292
+ "red",
5293
+ "red_on_white",
5294
+ "white_on_gray",
5295
+ "white_on_green",
5296
+ "green_on_white",
5297
+ "white_on_red",
5298
+ "white_on_yellow",
5299
+ "yellow_on_white",
5300
+ "black_on_light_yellow",
5301
+ "black_on_light_green",
5302
+ "black_on_light_red"
5303
+ ],
5304
+ widgetTypes: [
5305
+ "alert_graph",
5306
+ "alert_value",
5307
+ "bar_chart",
5308
+ "change",
5309
+ "check_status",
5310
+ "distribution",
5311
+ "event_stream",
5312
+ "event_timeline",
5313
+ "free_text",
5314
+ "funnel",
5315
+ "geomap",
5316
+ "group",
5317
+ "heatmap",
5318
+ "hostmap",
5319
+ "iframe",
5320
+ "image",
5321
+ "list_stream",
5322
+ "log_stream",
5323
+ "manage_status",
5324
+ "note",
5325
+ "powerpack",
5326
+ "query_table",
5327
+ "query_value",
5328
+ "run_workflow",
5329
+ "scatterplot",
5330
+ "servicemap",
5331
+ "slo",
5332
+ "slo_list",
5333
+ "split_group",
5334
+ "sunburst",
5335
+ "timeseries",
5336
+ "toplist",
5337
+ "topology_map",
5338
+ "trace_service",
5339
+ "treemap"
5340
+ ],
5341
+ displayTypes: ["area", "bars", "line", "overlay"],
5342
+ lineTypes: ["dashed", "dotted", "solid"],
5343
+ lineWidths: ["normal", "thick", "thin"],
5344
+ comparators: ["=", ">", ">=", "<", "<="],
5345
+ aggregators: ["avg", "last", "max", "min", "sum", "percentile"],
5346
+ layoutTypes: ["ordered", "free"],
5347
+ responseFormats: ["timeseries", "scalar", "event_list"],
5348
+ sortOrders: ["asc", "desc"],
5349
+ textAligns: ["center", "left", "right"],
5350
+ verticalAligns: ["center", "top", "bottom"],
5351
+ horizontalAligns: ["center", "left", "right"],
5352
+ imageSizings: ["fill", "contain", "cover", "none", "scale-down", "zoom", "fit", "center"],
5353
+ eventSizes: ["s", "l"],
5354
+ tickEdges: ["bottom", "left", "right", "top"],
5355
+ sizeFormats: ["small", "medium", "large"],
5356
+ viewModes: ["overall", "component", "both"],
5357
+ groupings: ["check", "cluster"],
5358
+ liveSpans: [
5359
+ "1m",
5360
+ "5m",
5361
+ "10m",
5362
+ "15m",
5363
+ "30m",
5364
+ "1h",
5365
+ "4h",
5366
+ "1d",
5367
+ "2d",
5368
+ "1w",
5369
+ "1mo",
5370
+ "3mo",
5371
+ "6mo",
5372
+ "week_to_date",
5373
+ "month_to_date",
5374
+ "1y",
5375
+ "alert"
5376
+ ],
5377
+ eventsDataSources: [
5378
+ "logs",
5379
+ "spans",
5380
+ "network",
5381
+ "rum",
5382
+ "security_signals",
5383
+ "profiles",
5384
+ "audit",
5385
+ "events",
5386
+ "ci_tests",
5387
+ "ci_pipelines",
5388
+ "incident_analytics",
5389
+ "product_analytics",
5390
+ "on_call_events"
5391
+ ],
5392
+ metricAggregations: ["avg", "min", "max", "sum", "last", "area", "l2norm", "percentile"],
5393
+ eventAggregations: [
5394
+ "count",
5395
+ "cardinality",
5396
+ "median",
5397
+ "pc75",
5398
+ "pc90",
5399
+ "pc95",
5400
+ "pc98",
5401
+ "pc99",
5402
+ "sum",
5403
+ "min",
5404
+ "max",
5405
+ "avg"
5406
+ ],
5407
+ docsUrl: "https://docs.datadoghq.com/api/latest/dashboards/"
5408
+ };
5409
+
5410
+ // src/schema/metrics.ts
5411
+ var metrics = {
5412
+ aggregators: ["avg", "max", "min", "sum", "count"],
5413
+ rollupMethods: ["avg", "max", "min", "sum", "count"],
5414
+ metricTypes: ["gauge", "rate", "count", "distribution"],
5415
+ dataSources: ["metrics", "logs", "spans", "rum", "events", "profiles", "cloud_cost"],
5416
+ docsUrl: "https://docs.datadoghq.com/api/latest/metrics/"
5417
+ };
5418
+
5419
+ // src/schema/monitors.ts
5420
+ var monitors = {
5421
+ types: [
5422
+ "composite",
5423
+ "event alert",
5424
+ "log alert",
5425
+ "metric alert",
5426
+ "process alert",
5427
+ "query alert",
5428
+ "rum alert",
5429
+ "service check",
5430
+ "synthetics alert",
5431
+ "trace-analytics alert",
5432
+ "slo alert",
5433
+ "event-v2 alert",
5434
+ "audit alert",
5435
+ "ci-pipelines alert",
5436
+ "ci-tests alert",
5437
+ "error-tracking alert",
5438
+ "database-monitoring alert",
5439
+ "network-performance alert",
5440
+ "cost alert",
5441
+ "data-quality alert",
5442
+ "network-path alert"
5443
+ ],
5444
+ aggregators: ["avg", "last", "max", "min", "sum", "count", "percentile"],
5445
+ comparators: [">", "<", ">=", "<=", "="],
5446
+ priorities: ["1", "2", "3", "4", "5"],
5447
+ notifyStates: ["Alert", "No Data", "Warn", "OK"],
5448
+ docsUrl: "https://docs.datadoghq.com/api/latest/monitors/"
5449
+ };
5450
+
5451
+ // src/schema/slos.ts
5452
+ var slos = {
5453
+ types: ["metric", "monitor", "time_slice"],
5454
+ timeframes: ["7d", "30d", "90d", "custom"],
5455
+ correctionCategories: ["Scheduled Maintenance", "Outside Business Hours", "Deployment", "Other"],
5456
+ measures: [
5457
+ "good_events",
5458
+ "bad_events",
5459
+ "good_minutes",
5460
+ "bad_minutes",
5461
+ "slo_status",
5462
+ "error_budget_remaining",
5463
+ "burn_rate",
5464
+ "error_budget_burndown"
5465
+ ],
5466
+ docsUrl: "https://docs.datadoghq.com/api/latest/service-level-objectives/"
5467
+ };
5468
+
5469
+ // src/schema/index.ts
5470
+ var schemas = { dashboards, metrics, monitors, slos };
5471
+ var schemaResources = Object.keys(schemas);
5472
+
5473
+ // src/tools/schema.ts
5474
+ var ResourceSchema = z21.enum(schemaResources);
5475
+ var InputSchema20 = {
5476
+ resource: ResourceSchema.describe(
5477
+ "Datadog resource type to get schema for: dashboards, metrics, monitors, slos"
5478
+ )
5479
+ };
5480
+ function getSchema(resource) {
5481
+ const schema = schemas[resource];
5482
+ return { resource, schema };
5483
+ }
5484
+ function registerSchemaTool(server) {
5485
+ server.tool(
5486
+ "schema",
5487
+ "Get valid enum values for Datadog API fields. Returns palettes, widget types, aggregators, comparators, time spans, and other valid values for constructing dashboards, monitors, metrics queries, and SLOs. Use this to discover valid options before creating or updating Datadog resources.",
5488
+ InputSchema20,
5489
+ async ({ resource }) => {
5490
+ const result = getSchema(resource);
5491
+ return toolResult(result);
5492
+ }
5493
+ );
5494
+ }
5495
+
5277
5496
  // src/tools/index.ts
5278
5497
  function registerAllTools(server, clients, limits, features, site = "datadoghq.com", datadogConfig) {
5279
5498
  const { readOnly, disabledTools } = features;
@@ -5315,6 +5534,7 @@ function registerAllTools(server, clients, limits, features, site = "datadoghq.c
5315
5534
  if (enabled("tags")) registerTagsTool(server, clients.tags, limits, readOnly);
5316
5535
  if (enabled("usage")) registerUsageTool(server, clients.usage, limits);
5317
5536
  if (enabled("auth")) registerAuthTool(server, clients);
5537
+ if (enabled("schema")) registerSchemaTool(server);
5318
5538
  }
5319
5539
 
5320
5540
  // src/server.ts