Skip to content

Commit ed0c9b0

Browse files
authored
Merge pull request #211 from cloudflare/jrutherford/MON-1207-remote-captures-improvements
Improve DEX remote captures tools, separate by type for clarity
2 parents 132ed2a + 8f9717c commit ed0c9b0

File tree

2 files changed

+56
-20
lines changed

2 files changed

+56
-20
lines changed

apps/dex-analysis/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Currently available tools:
1818
| | `dex_traceroute_test_network_path` | Retrieve detailed time series results for the network path of a traceroute test by test id and device id. |
1919
| | `dex_traceroute_test_result_network_path` | Retrieve the hop-by-hop network path for a specific Traceroute DEX test result by id. Use `dex_traceroute_test_network_path` to obain test result ids. |
2020
| **Remote Captures** | `dex_list_remote_capture_eligible_devices` | Retrieve a list of devices eligible for remote captures like packet captures or WARP diagnostics. |
21-
| | `dex_create_remote_capture` | Initiate a remote capture on a specific device by id. |
21+
| | `dex_create_remote_pcap` | Initiate a remote packet capture on a specific device by id. |
22+
| | `dex_create_remote_warp_diag` | Initiate a remote Warp diagnostic capture on a specific device by id. |
2223
| | `dex_list_remote_captures` | Retrieve a list of previously created remote captures along with their details and status. |
2324
| | `dex_list_remote_warp_diag_contents` | List the filenames included in a remote WARP diag capture returned by `dex_list_remote_captures`. |
2425
| | `dex_explore_remote_warp_diag_output` | Retreive remote WARP diag file contents by filepath returned by `dex_list_remote_warp_diag_contents`. |

apps/dex-analysis/src/tools/dex-analysis.tools.ts

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,14 @@ export function registerDEXTools(agent: CloudflareDEXMCP) {
209209
})
210210

211211
registerTool({
212-
name: 'dex_create_remote_capture',
212+
name: 'dex_create_remote_pcap',
213213
description:
214-
'Create a remote capture for a device. This is a resource intensive and privacy-sensitive operation on a real user device.' +
214+
'Create a remote packet capture (PCAP) for a device. This is a resource intensive and privacy-sensitive operation on a real user device.' +
215215
'Always ask for confirmation from the user that the targeted email and device are correct before executing a capture',
216216
schema: {
217217
device_id: z.string().describe('The device ID to target.'),
218218
user_email: z.string().describe('The email of the user associated with the device.'),
219-
type: z.enum(['pcap', 'warp-diag']).describe('The type of remote capture to perform.'),
220-
interfaces: z
221-
.array(z.enum(['default', 'tunnel']))
222-
.optional()
223-
.describe('The network interfaces to capture packets on.'),
224-
max_file_size_mb: z
219+
'max-file-size-mb': z
225220
.number()
226221
.min(1)
227222
.default(5)
@@ -230,29 +225,68 @@ export function registerDEXTools(agent: CloudflareDEXMCP) {
230225
'Maximum file size in MB for the capture file. Specifies the maximum file size of the warp-daig zip artifact that can be uploaded. ' +
231226
'If the zip artifact exceeds the specified max file size it will NOT be uploaded.'
232227
),
233-
max_packet_size_bytes: z
228+
'packet-size-bytes': z
234229
.number()
235230
.min(1)
236231
.default(160)
237232
.optional()
238233
.describe('Maximum number of bytes to save for each packet.'),
239-
test_all_routes: z
234+
'time-limit-min': z
235+
.number()
236+
.min(1)
237+
.default(5)
238+
.describe('Limit on capture duration in minutes'),
239+
},
240+
agent,
241+
llmContext:
242+
'If the request was successful, the capture has been initiated. You can poll the dex_list_remote_commands tool periodically to check on the completion status.',
243+
callback: async ({ accountId, accessToken, device_id, user_email, ...command_args }) => {
244+
return await fetchCloudflareApi({
245+
endpoint: `/dex/commands`,
246+
accountId,
247+
apiToken: accessToken,
248+
options: {
249+
method: 'POST',
250+
headers: {
251+
'Content-Type': 'application/json',
252+
},
253+
body: JSON.stringify({
254+
commands: [
255+
{
256+
type: 'pcap',
257+
device_id,
258+
user_email,
259+
args: command_args,
260+
version: 1,
261+
},
262+
],
263+
}),
264+
},
265+
})
266+
},
267+
})
268+
269+
registerTool({
270+
name: 'dex_create_remote_warp_diag',
271+
description:
272+
'Create a remote Warp Diagnostic (WARP-diag) for a device. This is a resource intensive and privacy-sensitive operation on a real user device.' +
273+
'Always ask for confirmation from the user that the targeted email and device are correct before executing a capture',
274+
schema: {
275+
device_id: z.string().describe('The device ID to target.'),
276+
user_email: z.string().describe('The email of the user associated with the device.'),
277+
'test-all-routes': z
240278
.boolean()
241279
.default(true)
242280
.describe(
243281
'Test an IP address from all included or excluded ranges. Tests an IP address from all included or excluded ranges.' +
244282
"Essentially the same as running 'route get '' and collecting the results. This option may increase the time taken to collect the warp-diag"
245283
),
246-
time_limit_mins: z
247-
.number()
248-
.min(1)
249-
.default(5)
250-
.describe('Limit on capture duration in minutes'),
251284
},
252285
agent,
253286
llmContext:
254-
'If the request was successful, the command has been created. You can poll the dex_list_remote_commands tool periodically to check on the completion status.',
255-
callback: async ({ accountId, accessToken, type, device_id, user_email, ...command_args }) => {
287+
'If the request was successful, the diagnostic has been initiated. You can poll the dex_list_remote_commands tool periodically to check on the completion status.' +
288+
'See https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/troubleshooting/warp-logs/ for more info on warp-diags',
289+
callback: async ({ accountId, accessToken, device_id, user_email, ...command_args }) => {
256290
return await fetchCloudflareApi({
257291
endpoint: `/dex/commands`,
258292
accountId,
@@ -265,7 +299,7 @@ export function registerDEXTools(agent: CloudflareDEXMCP) {
265299
body: JSON.stringify({
266300
commands: [
267301
{
268-
type,
302+
type: 'warp-diag',
269303
device_id,
270304
user_email,
271305
args: command_args,
@@ -498,7 +532,8 @@ export function registerDEXTools(agent: CloudflareDEXMCP) {
498532
},
499533
llmContext:
500534
'Use the dex_explore_remote_warp_diag_output tool for specific file paths to explore the file contents for analysis. ' +
501-
'Hint: you can call dex_explore_remote_warp_diag_output multiple times in parallel if necessary to take advantage of in-memory caching for best performance.',
535+
'Hint: you can call dex_explore_remote_warp_diag_output multiple times in parallel if necessary to take advantage of in-memory caching for best performance.' +
536+
'See https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/troubleshooting/warp-logs/ for more info on warp-diags',
502537
agent,
503538
callback: async ({ accessToken, download }) => {
504539
const reader = await getReader(env, accessToken, download)

0 commit comments

Comments
 (0)