hawkeye-mcp-server 1.0.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/INSTALLATION.md +734 -0
  3. package/LICENSE +21 -0
  4. package/README.md +289 -0
  5. package/SPECIFICATION.md +1073 -0
  6. package/USAGE.md +849 -0
  7. package/build/config/config.d.ts +58 -0
  8. package/build/config/config.js +100 -0
  9. package/build/config/config.js.map +1 -0
  10. package/build/index.d.ts +6 -0
  11. package/build/index.js +138 -0
  12. package/build/index.js.map +1 -0
  13. package/build/services/auth.service.d.ts +34 -0
  14. package/build/services/auth.service.js +96 -0
  15. package/build/services/auth.service.js.map +1 -0
  16. package/build/services/project.service.d.ts +50 -0
  17. package/build/services/project.service.js +136 -0
  18. package/build/services/project.service.js.map +1 -0
  19. package/build/services/session.service.d.ts +68 -0
  20. package/build/services/session.service.js +357 -0
  21. package/build/services/session.service.js.map +1 -0
  22. package/build/tools/continue-investigation.d.ts +10 -0
  23. package/build/tools/continue-investigation.js +84 -0
  24. package/build/tools/continue-investigation.js.map +1 -0
  25. package/build/tools/get-incident-report.d.ts +10 -0
  26. package/build/tools/get-incident-report.js +62 -0
  27. package/build/tools/get-incident-report.js.map +1 -0
  28. package/build/tools/get-session-report.d.ts +25 -0
  29. package/build/tools/get-session-report.js +46 -0
  30. package/build/tools/get-session-report.js.map +1 -0
  31. package/build/tools/get-session-summary.d.ts +22 -0
  32. package/build/tools/get-session-summary.js +41 -0
  33. package/build/tools/get-session-summary.js.map +1 -0
  34. package/build/tools/get-status.d.ts +10 -0
  35. package/build/tools/get-status.js +129 -0
  36. package/build/tools/get-status.js.map +1 -0
  37. package/build/tools/index.d.ts +29 -0
  38. package/build/tools/index.js +349 -0
  39. package/build/tools/index.js.map +1 -0
  40. package/build/tools/inspect-session.d.ts +28 -0
  41. package/build/tools/inspect-session.js +51 -0
  42. package/build/tools/inspect-session.js.map +1 -0
  43. package/build/tools/investigate-alert.d.ts +10 -0
  44. package/build/tools/investigate-alert.js +122 -0
  45. package/build/tools/investigate-alert.js.map +1 -0
  46. package/build/tools/list-sessions.d.ts +49 -0
  47. package/build/tools/list-sessions.js +79 -0
  48. package/build/tools/list-sessions.js.map +1 -0
  49. package/build/types/errors.d.ts +61 -0
  50. package/build/types/errors.js +76 -0
  51. package/build/types/errors.js.map +1 -0
  52. package/build/types/hawkeye.d.ts +238 -0
  53. package/build/types/hawkeye.js +8 -0
  54. package/build/types/hawkeye.js.map +1 -0
  55. package/build/types/mcp.d.ts +125 -0
  56. package/build/types/mcp.js +6 -0
  57. package/build/types/mcp.js.map +1 -0
  58. package/build/utils/errors.d.ts +20 -0
  59. package/build/utils/errors.js +125 -0
  60. package/build/utils/errors.js.map +1 -0
  61. package/build/utils/http-client.d.ts +51 -0
  62. package/build/utils/http-client.js +133 -0
  63. package/build/utils/http-client.js.map +1 -0
  64. package/build/utils/logger.d.ts +35 -0
  65. package/build/utils/logger.js +77 -0
  66. package/build/utils/logger.js.map +1 -0
  67. package/build/utils/validation.d.ts +134 -0
  68. package/build/utils/validation.js +68 -0
  69. package/build/utils/validation.js.map +1 -0
  70. package/package.json +66 -0
@@ -0,0 +1,1073 @@
1
+ # Hawkeye MCP Server - Comprehensive Specification
2
+
3
+ ## Overview
4
+
5
+ The Hawkeye MCP (Model Context Protocol) Server enables AI coding agents (like Cursor.ai) to investigate cloud environment issues by leveraging Hawkeye's automated incident analysis and root cause analysis capabilities. This server acts as a bridge between coding agents and the Hawkeye API, providing intelligent, context-aware tools for cloud incident investigation.
6
+
7
+ ## Use Cases
8
+
9
+ ### Primary Use Case
10
+ A developer using Cursor.ai encounters an alert or incident in their cloud environment. They can:
11
+ 1. Ask Cursor to investigate an alert by providing an alert ID
12
+ 2. Request a new investigation with a custom prompt and timeframe
13
+ 3. Get status updates on ongoing investigations
14
+ 4. Retrieve and analyze completed RCAs
15
+ 5. Follow up on existing investigations with additional questions
16
+
17
+ ### Developer Experience Goals
18
+ - **Natural Language Interface**: Developers should be able to say "investigate alert XYZ" or "analyze my EKS cluster for the last 2 hours"
19
+ - **Intelligent Defaults**: The server should automatically handle project selection, timeframe formatting, and session management
20
+ - **Streaming Support**: Real-time feedback during long-running investigations
21
+ - **Context Awareness**: Remember previous investigations and allow follow-up questions
22
+
23
+ ## Architecture
24
+
25
+ ### Components
26
+
27
+ ```
28
+ ┌─────────────────────────────────────────────────────────┐
29
+ │ Cursor.ai / AI Agent │
30
+ └──────────────────────┬──────────────────────────────────┘
31
+ │ MCP Protocol
32
+ ┌──────────────────────▼──────────────────────────────────┐
33
+ │ Hawkeye MCP Server │
34
+ │ ┌──────────────────────────────────────────────────┐ │
35
+ │ │ Tool Handlers: │ │
36
+ │ │ • investigate_alert_by_id │ │
37
+ │ │ • create_investigation │ │
38
+ │ │ • get_investigation_status │ │
39
+ │ │ • get_rca_by_alert_id │ │
40
+ │ │ • continue_investigation │ │
41
+ │ │ • list_projects │ │
42
+ │ │ • list_sessions │ │
43
+ │ │ • inspect_session │ │
44
+ │ │ • get_session_report │ │
45
+ │ │ • get_session_summary │ │
46
+ │ │ • get_incident_report │ │
47
+ │ └──────────────────────────────────────────────────┘ │
48
+ │ ┌──────────────────────────────────────────────────┐ │
49
+ │ │ Core Services: │ │
50
+ │ │ • AuthenticationService │ │
51
+ │ │ • SessionManager │ │
52
+ │ │ • ProjectManager │ │
53
+ │ │ • TimeframeParser │ │
54
+ │ │ • StreamingHandler │ │
55
+ │ └──────────────────────────────────────────────────┘ │
56
+ └──────────────────────┬──────────────────────────────────┘
57
+ │ HTTPS/REST
58
+ ┌──────────────────────▼──────────────────────────────────┐
59
+ │ Hawkeye API │
60
+ │ • /api/v1/project │
61
+ │ • /api/v1/inference/session/list │
62
+ │ • /api/v1/inference/new_session │
63
+ │ • /api/v1/inference/session │
64
+ │ • /api/v1/inference/session/inspect │
65
+ │ • /api/v1/inference/session_report │
66
+ │ • /api/v1/inference/session/summary/{uuid} │
67
+ │ • /api/v1/inference/incident_report │
68
+ │ • /api/v1/user/login │
69
+ └──────────────────────────────────────────────────────────┘
70
+ ```
71
+
72
+ ## MCP Tools Specification
73
+
74
+ ### 1. `hawkeye_investigate_alert`
75
+
76
+ **Description**: Finds an existing RCA or creates a new investigation for a specific alert/incident ID.
77
+
78
+ **Input Schema**:
79
+ ```typescript
80
+ {
81
+ alert_id: string; // Full alert ID (e.g., /subscriptions/.../alerts/...)
82
+ project_uuid?: string; // Optional: if not provided, will auto-detect
83
+ wait_for_completion?: boolean; // Default: false. If true, polls until complete
84
+ max_wait_seconds?: number; // Default: 300 (5 minutes)
85
+ }
86
+ ```
87
+
88
+ **Behavior**:
89
+ 1. Searches for existing sessions associated with the alert_id
90
+ 2. If found, returns the latest RCA
91
+ 3. If not found, creates a new investigation session
92
+ 4. If `wait_for_completion` is true, polls for completion
93
+ 5. Returns investigation status and results
94
+
95
+ **Output**:
96
+ ```typescript
97
+ {
98
+ status: "found_existing" | "new_investigation" | "in_progress" | "completed";
99
+ session_uuid: string;
100
+ investigation_results?: {
101
+ final_answer: string;
102
+ chain_of_thoughts: Array<{
103
+ description: string;
104
+ investigation: string;
105
+ }>;
106
+ sources: Array<any>;
107
+ follow_up_suggestions: string[];
108
+ };
109
+ message: string;
110
+ }
111
+ ```
112
+
113
+ ### 2. `hawkeye_create_investigation`
114
+
115
+ **Description**: Creates a new custom investigation with a user-provided prompt and timeframe.
116
+
117
+ **Input Schema**:
118
+ ```typescript
119
+ {
120
+ prompt: string; // Investigation prompt
121
+ timeframe?: string; // Natural language timeframe (e.g., "last 2 hours", "past week")
122
+ start_time?: string; // ISO 8601 timestamp
123
+ end_time?: string; // ISO 8601 timestamp
124
+ project_uuid?: string; // Optional: if not provided, will auto-detect or use default
125
+ wait_for_completion?: boolean; // Default: false
126
+ max_wait_seconds?: number; // Default: 300 (5 minutes)
127
+ stream_updates?: boolean; // Default: false. If true, provides real-time updates
128
+ }
129
+ ```
130
+
131
+ **Behavior**:
132
+ 1. Validates and parses timeframe into proper format
133
+ 2. Enhances prompt to include timeframe context
134
+ 3. Selects appropriate project (auto-detect or use default)
135
+ 4. Creates new session
136
+ 5. Sends investigation prompt
137
+ 6. Optionally waits for completion or streams results
138
+
139
+ **Output**:
140
+ ```typescript
141
+ {
142
+ session_uuid: string;
143
+ status: "created" | "in_progress" | "completed";
144
+ enhanced_prompt: string; // Shows how the prompt was enhanced
145
+ timeframe_parsed: {
146
+ start: string;
147
+ end: string;
148
+ description: string;
149
+ };
150
+ investigation_results?: {
151
+ // Same as hawkeye_investigate_alert
152
+ };
153
+ }
154
+ ```
155
+
156
+ ### 3. `hawkeye_get_investigation_status`
157
+
158
+ **Description**: Gets the current status and results of an ongoing or completed investigation.
159
+
160
+ **Input Schema**:
161
+ ```typescript
162
+ {
163
+ session_uuid: string;
164
+ project_uuid?: string; // Optional: will be auto-detected if not provided
165
+ include_full_details?: boolean; // Default: true
166
+ }
167
+ ```
168
+
169
+ **Output**:
170
+ ```typescript
171
+ {
172
+ session_uuid: string;
173
+ status: "in_progress" | "completed" | "failed" | "unknown";
174
+ progress_percentage?: number;
175
+ current_step?: string;
176
+ investigation_results?: {
177
+ // Same as hawkeye_investigate_alert
178
+ };
179
+ created_at: string;
180
+ updated_at: string;
181
+ }
182
+ ```
183
+
184
+ ### 4. `hawkeye_continue_investigation`
185
+
186
+ **Description**: Asks a follow-up question or provides additional context to an existing investigation.
187
+
188
+ **Input Schema**:
189
+ ```typescript
190
+ {
191
+ session_uuid: string;
192
+ follow_up_prompt: string;
193
+ project_uuid?: string;
194
+ wait_for_completion?: boolean;
195
+ max_wait_seconds?: number;
196
+ }
197
+ ```
198
+
199
+ **Output**: Same as `hawkeye_create_investigation`
200
+
201
+ ### 5. `hawkeye_list_projects`
202
+
203
+ **Description**: Lists all available Hawkeye projects for the authenticated user.
204
+
205
+ **Input Schema**:
206
+ ```typescript
207
+ {
208
+ include_inactive?: boolean; // Default: false
209
+ }
210
+ ```
211
+
212
+ **Output**:
213
+ ```typescript
214
+ {
215
+ projects: Array<{
216
+ uuid: string;
217
+ name: string;
218
+ description: string;
219
+ state: string;
220
+ sync_state: string;
221
+ training_state: string;
222
+ created_at: string;
223
+ updated_at: string;
224
+ }>;
225
+ default_project?: string; // UUID of the default project
226
+ }
227
+ ```
228
+
229
+ ### 6. `hawkeye_list_sessions`
230
+
231
+ **Description**: Lists sessions for a project with pagination, date filtering, and investigation status filtering support.
232
+
233
+ **Input Schema**:
234
+ ```typescript
235
+ {
236
+ project_uuid?: string; // Optional: uses default if not provided
237
+ page?: number; // Page number (1-indexed), default: 1
238
+ limit?: number; // Results per page (max 100), default: 50
239
+ date_from?: string; // ISO 8601 date or date string (e.g., "2024-01-01")
240
+ date_to?: string; // ISO 8601 date or date string
241
+ organization_uuid?: string; // Optional: defaults to ORGANIZATION_NAME_ROOT
242
+ only_uninvestigated?: boolean; // Convenience: filter for uninvestigated incidents
243
+ investigation_status?: string; // Filter by investigation status (e.g., "INVESTIGATION_STATUS_NOT_STARTED")
244
+ session_type?: string; // Filter by session type (e.g., "SESSION_TYPE_INCIDENT")
245
+ hide_grouped_incidents?: boolean; // If true, hides grouped incidents, default: false
246
+ }
247
+ ```
248
+
249
+ **Behavior**:
250
+ 1. Retrieves list of sessions for specified project
251
+ 2. Supports pagination using page/limit parameters
252
+ 3. Can filter by date range using create_time field
253
+ 4. Can filter by investigation status (e.g., not started, in progress, completed)
254
+ 5. Can filter by session type (e.g., incident vs manual investigations)
255
+ 6. Convenience parameter `only_uninvestigated` automatically sets investigation_status to "INVESTIGATION_STATUS_NOT_STARTED" and session_type to "SESSION_TYPE_INCIDENT"
256
+ 7. Can optionally hide grouped incidents
257
+ 8. Returns sessions sorted by creation time (most recent first)
258
+
259
+ **Output**:
260
+ ```typescript
261
+ {
262
+ sessions: Array<{
263
+ session_uuid: string;
264
+ name: string;
265
+ create_time: string;
266
+ last_update: string;
267
+ prompt_cycle_count: number;
268
+ incident_info?: {
269
+ id: string;
270
+ title?: string;
271
+ priority?: string;
272
+ status?: string;
273
+ type?: string;
274
+ grouped_incidents?: {
275
+ id: string[];
276
+ reason: string;
277
+ };
278
+ };
279
+ }>;
280
+ page: number;
281
+ limit: number;
282
+ count: number;
283
+ project_uuid: string;
284
+ filters_applied: {
285
+ date_from?: string;
286
+ date_to?: string;
287
+ investigation_status?: string;
288
+ session_type?: string;
289
+ only_uninvestigated?: boolean;
290
+ hide_grouped_incidents?: boolean;
291
+ };
292
+ }
293
+ ```
294
+
295
+ ### 7. `hawkeye_inspect_session`
296
+
297
+ **Description**: Gets detailed information about a session including all prompt cycles, chain of thoughts, sources, and follow-up suggestions.
298
+
299
+ **Input Schema**:
300
+ ```typescript
301
+ {
302
+ session_uuid: string;
303
+ project_uuid?: string; // Optional: will auto-detect if not provided
304
+ organization_uuid?: string; // Optional: defaults to ORGANIZATION_NAME_ROOT
305
+ }
306
+ ```
307
+
308
+ **Behavior**:
309
+ 1. Retrieves full session details using /api/v1/inference/session/inspect
310
+ 2. Returns all prompt cycles with detailed information
311
+ 3. Includes chain of thoughts (analysis steps)
312
+ 4. Includes sources used in the investigation
313
+ 5. Includes follow-up suggestions
314
+
315
+ **Output**:
316
+ ```typescript
317
+ {
318
+ session_info: {
319
+ session_uuid: string;
320
+ name: string;
321
+ create_time: string;
322
+ last_update: string;
323
+ };
324
+ prompt_cycles: Array<{
325
+ id: string;
326
+ status: string; // PROMPT_STATUS_COMPLETED, PROMPT_STATUS_ERROR, etc.
327
+ request: {
328
+ messages: Array<{
329
+ content: {
330
+ content_type: string;
331
+ parts: string[];
332
+ };
333
+ }>;
334
+ };
335
+ final_answer?: string;
336
+ chain_of_thoughts: Array<{
337
+ description: string;
338
+ investigation?: string;
339
+ }>;
340
+ sources: Array<{
341
+ id?: string;
342
+ title?: string;
343
+ // ... other source fields
344
+ }>;
345
+ follow_up_suggestions: string[];
346
+ }>;
347
+ }
348
+ ```
349
+
350
+ ### 8. `hawkeye_get_session_report`
351
+
352
+ **Description**: Gets a summary report for one or more sessions, including time saved metrics.
353
+
354
+ **Input Schema**:
355
+ ```typescript
356
+ {
357
+ session_uuids: string[]; // Array of session UUIDs (can be single or multiple)
358
+ project_uuid: string; // Required: project UUID
359
+ }
360
+ ```
361
+
362
+ **Behavior**:
363
+ 1. Retrieves session reports using GET /api/v1/inference/session_report
364
+ 2. Can fetch reports for multiple sessions in one call
365
+ 3. Includes summary and time-saved metrics
366
+
367
+ **Output**:
368
+ ```typescript
369
+ {
370
+ reports: Array<{
371
+ create_time: string;
372
+ prompt: string;
373
+ session_link: string;
374
+ summary: string;
375
+ time_saved: number; // in seconds
376
+ }>;
377
+ }
378
+ ```
379
+
380
+ ### 9. `hawkeye_get_session_summary`
381
+
382
+ **Description**: Gets detailed analysis and scoring for a session, including accuracy and completeness metrics.
383
+
384
+ **Input Schema**:
385
+ ```typescript
386
+ {
387
+ session_uuid: string;
388
+ }
389
+ ```
390
+
391
+ **Behavior**:
392
+ 1. Retrieves session summary using GET /api/v1/inference/session/summary/{uuid}
393
+ 2. Returns detailed scoring information if available
394
+ 3. Includes qualitative feedback and improvement suggestions
395
+
396
+ **Output**:
397
+ ```typescript
398
+ {
399
+ analysis_score?: {
400
+ accuracy: {
401
+ root_cause_correct: 'Yes' | 'No' | 'Partial';
402
+ impact_analysis_correct: 'Yes' | 'No' | 'Partial';
403
+ timeline_accurate: 'Yes' | 'No' | 'Partial';
404
+ overall_score: number;
405
+ };
406
+ completeness: {
407
+ data_sources: number;
408
+ remediation_steps: number;
409
+ prevention_measures: number;
410
+ business_impact: number;
411
+ overall_score: number;
412
+ };
413
+ qualitative: {
414
+ trust_without_review: 'Yes' | 'No' | 'Maybe';
415
+ missing_elements: string;
416
+ additional_notes: string;
417
+ improvement_suggestions: string;
418
+ };
419
+ scored_by: string;
420
+ scored_during_call: boolean;
421
+ call_recording_url: string | null;
422
+ };
423
+ }
424
+ ```
425
+
426
+ ### 10. `hawkeye_get_incident_report`
427
+
428
+ **Description**: Gets comprehensive incident statistics and analytics across all investigations.
429
+
430
+ **Input Schema**:
431
+ ```typescript
432
+ {
433
+ // No parameters required - returns organization-wide stats
434
+ }
435
+ ```
436
+
437
+ **Behavior**:
438
+ 1. Retrieves incident report using GET /api/v1/inference/incident_report
439
+ 2. Returns organization-wide incident analytics
440
+ 3. Includes time saved metrics, MTTR, and noise reduction stats
441
+
442
+ **Output**:
443
+ ```typescript
444
+ {
445
+ avg_investigation_time_saved_minutes: number;
446
+ avg_mttr: number; // Mean Time To Resolution
447
+ end_time: string;
448
+ start_time: string;
449
+ incident_type_reports: Array<{
450
+ incident_type: string;
451
+ priority_reports: Array<{
452
+ avg_investigation_time_minutes: number;
453
+ avg_mttr: number;
454
+ avg_time_saved_minutes: number;
455
+ investigated_incidents: number;
456
+ percent_grouped: number;
457
+ priority: string; // e.g., "P1", "P2", "P3"
458
+ total_incidents: number;
459
+ }>;
460
+ }>;
461
+ noise_reduction: number; // Percentage
462
+ total_incidents: number;
463
+ total_investigation_time_saved_hours: number;
464
+ total_investigations: number;
465
+ }
466
+ ```
467
+
468
+ ### 11. `hawkeye_configure_defaults`
469
+
470
+ **Description**: Sets default project and preferences for the session.
471
+
472
+ **Input Schema**:
473
+ ```typescript
474
+ {
475
+ default_project_uuid?: string;
476
+ default_organization_uuid?: string;
477
+ default_timeframe?: string; // e.g., "last 1 hour"
478
+ enable_streaming?: boolean;
479
+ }
480
+ ```
481
+
482
+ **Output**:
483
+ ```typescript
484
+ {
485
+ status: "configured";
486
+ current_defaults: {
487
+ project_uuid: string;
488
+ organization_uuid: string;
489
+ timeframe: string;
490
+ streaming_enabled: boolean;
491
+ };
492
+ }
493
+ ```
494
+
495
+ ## Filtering and Search Capabilities
496
+
497
+ ### Investigation Status Filtering
498
+
499
+ The `hawkeye_list_sessions` tool supports filtering sessions by investigation status. This allows you to find incidents based on whether they've been investigated or not.
500
+
501
+ **Supported Investigation Statuses**:
502
+ - `INVESTIGATION_STATUS_NOT_STARTED` - Incidents that have not been investigated yet
503
+ - `INVESTIGATION_STATUS_IN_PROGRESS` - Investigations currently in progress
504
+ - `INVESTIGATION_STATUS_COMPLETED` - Completed investigations
505
+
506
+ **Example - Find uninvestigated incidents**:
507
+ ```json
508
+ {
509
+ "investigation_status": "INVESTIGATION_STATUS_NOT_STARTED",
510
+ "session_type": "SESSION_TYPE_INCIDENT"
511
+ }
512
+ ```
513
+
514
+ **Convenience Parameter**:
515
+ For the common use case of finding uninvestigated incidents, use the `only_uninvestigated` parameter:
516
+ ```json
517
+ {
518
+ "only_uninvestigated": true
519
+ }
520
+ ```
521
+ This automatically sets both `investigation_status` and `session_type` to the appropriate values.
522
+
523
+ ### Session Type Filtering
524
+
525
+ Filter sessions by their type to distinguish between automated incident investigations and manual investigations.
526
+
527
+ **Supported Session Types**:
528
+ - `SESSION_TYPE_INCIDENT` - Automated incident investigations triggered by alerts
529
+ - `SESSION_TYPE_MANUAL` - Manual investigations created by users
530
+
531
+ ### Date Range Filtering
532
+
533
+ Filter sessions by creation date using `date_from` and `date_to` parameters:
534
+
535
+ ```json
536
+ {
537
+ "date_from": "2024-01-01",
538
+ "date_to": "2024-01-31"
539
+ }
540
+ ```
541
+
542
+ Supports:
543
+ - ISO 8601 date strings (e.g., "2024-01-01")
544
+ - ISO 8601 datetime strings (e.g., "2024-01-01T00:00:00Z")
545
+
546
+ ### Grouped Incidents
547
+
548
+ Some incidents may be automatically grouped by Hawkeye when they share similar characteristics. Use the `hide_grouped_incidents` parameter to exclude these from results:
549
+
550
+ ```json
551
+ {
552
+ "hide_grouped_incidents": true
553
+ }
554
+ ```
555
+
556
+ ### Combining Filters
557
+
558
+ All filters can be combined for precise queries:
559
+
560
+ ```json
561
+ {
562
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24",
563
+ "only_uninvestigated": true,
564
+ "date_from": "2024-01-01",
565
+ "hide_grouped_incidents": true,
566
+ "limit": 20
567
+ }
568
+ ```
569
+
570
+ ## Core Services
571
+
572
+ ### AuthenticationService
573
+
574
+ **Responsibilities**:
575
+ - Authenticate using email/password from environment variables
576
+ - Cache authentication tokens
577
+ - Refresh tokens before expiry
578
+ - Handle authentication failures gracefully
579
+
580
+ **Configuration**:
581
+ ```typescript
582
+ {
583
+ HAWKEYE_EMAIL: string; // From .env
584
+ HAWKEYE_PASSWORD: string; // From .env
585
+ HAWKEYE_BASE_URL: string; // From .env, default: https://sandbox.app.neubird.ai/api
586
+ TOKEN_REFRESH_BUFFER: number; // Default: 5 minutes before expiry
587
+ }
588
+ ```
589
+
590
+ ### SessionManager
591
+
592
+ **Responsibilities**:
593
+ - Create and manage investigation sessions
594
+ - Send prompts to sessions
595
+ - Poll for session completion
596
+ - Inspect session details
597
+ - Retrieve investigation results
598
+ - Handle streaming responses
599
+
600
+ **Key Methods**:
601
+ ```typescript
602
+ async createSession(projectUuid: string, organizationUuid: string): Promise<Session>;
603
+ async sendPrompt(sessionUuid: string, projectUuid: string, prompt: string, options?: PromptOptions): Promise<PromptResponse>;
604
+ async inspectSession(sessionUuid: string, projectUuid: string, organizationUuid: string): Promise<SessionDetails>;
605
+ async pollForCompletion(sessionUuid: string, maxAttempts: number, intervalMs: number): Promise<SessionDetails>;
606
+ async findSessionsByAlertId(alertId: string, projectUuid: string, organizationUuid: string): Promise<Session[]>;
607
+ ```
608
+
609
+ ### ProjectManager
610
+
611
+ **Responsibilities**:
612
+ - List available projects
613
+ - Get project details
614
+ - Auto-select appropriate project based on context
615
+ - Manage project preferences
616
+
617
+ **Key Methods**:
618
+ ```typescript
619
+ async listProjects(): Promise<Project[]>;
620
+ async getProject(projectUuid: string): Promise<Project>;
621
+ async getDefaultProject(): Promise<Project>;
622
+ async setDefaultProject(projectUuid: string): Promise<void>;
623
+ ```
624
+
625
+ ### TimeframeParser
626
+
627
+ **Responsibilities**:
628
+ - Parse natural language timeframes (e.g., "last 2 hours", "past 24 hours", "yesterday")
629
+ - Convert to ISO 8601 timestamps
630
+ - Validate timeframe inputs
631
+ - Provide intelligent defaults
632
+
633
+ **Supported Formats**:
634
+ - "last X hours/minutes/days/weeks"
635
+ - "past X hours/minutes/days/weeks"
636
+ - "since YYYY-MM-DD"
637
+ - "between YYYY-MM-DD and YYYY-MM-DD"
638
+ - ISO 8601 timestamps
639
+ - Relative time strings
640
+
641
+ **Key Methods**:
642
+ ```typescript
643
+ parseTimeframe(input: string): { start: Date, end: Date, description: string };
644
+ formatForPrompt(timeframe: { start: Date, end: Date }): string;
645
+ validateTimeframe(start: Date, end: Date): boolean;
646
+ ```
647
+
648
+ ### StreamingHandler
649
+
650
+ **Responsibilities**:
651
+ - Handle Server-Sent Events (SSE) from Hawkeye API
652
+ - Parse streaming response chunks
653
+ - Extract progress updates
654
+ - Detect completion
655
+ - Aggregate final results
656
+
657
+ **Key Methods**:
658
+ ```typescript
659
+ async streamPromptResponse(sessionUuid: string, projectUuid: string, prompt: string, onProgress: (data: ProgressUpdate) => void): Promise<CompletedResponse>;
660
+ ```
661
+
662
+ ## Configuration
663
+
664
+ ### Environment Variables
665
+
666
+ ```bash
667
+ # Required
668
+ HAWKEYE_EMAIL=user@example.com
669
+ HAWKEYE_PASSWORD=your_password
670
+ HAWKEYE_BASE_URL=https://your-app.app.neubird.ai/api
671
+
672
+ # Optional
673
+ HAWKEYE_DEFAULT_PROJECT_UUID=uuid-here
674
+ HAWKEYE_DEFAULT_ORGANIZATION_UUID=ORGANIZATION_NAME_ROOT
675
+ HAWKEYE_DEFAULT_TIMEFRAME="last 1 hour"
676
+ HAWKEYE_ENABLE_STREAMING=true
677
+ HAWKEYE_MAX_POLL_ATTEMPTS=30
678
+ HAWKEYE_POLL_INTERVAL_MS=2000
679
+ ```
680
+
681
+ ### Server Configuration
682
+
683
+ ```typescript
684
+ {
685
+ name: "hawkeye-mcp-server",
686
+ version: "2.0.0",
687
+ capabilities: {
688
+ tools: {},
689
+ logging: {},
690
+ resources: {} // For caching investigation results
691
+ }
692
+ }
693
+ ```
694
+
695
+ ## Error Handling
696
+
697
+ ### Error Types
698
+
699
+ 1. **Authentication Errors**
700
+ - Invalid credentials
701
+ - Token expiration
702
+ - Network connectivity issues
703
+
704
+ 2. **API Errors**
705
+ - Rate limiting
706
+ - Invalid requests
707
+ - Server errors
708
+ - Timeouts
709
+
710
+ 3. **Validation Errors**
711
+ - Invalid alert IDs
712
+ - Invalid timeframes
713
+ - Missing required parameters
714
+
715
+ 4. **Investigation Errors**
716
+ - Session creation failures
717
+ - Prompt sending failures
718
+ - Investigation timeouts
719
+ - No results found
720
+
721
+ ### Error Response Format
722
+
723
+ ```typescript
724
+ {
725
+ error: {
726
+ type: "authentication" | "api" | "validation" | "investigation" | "unknown";
727
+ message: string;
728
+ details?: any;
729
+ recovery_suggestions?: string[];
730
+ }
731
+ }
732
+ ```
733
+
734
+ ## Performance Considerations
735
+
736
+ ### Caching Strategy
737
+
738
+ 1. **Authentication Tokens**: Cache for 55 minutes (with 5-minute buffer)
739
+ 2. **Project List**: Cache for 5 minutes
740
+ 3. **Completed Investigations**: Cache for 1 hour
741
+ 4. **Session Status**: No caching (always fetch fresh)
742
+
743
+ ### Rate Limiting
744
+
745
+ - Implement exponential backoff for API requests
746
+ - Respect API rate limits (if specified by Hawkeye)
747
+ - Queue requests if necessary
748
+
749
+ ### Optimization
750
+
751
+ - Parallel project and session listing when possible
752
+ - Lazy-load investigation details
753
+ - Stream large responses
754
+ - Compress request/response payloads where supported
755
+
756
+ ## Security Considerations
757
+
758
+ 1. **Credential Management**
759
+ - Never log passwords or tokens
760
+ - Store credentials in environment variables only
761
+ - Clear sensitive data from memory after use
762
+
763
+ 2. **Input Validation**
764
+ - Validate all user inputs
765
+ - Sanitize alert IDs and prompts
766
+ - Prevent injection attacks
767
+
768
+ 3. **Output Sanitization**
769
+ - Strip potentially sensitive information from responses
770
+ - Sanitize HTML in investigation results
771
+
772
+ ## Testing Strategy
773
+
774
+ ### Unit Tests
775
+
776
+ - Test each service independently
777
+ - Mock API responses
778
+ - Validate input/output schemas
779
+ - Test error handling paths
780
+
781
+ ### Integration Tests
782
+
783
+ - Test against Hawkeye staging/sandbox environment
784
+ - Validate end-to-end workflows
785
+ - Test streaming functionality
786
+ - Test timeout handling
787
+
788
+ ### E2E Tests with Cursor
789
+
790
+ - Test natural language interactions
791
+ - Validate agent understanding of tool outputs
792
+ - Test multi-turn investigations
793
+ - Test error recovery
794
+
795
+ ## Implementation Phases
796
+
797
+ ### Phase 1: Core Infrastructure ✅ (COMPLETED)
798
+ - Authentication service
799
+ - Session manager
800
+ - Project manager
801
+ - Basic MCP tool scaffolding
802
+ - `hawkeye_list_projects`
803
+
804
+ ### Phase 2: Investigation Tools ✅ (COMPLETED)
805
+ - `hawkeye_investigate_alert`
806
+ - `hawkeye_get_investigation_status`
807
+ - `hawkeye_continue_investigation`
808
+
809
+ ### Phase 3: Session Management & Analytics ✅ (COMPLETED)
810
+ - `hawkeye_list_sessions` - List sessions with pagination, date filtering, and investigation status filtering
811
+ - Supports filtering by investigation_status (e.g., not started, in progress, completed)
812
+ - Supports filtering by session_type (e.g., incident vs manual)
813
+ - Convenience parameter for uninvestigated incidents
814
+ - Option to hide grouped incidents
815
+ - `hawkeye_inspect_session` - Get detailed session information
816
+ - `hawkeye_get_session_report` - Get session summaries and time-saved metrics
817
+ - `hawkeye_get_session_summary` - Get detailed analysis scores
818
+ - `hawkeye_get_incident_report` - Get organization-wide analytics
819
+
820
+ ### Phase 4: Advanced Investigation Features (PLANNED)
821
+ - `hawkeye_create_investigation` - Custom investigations with timeframes
822
+ - Timeframe parser for natural language date inputs
823
+ - Enhanced prompt engineering for context-aware investigations
824
+
825
+ ### Phase 5: Streaming & Real-time Updates (PLANNED)
826
+ - Streaming support for long-running investigations
827
+ - Real-time progress updates
828
+ - WebSocket or SSE support
829
+
830
+ ### Phase 6: Optimization & Polish
831
+ - Caching strategies
832
+ - Error handling improvements
833
+ - Performance optimization
834
+ - Rate limiting and retry logic
835
+ - Comprehensive documentation and examples
836
+
837
+ ## Documentation Requirements
838
+
839
+ ### For Developers
840
+
841
+ 1. **Setup Guide**: How to install and configure the MCP server
842
+ 2. **Tool Reference**: Detailed documentation for each tool
843
+ 3. **Examples**: Common use cases with example prompts
844
+ 4. **Troubleshooting**: Common issues and solutions
845
+
846
+ ### For AI Agents
847
+
848
+ 1. **Tool Descriptions**: Clear, concise descriptions for each tool
849
+ 2. **Example Interactions**: Sample prompts and expected responses
850
+ 3. **Error Handling**: How to interpret and recover from errors
851
+ 4. **Best Practices**: Optimal usage patterns
852
+
853
+ ## Example Interactions
854
+
855
+ ### Example 1: List Recent Sessions
856
+
857
+ **User to Cursor**:
858
+ ```
859
+ Show me the recent investigations from the HTM-Azure project from the last week
860
+ ```
861
+
862
+ **Cursor calls**:
863
+ ```json
864
+ {
865
+ "tool": "hawkeye_list_sessions",
866
+ "arguments": {
867
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24",
868
+ "limit": 20,
869
+ "date_from": "2024-01-14"
870
+ }
871
+ }
872
+ ```
873
+
874
+ ### Example 1a: List Uninvestigated Incidents
875
+
876
+ **User to Cursor**:
877
+ ```
878
+ Show me all the incidents that haven't been investigated yet in the HTM-Azure project
879
+ ```
880
+
881
+ **Cursor calls**:
882
+ ```json
883
+ {
884
+ "tool": "hawkeye_list_sessions",
885
+ "arguments": {
886
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24",
887
+ "only_uninvestigated": true,
888
+ "limit": 50
889
+ }
890
+ }
891
+ ```
892
+
893
+ **Alternative using explicit filters**:
894
+ ```json
895
+ {
896
+ "tool": "hawkeye_list_sessions",
897
+ "arguments": {
898
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24",
899
+ "investigation_status": "INVESTIGATION_STATUS_NOT_STARTED",
900
+ "session_type": "SESSION_TYPE_INCIDENT",
901
+ "limit": 50
902
+ }
903
+ }
904
+ ```
905
+
906
+ ### Example 2: Get Session Details
907
+
908
+ **User to Cursor**:
909
+ ```
910
+ Can you show me the detailed analysis from session abc-123, including all the sources it used?
911
+ ```
912
+
913
+ **Cursor calls**:
914
+ ```json
915
+ {
916
+ "tool": "hawkeye_inspect_session",
917
+ "arguments": {
918
+ "session_uuid": "abc-123",
919
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24"
920
+ }
921
+ }
922
+ ```
923
+
924
+ ### Example 3: Get Incident Analytics
925
+
926
+ **User to Cursor**:
927
+ ```
928
+ Show me the overall incident statistics and how much time Hawkeye has saved us
929
+ ```
930
+
931
+ **Cursor calls**:
932
+ ```json
933
+ {
934
+ "tool": "hawkeye_get_incident_report",
935
+ "arguments": {}
936
+ }
937
+ ```
938
+
939
+ ### Example 4: Get Session Report with Time Saved
940
+
941
+ **User to Cursor**:
942
+ ```
943
+ Give me a summary report for these three investigations
944
+ ```
945
+
946
+ **Cursor calls**:
947
+ ```json
948
+ {
949
+ "tool": "hawkeye_get_session_report",
950
+ "arguments": {
951
+ "session_uuids": ["session-1", "session-2", "session-3"],
952
+ "project_uuid": "74acc801-3428-4292-8a74-ae16ecb71c24"
953
+ }
954
+ }
955
+ ```
956
+
957
+ ### Example 5: Investigate an Alert
958
+
959
+ **User to Cursor**:
960
+ ```
961
+ Can you investigate alert /subscriptions/cb3bc010-0fc7-476a-8577-03c3e45e2296/resourcegroups/test123/providers/microsoft.insights/components/test123-insights/providers/Microsoft.AlertsManagement/alerts/08f9c803-6bff-4030-bbe8-300a993af000?
962
+ ```
963
+
964
+ **Cursor calls**:
965
+ ```json
966
+ {
967
+ "tool": "hawkeye_investigate_alert",
968
+ "arguments": {
969
+ "alert_id": "/subscriptions/cb3bc010-0fc7-476a-8577-03c3e45e2296/resourcegroups/test123/providers/microsoft.insights/components/test123-insights/providers/Microsoft.AlertsManagement/alerts/08f9c803-6bff-4030-bbe8-300a993af000",
970
+ "wait_for_completion": true,
971
+ "max_wait_seconds": 300
972
+ }
973
+ }
974
+ ```
975
+
976
+ ### Example 6: Create Custom Investigation
977
+
978
+ **User to Cursor**:
979
+ ```
980
+ Analyze my EKS cluster security for the last 2 hours
981
+ ```
982
+
983
+ **Cursor calls**:
984
+ ```json
985
+ {
986
+ "tool": "hawkeye_create_investigation",
987
+ "arguments": {
988
+ "prompt": "Analyze my EKS cluster for security vulnerabilities and misconfigurations",
989
+ "timeframe": "last 2 hours",
990
+ "wait_for_completion": true
991
+ }
992
+ }
993
+ ```
994
+
995
+ ### Example 7: Follow-up Investigation
996
+
997
+ **User to Cursor**:
998
+ ```
999
+ Can you dig deeper into the network policy issues you found?
1000
+ ```
1001
+
1002
+ **Cursor calls**:
1003
+ ```json
1004
+ {
1005
+ "tool": "hawkeye_continue_investigation",
1006
+ "arguments": {
1007
+ "session_uuid": "previous-session-uuid",
1008
+ "follow_up_prompt": "Please provide more details about the network policy issues, including specific configurations that need to be addressed",
1009
+ "wait_for_completion": true
1010
+ }
1011
+ }
1012
+ ```
1013
+
1014
+ ## Success Metrics
1015
+
1016
+ 1. **Response Time**: < 500ms for non-investigation tools, < 5 minutes for investigations
1017
+ 2. **Success Rate**: > 95% successful API calls
1018
+ 3. **Developer Satisfaction**: Natural, intuitive interactions with minimal friction
1019
+ 4. **Cache Hit Rate**: > 80% for authentication tokens and project lists
1020
+ 5. **Error Recovery**: Clear, actionable error messages with recovery suggestions
1021
+
1022
+ ## Future Enhancements
1023
+
1024
+ 1. **Proactive Monitoring**: Subscribe to alerts and automatically trigger investigations
1025
+ 2. **Multi-Cloud Support**: Extend beyond current cloud providers
1026
+ 3. **Investigation Templates**: Pre-defined investigation templates for common scenarios
1027
+ 4. **Collaborative Investigations**: Share and collaborate on investigations
1028
+ 5. **Historical Analysis**: Trend analysis across multiple investigations
1029
+ 6. **Custom Integrations**: Webhooks, Slack notifications, etc.
1030
+ 7. **Advanced Filtering Enhancements**: Additional filtering capabilities such as:
1031
+ - Full-text search across session names and incident titles
1032
+ - Filter by priority (P1, P2, P3, P4)
1033
+ - Filter by incident type (FIREHYDRANT, PAGERDUTY, etc.)
1034
+ - Filter by time range with more granular controls
1035
+ - Saved filter presets
1036
+ 8. **Investigation Chaining**: Automatically trigger related investigations
1037
+
1038
+ ---
1039
+
1040
+ ## Questions for Clarification
1041
+
1042
+ Before implementation, please clarify:
1043
+
1044
+ 1. **Organization UUID**: Is there a single organization UUID or should we support multiple? Should this be auto-detected?
1045
+
1046
+ 2. **Project Selection**: Should the server:
1047
+ - Auto-detect the appropriate project based on alert content?
1048
+ - Always use a default project from config?
1049
+ - Ask the user to specify?
1050
+
1051
+ 3. **Streaming Preference**: Should streaming be:
1052
+ - Default enabled for all investigations?
1053
+ - Optional based on investigation type?
1054
+ - User-configurable per request?
1055
+
1056
+ 4. **Investigation Timeout**: What's a reasonable timeout for investigations?
1057
+ - 5 minutes?
1058
+ - 10 minutes?
1059
+ - Configurable based on investigation type?
1060
+
1061
+ 5. **Pagination**: Should we support pagination for:
1062
+ - Project lists?
1063
+ - Session lists?
1064
+ - Investigation results?
1065
+
1066
+ 6. **Alert ID Format**: Are there different alert ID formats we need to support beyond the Azure format shown?
1067
+
1068
+ 7. **Additional Context**: Should investigations include:
1069
+ - Git commit information?
1070
+ - Recent deployments?
1071
+ - Related code changes?
1072
+
1073
+ 8. **Cost Considerations**: Are there API rate limits or costs we should be aware of?