Skip to content

Commit 9f15642

Browse files
authored
Add RUM tools (#28)
1 parent 4fa2b90 commit 9f15642

6 files changed

Lines changed: 627 additions & 0 deletions

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,56 @@ MCP server for the Datadog API, enabling incident management and more.
151151
- **Returns**: Scheduled downtime details including ID and active status.
152152

153153
15. `cancel_downtime`
154+
154155
- Cancel a scheduled downtime in Datadog.
155156
- **Inputs**:
156157
- `downtimeId` (number): The ID of the downtime to cancel.
157158
- **Returns**: Confirmation of downtime cancellation.
158159

160+
16. `get_rum_applications`
161+
162+
- Get all RUM applications in the organization.
163+
- **Inputs**: None.
164+
- **Returns**: List of RUM applications.
165+
166+
17. `get_rum_events`
167+
168+
- Search and retrieve RUM events from Datadog.
169+
- **Inputs**:
170+
- `query` (string): Datadog RUM query string.
171+
- `from` (number): Start time in epoch seconds.
172+
- `to` (number): End time in epoch seconds.
173+
- `limit` (optional number): Maximum number of events to return (default: 100).
174+
- **Returns**: Array of RUM events.
175+
176+
18. `get_rum_grouped_event_count`
177+
178+
- Search, group and count RUM events by a specified dimension.
179+
- **Inputs**:
180+
- `query` (optional string): Additional query filter for RUM search (default: "\*").
181+
- `from` (number): Start time in epoch seconds.
182+
- `to` (number): End time in epoch seconds.
183+
- `groupBy` (optional string): Dimension to group results by (default: "application.name").
184+
- **Returns**: Grouped event counts.
185+
186+
19. `get_rum_page_performance`
187+
188+
- Get page (view) performance metrics from RUM data.
189+
- **Inputs**:
190+
- `query` (optional string): Additional query filter for RUM search (default: "\*").
191+
- `from` (number): Start time in epoch seconds.
192+
- `to` (number): End time in epoch seconds.
193+
- `metricNames` (array of strings): Array of metric names to retrieve (e.g., 'view.load_time', 'view.first_contentful_paint').
194+
- **Returns**: Performance metrics including average, min, max, and count for each metric.
195+
196+
20. `get_rum_page_waterfall`
197+
198+
- Retrieve RUM page (view) waterfall data filtered by application name and session ID.
199+
- **Inputs**:
200+
- `applicationName` (string): Application name to filter events.
201+
- `sessionId` (string): Session ID to filter events.
202+
- **Returns**: Waterfall data for the specified application and session.
203+
159204
## Setup
160205

161206
### Datadog Credentials

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { HOSTS_TOOLS, createHostsToolHandlers } from './tools/hosts'
2727
import { ToolHandlers } from './utils/types'
2828
import { createDatadogConfig } from './utils/datadog'
2929
import { createDowntimesToolHandlers, DOWNTIMES_TOOLS } from './tools/downtimes'
30+
import { createRumToolHandlers, RUM_TOOLS } from './tools/rum'
3031
import { v2, v1 } from '@datadog/datadog-api-client'
3132

3233
const server = new Server(
@@ -60,6 +61,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
6061
...TRACES_TOOLS,
6162
...HOSTS_TOOLS,
6263
...DOWNTIMES_TOOLS,
64+
...RUM_TOOLS,
6365
],
6466
}
6567
})
@@ -83,6 +85,7 @@ const TOOL_HANDLERS: ToolHandlers = {
8385
...createTracesToolHandlers(new v2.SpansApi(datadogConfig)),
8486
...createHostsToolHandlers(new v1.HostsApi(datadogConfig)),
8587
...createDowntimesToolHandlers(new v1.DowntimesApi(datadogConfig)),
88+
...createRumToolHandlers(new v2.RUMApi(datadogConfig)),
8689
}
8790
/**
8891
* Handler for invoking Datadog-related tools in the mcp-server-datadog.

src/tools/rum/index.ts

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

src/tools/rum/schema.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { z } from 'zod'
2+
3+
/**
4+
* Schema for retrieving RUM events.
5+
* Defines parameters for querying RUM events within a time window.
6+
*
7+
* @param query - Datadog RUM query string
8+
* @param from - Start time in epoch seconds
9+
* @param to - End time in epoch seconds
10+
* @param limit - Maximum number of events to return (default: 100)
11+
*/
12+
export const GetRumEventsZodSchema = z.object({
13+
query: z.string().default('').describe('Datadog RUM query string'),
14+
from: z.number().describe('Start time in epoch seconds'),
15+
to: z.number().describe('End time in epoch seconds'),
16+
limit: z
17+
.number()
18+
.optional()
19+
.default(100)
20+
.describe('Maximum number of events to return. Default is 100.'),
21+
})
22+
23+
/**
24+
* Schema for retrieving RUM applications.
25+
* Returns a list of all RUM applications in the organization.
26+
*/
27+
export const GetRumApplicationsZodSchema = z.object({})
28+
29+
/**
30+
* Schema for retrieving unique user session counts.
31+
* Defines parameters for querying session counts within a time window.
32+
*
33+
* @param query - Optional. Additional query filter for RUM search. Defaults to "*" (all events)
34+
* @param from - Start time in epoch seconds
35+
* @param to - End time in epoch seconds
36+
* @param groupBy - Optional. Dimension to group results by (e.g., 'application.name')
37+
*/
38+
export const GetRumGroupedEventCountZodSchema = z.object({
39+
query: z
40+
.string()
41+
.default('*')
42+
.describe('Optional query filter for RUM search'),
43+
from: z.number().describe('Start time in epoch seconds'),
44+
to: z.number().describe('End time in epoch seconds'),
45+
groupBy: z
46+
.string()
47+
.optional()
48+
.default('application.name')
49+
.describe('Dimension to group results by. Default is application.name'),
50+
})
51+
52+
/**
53+
* Schema for retrieving page performance metrics.
54+
* Defines parameters for querying performance metrics within a time window.
55+
*
56+
* @param query - Optional. Additional query filter for RUM search. Defaults to "*" (all events)
57+
* @param from - Start time in epoch seconds
58+
* @param to - End time in epoch seconds
59+
* @param metricNames - Array of metric names to retrieve (e.g., 'view.load_time', 'view.first_contentful_paint')
60+
*/
61+
export const GetRumPagePerformanceZodSchema = z.object({
62+
query: z
63+
.string()
64+
.default('*')
65+
.describe('Optional query filter for RUM search'),
66+
from: z.number().describe('Start time in epoch seconds'),
67+
to: z.number().describe('End time in epoch seconds'),
68+
metricNames: z
69+
.array(z.string())
70+
.default([
71+
'view.load_time',
72+
'view.first_contentful_paint',
73+
'view.largest_contentful_paint',
74+
])
75+
.describe('Array of metric names to retrieve'),
76+
})
77+
78+
/**
79+
* Schema for retrieving RUM page waterfall data.
80+
* Defines parameters for querying waterfall data within a time window.
81+
*
82+
* @param application - Application name or ID to filter events
83+
* @param sessionId - Session ID to filter events
84+
* @param from - Start time in epoch seconds
85+
* @param to - End time in epoch seconds
86+
*/
87+
export const GetRumPageWaterfallZodSchema = z.object({
88+
applicationName: z.string().describe('Application name to filter events'),
89+
sessionId: z.string().describe('Session ID to filter events'),
90+
})

0 commit comments

Comments
 (0)