Skip to content

Commit a224390

Browse files
committed
Some update
1 parent 2e75dc3 commit a224390

14 files changed

Lines changed: 323 additions & 451 deletions

File tree

README.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,40 @@ MCP server for the Datadog API, enabling incident management and more.
8888
- `operation` (optional string): Filter by operation name.
8989
- **Returns**: Array of matching traces from Datadog APM.
9090

91-
9. `list_hosts`
91+
9. `list_spans`
9292

93-
- Get list of hosts from Datadog.
93+
- Get a list of spans matching a search query (Datadog Spans Search API).
9494
- **Inputs**:
95-
- `filter` (optional string): Filter string for search results.
96-
- `sort_field` (optional string): Field to sort hosts by.
97-
- `sort_dir` (optional string): Sort direction (asc/desc).
98-
- `start` (optional number): Starting offset for pagination.
99-
- `count` (optional number): Max number of hosts to return (max: 1000).
100-
- `from` (optional number): Search hosts from this UNIX timestamp.
101-
- `include_muted_hosts_data` (optional boolean): Include muted hosts status and expiry.
102-
- `include_hosts_metadata` (optional boolean): Include host metadata (version, platform, etc).
103-
- **Returns**: Array of hosts with details including name, ID, aliases, apps, mute status, and more.
104-
105-
10. `get_active_hosts_count`
95+
- `query` (string): Search query following spans syntax.
96+
- `from` (number): Minimum timestamp for requested spans (epoch seconds).
97+
- `to` (number): Maximum timestamp for requested spans (epoch seconds).
98+
- `sort` (optional string): Order of spans in results ('timestamp' | '-timestamp').
99+
- `cursor` (optional string): Pagination cursor from previous request.
100+
- `limit` (optional number): Maximum number of spans to return (default 100).
101+
- **Returns**: Spans list, count, and next cursor when available.
102+
103+
10. `list_hosts`
104+
105+
- Get list of hosts from Datadog.
106+
- **Inputs**:
107+
- `filter` (optional string): Filter string for search results.
108+
- `sort_field` (optional string): Field to sort hosts by.
109+
- `sort_dir` (optional string): Sort direction (asc/desc).
110+
- `start` (optional number): Starting offset for pagination.
111+
- `count` (optional number): Max number of hosts to return (max: 1000).
112+
- `from` (optional number): Search hosts from this UNIX timestamp.
113+
- `include_muted_hosts_data` (optional boolean): Include muted hosts status and expiry.
114+
- `include_hosts_metadata` (optional boolean): Include host metadata (version, platform, etc).
115+
- **Returns**: Array of hosts with details including name, ID, aliases, apps, mute status, and more.
116+
117+
11. `get_active_hosts_count`
106118

107119
- Get the total number of active hosts in Datadog.
108120
- **Inputs**:
109121
- `from` (optional number): Number of seconds from which you want to get total number of active hosts (defaults to 2h).
110122
- **Returns**: Count of total active and up hosts.
111123

112-
11. `mute_host`
124+
12. `mute_host`
113125

114126
- Mute a host in Datadog.
115127
- **Inputs**:
@@ -119,22 +131,22 @@ MCP server for the Datadog API, enabling incident management and more.
119131
- `override` (optional boolean): If true and the host is already muted, replaces existing end time.
120132
- **Returns**: Success status and confirmation message.
121133

122-
12. `unmute_host`
134+
13. `unmute_host`
123135

124136
- Unmute a host in Datadog.
125137
- **Inputs**:
126138
- `hostname` (string): The name of the host to unmute.
127139
- **Returns**: Success status and confirmation message.
128140

129-
13. `list_downtimes`
141+
14. `list_downtimes`
130142

131143
- List scheduled downtimes from Datadog.
132144
- **Inputs**:
133145
- `currentOnly` (optional boolean): Return only currently active downtimes when true.
134146
- `monitorId` (optional number): Filter by monitor ID.
135147
- **Returns**: Array of scheduled downtimes with details including scope, monitor information, and schedule.
136148

137-
14. `schedule_downtime`
149+
15. `schedule_downtime`
138150

139151
- Schedule a downtime in Datadog.
140152
- **Inputs**:
@@ -152,20 +164,20 @@ MCP server for the Datadog API, enabling incident management and more.
152164
- `until` (optional number): UNIX timestamp for when the recurrence ends.
153165
- **Returns**: Scheduled downtime details including ID and active status.
154166

155-
15. `cancel_downtime`
167+
16. `cancel_downtime`
156168

157169
- Cancel a scheduled downtime in Datadog.
158170
- **Inputs**:
159171
- `downtimeId` (number): The ID of the downtime to cancel.
160172
- **Returns**: Confirmation of downtime cancellation.
161173

162-
16. `get_rum_applications`
174+
17. `get_rum_applications`
163175

164176
- Get all RUM applications in the organization.
165177
- **Inputs**: None.
166178
- **Returns**: List of RUM applications.
167179

168-
17. `get_rum_events`
180+
18. `get_rum_events`
169181

170182
- Search and retrieve RUM events from Datadog.
171183
- **Inputs**:
@@ -175,7 +187,7 @@ MCP server for the Datadog API, enabling incident management and more.
175187
- `limit` (optional number): Maximum number of events to return (default: 100).
176188
- **Returns**: Array of RUM events.
177189

178-
18. `get_rum_grouped_event_count`
190+
19. `get_rum_grouped_event_count`
179191

180192
- Search, group and count RUM events by a specified dimension.
181193
- **Inputs**:
@@ -185,7 +197,7 @@ MCP server for the Datadog API, enabling incident management and more.
185197
- `groupBy` (optional string): Dimension to group results by (default: "application.name").
186198
- **Returns**: Grouped event counts.
187199

188-
19. `get_rum_page_performance`
200+
20. `get_rum_page_performance`
189201

190202
- Get page (view) performance metrics from RUM data.
191203
- **Inputs**:
@@ -195,7 +207,7 @@ MCP server for the Datadog API, enabling incident management and more.
195207
- `metricNames` (array of strings): Array of metric names to retrieve (e.g., 'view.load_time', 'view.first_contentful_paint').
196208
- **Returns**: Performance metrics including average, min, max, and count for each metric.
197209

198-
20. `get_rum_page_waterfall`
210+
21. `get_rum_page_waterfall`
199211

200212
- Retrieve RUM page (view) waterfall data filtered by application name and session ID.
201213
- **Inputs**:
@@ -243,7 +255,7 @@ pnpm watch # for development with auto-rebuild
243255

244256
To use this with Claude Desktop, add the following to your `claude_desktop_config.json`:
245257

246-
On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
258+
On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
247259
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
248260

249261
```json

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "@winor30/mcp-server-datadog",
3-
"version": "1.6.0",
2+
"name": "@datgfg/mcp-server-datadog",
3+
"version": "1.6.3",
44
"description": "MCP server for interacting with Datadog API",
55
"repository": {
66
"type": "git",
7-
"url": "https://github.com/winor30/mcp-server-datadog.git"
7+
"url": "https://github.com/datgfg/mcp-server-datadog.git"
88
},
99
"type": "module",
1010
"bin": {
@@ -35,7 +35,7 @@
3535
"lint-staged": "lint-staged"
3636
},
3737
"dependencies": {
38-
"@datadog/datadog-api-client": "^1.34.1",
38+
"@datadog/datadog-api-client": "^1.41.0",
3939
"@modelcontextprotocol/sdk": "0.6.0",
4040
"zod": "^3.24.3",
4141
"zod-to-json-schema": "^3.24.5"
@@ -70,7 +70,6 @@
7070
},
7171
"lint-staged": {
7272
"*.{js,ts}": [
73-
"eslint --fix",
7473
"prettier --write"
7574
],
7675
"*.{json,md}": [

pnpm-lock.yaml

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ import {
1616
import { log, mcpDatadogVersion } from './utils/helper'
1717
import { INCIDENT_TOOLS, createIncidentToolHandlers } from './tools/incident'
1818
import { METRICS_TOOLS, createMetricsToolHandlers } from './tools/metrics'
19-
import { LOGS_TOOLS, createLogsToolHandlers } from './tools/logs'
19+
// import { LOGS_TOOLS, createLogsToolHandlers } from './tools/logs'
2020
import { MONITORS_TOOLS, createMonitorsToolHandlers } from './tools/monitors'
2121
import {
2222
DASHBOARDS_TOOLS,
2323
createDashboardsToolHandlers,
2424
} from './tools/dashboards'
25-
import { TRACES_TOOLS, createTracesToolHandlers } from './tools/traces'
26-
import { HOSTS_TOOLS, createHostsToolHandlers } from './tools/hosts'
25+
// Traces tools have been consolidated under spans tools
26+
// import { TRACES_TOOLS, createTracesToolHandlers } from './tools/traces'
27+
import { SPANS_TOOLS, createSpansToolHandlers } from './tools/spans'
28+
// import { HOSTS_TOOLS, createHostsToolHandlers } from './tools/hosts'
2729
import { ToolHandlers } from './utils/types'
2830
import { createDatadogConfig } from './utils/datadog'
29-
import { createDowntimesToolHandlers, DOWNTIMES_TOOLS } from './tools/downtimes'
31+
// import { createDowntimesToolHandlers, DOWNTIMES_TOOLS } from './tools/downtimes'
3032
import { createRumToolHandlers, RUM_TOOLS } from './tools/rum'
3133
import { v2, v1 } from '@datadog/datadog-api-client'
3234

@@ -55,12 +57,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
5557
tools: [
5658
...INCIDENT_TOOLS,
5759
...METRICS_TOOLS,
58-
...LOGS_TOOLS,
60+
// ...LOGS_TOOLS,
5961
...MONITORS_TOOLS,
6062
...DASHBOARDS_TOOLS,
61-
...TRACES_TOOLS,
62-
...HOSTS_TOOLS,
63-
...DOWNTIMES_TOOLS,
63+
// ...TRACES_TOOLS,
64+
...SPANS_TOOLS,
65+
// ...HOSTS_TOOLS,
66+
// ...DOWNTIMES_TOOLS,
6467
...RUM_TOOLS,
6568
],
6669
}
@@ -79,12 +82,13 @@ const datadogConfig = createDatadogConfig({
7982
const TOOL_HANDLERS: ToolHandlers = {
8083
...createIncidentToolHandlers(new v2.IncidentsApi(datadogConfig)),
8184
...createMetricsToolHandlers(new v1.MetricsApi(datadogConfig)),
82-
...createLogsToolHandlers(new v2.LogsApi(datadogConfig)),
85+
// ...createLogsToolHandlers(new v2.LogsApi(datadogConfig)),
8386
...createMonitorsToolHandlers(new v1.MonitorsApi(datadogConfig)),
8487
...createDashboardsToolHandlers(new v1.DashboardsApi(datadogConfig)),
85-
...createTracesToolHandlers(new v2.SpansApi(datadogConfig)),
86-
...createHostsToolHandlers(new v1.HostsApi(datadogConfig)),
87-
...createDowntimesToolHandlers(new v1.DowntimesApi(datadogConfig)),
88+
// ...createTracesToolHandlers(new v2.SpansApi(datadogConfig)),
89+
...createSpansToolHandlers(new v2.SpansApi(datadogConfig)),
90+
// ...createHostsToolHandlers(new v1.HostsApi(datadogConfig)),
91+
// ...createDowntimesToolHandlers(new v1.DowntimesApi(datadogConfig)),
8892
...createRumToolHandlers(new v2.RUMApi(datadogConfig)),
8993
}
9094
/**

src/tools/metrics/schema.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ export const QueryMetricsZodSchema = z.object({
1515
})
1616

1717
export type QueryMetricsArgs = z.infer<typeof QueryMetricsZodSchema>
18+
19+
// Schema for listing all metrics
20+
export const ListMetricsZodSchema = z.object({
21+
from: z
22+
.number()
23+
.optional()
24+
.describe(
25+
'Start of the timeframe (in seconds since Unix epoch) to list active metrics. Defaults to 24h ago if omitted.',
26+
),
27+
tagFilter: z
28+
.string()
29+
.optional()
30+
.describe('Filter metrics that have been submitted with the given tags.'),
31+
})
32+
33+
export type ListMetricsArgs = z.infer<typeof ListMetricsZodSchema>

src/tools/metrics/tool.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ExtendedTool, ToolHandlers } from '../../utils/types'
22
import { v1 } from '@datadog/datadog-api-client'
33
import { createToolSchema } from '../../utils/tool'
4-
import { QueryMetricsZodSchema } from './schema'
4+
import { QueryMetricsZodSchema, ListMetricsZodSchema } from './schema'
55

6-
type MetricsToolName = 'query_metrics'
6+
type MetricsToolName = 'query_metrics' | 'list_metrics'
77
type MetricsTool = ExtendedTool<MetricsToolName>
88

99
export const METRICS_TOOLS: MetricsTool[] = [
@@ -12,6 +12,11 @@ export const METRICS_TOOLS: MetricsTool[] = [
1212
'query_metrics',
1313
'Query timeseries points of metrics from Datadog',
1414
),
15+
createToolSchema(
16+
ListMetricsZodSchema,
17+
'list_metrics',
18+
'List active metric names from Datadog',
19+
),
1520
] as const
1621

1722
type MetricsToolHandlers = ToolHandlers<MetricsToolName>
@@ -40,5 +45,29 @@ export const createMetricsToolHandlers = (
4045
],
4146
}
4247
},
48+
list_metrics: async (request) => {
49+
const { from, tagFilter } = ListMetricsZodSchema.parse(
50+
request.params.arguments,
51+
)
52+
53+
// default to 24h ago if from not provided
54+
const fromSeconds = from ?? Math.floor(Date.now() / 1000) - 60 * 60 * 24
55+
56+
const response = await apiInstance.listActiveMetrics({
57+
from: fromSeconds,
58+
tagFilter,
59+
})
60+
61+
const metrics = response.metrics as string[]
62+
63+
return {
64+
content: [
65+
{
66+
type: 'text',
67+
text: `Metrics: ${JSON.stringify(metrics)}`,
68+
},
69+
],
70+
}
71+
},
4372
}
4473
}

src/tools/spans/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { SPANS_TOOLS, createSpansToolHandlers } from './tool'

0 commit comments

Comments
 (0)