awslabs.cloudwatch-applicationsignals-mcp-server 0.1.21__py3-none-any.whl
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.
- awslabs/__init__.py +17 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/__init__.py +17 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/audit_presentation_utils.py +288 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/audit_utils.py +912 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/aws_clients.py +120 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/canary_utils.py +910 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-dotnet-enablement.md +435 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-java-enablement.md +321 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-nodejs-enablement.md +420 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ec2/ec2-python-enablement.md +598 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-dotnet-enablement.md +264 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-java-enablement.md +193 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-nodejs-enablement.md +198 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/ecs/ecs-python-enablement.md +236 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-dotnet-enablement.md +166 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-java-enablement.md +166 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-nodejs-enablement.md +166 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/eks/eks-python-enablement.md +169 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-dotnet-enablement.md +336 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-java-enablement.md +336 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-nodejs-enablement.md +336 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_guides/templates/lambda/lambda-python-enablement.md +336 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/enablement_tools.py +147 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/server.py +1505 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/service_audit_utils.py +231 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/service_tools.py +659 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/sli_report_client.py +333 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/slo_tools.py +386 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/trace_tools.py +784 -0
- awslabs/cloudwatch_applicationsignals_mcp_server/utils.py +172 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/METADATA +808 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/RECORD +36 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/WHEEL +4 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/entry_points.txt +2 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/licenses/LICENSE +174 -0
- awslabs_cloudwatch_applicationsignals_mcp_server-0.1.21.dist-info/licenses/NOTICE +2 -0
awslabs/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
# This file is part of the awslabs namespace.
|
|
16
|
+
# It is intentionally minimal to support PEP 420 namespace packages.
|
|
17
|
+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""AWS Application Signals MCP Server."""
|
|
16
|
+
|
|
17
|
+
__version__ = '0.1.21'
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Utilities for presenting audit findings and managing user interaction."""
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
from loguru import logger
|
|
19
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def extract_findings_summary(audit_result: str) -> Tuple[List[Dict[str, Any]], str]:
|
|
23
|
+
"""Extract findings from audit result and return summary with original result.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
Tuple of (findings_list, original_result)
|
|
27
|
+
"""
|
|
28
|
+
try:
|
|
29
|
+
# Find the JSON part in the audit result
|
|
30
|
+
json_start = audit_result.find('{')
|
|
31
|
+
if json_start == -1:
|
|
32
|
+
return [], audit_result
|
|
33
|
+
|
|
34
|
+
json_part = audit_result[json_start:]
|
|
35
|
+
audit_data = json.loads(json_part)
|
|
36
|
+
|
|
37
|
+
findings = audit_data.get('AuditFindings', [])
|
|
38
|
+
return findings, audit_result
|
|
39
|
+
|
|
40
|
+
except (json.JSONDecodeError, KeyError) as e:
|
|
41
|
+
logger.warning(f'Failed to parse audit result for findings extraction: {e}')
|
|
42
|
+
return [], audit_result
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def format_findings_summary(findings: List[Dict[str, Any]], audit_type: str = 'service') -> str:
|
|
46
|
+
"""Format findings into a user-friendly summary for selection.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
findings: List of audit findings
|
|
50
|
+
audit_type: Type of audit ("service", "slo", "operation")
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Formatted summary string
|
|
54
|
+
"""
|
|
55
|
+
if not findings:
|
|
56
|
+
return f'â
No issues found in {audit_type} audit. All targets appear healthy.'
|
|
57
|
+
|
|
58
|
+
# Group findings by severity
|
|
59
|
+
critical_findings = []
|
|
60
|
+
warning_findings = []
|
|
61
|
+
info_findings = []
|
|
62
|
+
|
|
63
|
+
for finding in findings:
|
|
64
|
+
severity = finding.get('Severity', 'INFO').upper()
|
|
65
|
+
if severity == 'CRITICAL':
|
|
66
|
+
critical_findings.append(finding)
|
|
67
|
+
elif severity == 'WARNING':
|
|
68
|
+
warning_findings.append(finding)
|
|
69
|
+
else:
|
|
70
|
+
info_findings.append(finding)
|
|
71
|
+
|
|
72
|
+
# Build summary
|
|
73
|
+
summary = f'đ **{audit_type.title()} Audit Results Summary**\n\n'
|
|
74
|
+
summary += f'Found **{len(findings)} total findings**:\n'
|
|
75
|
+
|
|
76
|
+
if critical_findings:
|
|
77
|
+
summary += (
|
|
78
|
+
f'đ¨ **{len(critical_findings)} Critical Issues** (require immediate attention)\n'
|
|
79
|
+
)
|
|
80
|
+
if warning_findings:
|
|
81
|
+
summary += f'â ď¸ **{len(warning_findings)} Warning Issues** (should be investigated)\n'
|
|
82
|
+
if info_findings:
|
|
83
|
+
summary += f'âšď¸ **{len(info_findings)} Info Issues** (for awareness)\n'
|
|
84
|
+
|
|
85
|
+
summary += '\n---\n\n'
|
|
86
|
+
|
|
87
|
+
# List findings with selection numbers
|
|
88
|
+
finding_counter = 1
|
|
89
|
+
|
|
90
|
+
if critical_findings:
|
|
91
|
+
summary += 'đ¨ **CRITICAL ISSUES:**\n'
|
|
92
|
+
for finding in critical_findings:
|
|
93
|
+
finding_id = finding.get('FindingId', f'finding-{finding_counter}')
|
|
94
|
+
description = finding.get('Description', 'No description available')
|
|
95
|
+
summary += f'**{finding_counter}.** Finding ID: {finding_id}\n'
|
|
96
|
+
summary += f' đŹ {description}\n\n'
|
|
97
|
+
finding_counter += 1
|
|
98
|
+
|
|
99
|
+
if warning_findings:
|
|
100
|
+
summary += 'â ď¸ **WARNING ISSUES:**\n'
|
|
101
|
+
for finding in warning_findings:
|
|
102
|
+
finding_id = finding.get('FindingId', f'finding-{finding_counter}')
|
|
103
|
+
description = finding.get('Description', 'No description available')
|
|
104
|
+
summary += f'**{finding_counter}.** Finding ID: {finding_id}\n'
|
|
105
|
+
summary += f' đŹ {description}\n\n'
|
|
106
|
+
finding_counter += 1
|
|
107
|
+
|
|
108
|
+
if info_findings:
|
|
109
|
+
summary += 'âšď¸ **INFORMATIONAL:**\n'
|
|
110
|
+
for finding in info_findings:
|
|
111
|
+
finding_id = finding.get('FindingId', f'finding-{finding_counter}')
|
|
112
|
+
description = finding.get('Description', 'No description available')
|
|
113
|
+
summary += f'**{finding_counter}.** Finding ID: {finding_id}\n'
|
|
114
|
+
summary += f' đŹ {description}\n\n'
|
|
115
|
+
finding_counter += 1
|
|
116
|
+
|
|
117
|
+
summary += '---\n\n'
|
|
118
|
+
summary += 'đŻ **Next Steps:**\n'
|
|
119
|
+
summary += "To investigate any specific issue in detail, please let me know which finding number you'd like me to analyze further.\n"
|
|
120
|
+
summary += 'I can perform comprehensive root cause analysis including traces, logs, metrics, and dependencies.\n\n'
|
|
121
|
+
summary += '**Example:** "Please investigate finding #1 in detail" or "Show me root cause analysis for finding #3"\n'
|
|
122
|
+
|
|
123
|
+
return summary
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def create_targeted_audit_request(
|
|
127
|
+
original_targets: List[Dict[str, Any]],
|
|
128
|
+
findings: List[Dict[str, Any]],
|
|
129
|
+
selected_finding_index: int,
|
|
130
|
+
audit_type: str,
|
|
131
|
+
) -> Dict[str, Any]:
|
|
132
|
+
"""Create a targeted audit request for a specific finding.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
original_targets: Original audit targets
|
|
136
|
+
findings: List of all findings
|
|
137
|
+
selected_finding_index: Index of the selected finding (1-based)
|
|
138
|
+
audit_type: Type of audit ("service", "slo", "operation")
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Dictionary with targeted audit parameters
|
|
142
|
+
"""
|
|
143
|
+
if selected_finding_index < 1 or selected_finding_index > len(findings):
|
|
144
|
+
raise ValueError(
|
|
145
|
+
f'Invalid finding index {selected_finding_index}. Must be between 1 and {len(findings)}'
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
selected_finding = findings[selected_finding_index - 1]
|
|
149
|
+
target_name = selected_finding.get('TargetName', '')
|
|
150
|
+
|
|
151
|
+
# Find the matching target from original targets
|
|
152
|
+
targeted_targets = []
|
|
153
|
+
|
|
154
|
+
for target in original_targets:
|
|
155
|
+
target_matches = False
|
|
156
|
+
|
|
157
|
+
if audit_type == 'service':
|
|
158
|
+
service_data = target.get('Data', {}).get('Service', {})
|
|
159
|
+
service_name = service_data.get('Name', '')
|
|
160
|
+
if service_name == target_name:
|
|
161
|
+
target_matches = True
|
|
162
|
+
elif audit_type == 'slo':
|
|
163
|
+
slo_data = target.get('Data', {}).get('Slo', {})
|
|
164
|
+
slo_name = slo_data.get('SloName', '')
|
|
165
|
+
if slo_name == target_name:
|
|
166
|
+
target_matches = True
|
|
167
|
+
elif audit_type == 'operation':
|
|
168
|
+
service_op_data = target.get('Data', {}).get('ServiceOperation', {})
|
|
169
|
+
service_data = service_op_data.get('Service', {})
|
|
170
|
+
service_name = service_data.get('Name', '')
|
|
171
|
+
operation = service_op_data.get('Operation', '')
|
|
172
|
+
# For operations, target name might be "service-name:operation"
|
|
173
|
+
if f'{service_name}:{operation}' == target_name or service_name == target_name:
|
|
174
|
+
target_matches = True
|
|
175
|
+
|
|
176
|
+
if target_matches:
|
|
177
|
+
targeted_targets.append(target)
|
|
178
|
+
|
|
179
|
+
if not targeted_targets:
|
|
180
|
+
# If we can't find exact match, create a new target based on the finding
|
|
181
|
+
logger.warning(
|
|
182
|
+
f'Could not find exact target match for finding {selected_finding_index}, creating new target'
|
|
183
|
+
)
|
|
184
|
+
if audit_type == 'service':
|
|
185
|
+
targeted_targets = [
|
|
186
|
+
{'Type': 'service', 'Data': {'Service': {'Type': 'Service', 'Name': target_name}}}
|
|
187
|
+
]
|
|
188
|
+
elif audit_type == 'slo':
|
|
189
|
+
targeted_targets = [{'Type': 'slo', 'Data': {'Slo': {'SloName': target_name}}}]
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
'targets': targeted_targets,
|
|
193
|
+
'finding': selected_finding,
|
|
194
|
+
'auditors': 'all', # Use all auditors for comprehensive root cause analysis
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def format_detailed_finding_analysis(finding: Dict[str, Any], detailed_result: str) -> str:
|
|
199
|
+
"""Format the detailed analysis result for a specific finding.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
finding: The specific finding being analyzed
|
|
203
|
+
detailed_result: The detailed audit result
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
Formatted analysis string
|
|
207
|
+
"""
|
|
208
|
+
target_name = finding.get('TargetName', 'Unknown Target')
|
|
209
|
+
finding_type = finding.get('FindingType', 'Unknown')
|
|
210
|
+
title = finding.get('Title', 'No title')
|
|
211
|
+
severity = finding.get('Severity', 'INFO').upper()
|
|
212
|
+
|
|
213
|
+
# Severity emoji mapping
|
|
214
|
+
severity_emoji = {'CRITICAL': 'đ¨', 'WARNING': 'â ď¸', 'INFO': 'âšď¸'}
|
|
215
|
+
|
|
216
|
+
analysis = f'{severity_emoji.get(severity, "âšď¸")} **DETAILED ROOT CAUSE ANALYSIS**\n\n'
|
|
217
|
+
analysis += f'**Target:** {target_name}\n'
|
|
218
|
+
analysis += f'**Issue Type:** {finding_type}\n'
|
|
219
|
+
analysis += f'**Severity:** {severity}\n'
|
|
220
|
+
analysis += f'**Title:** {title}\n\n'
|
|
221
|
+
|
|
222
|
+
# Add the original finding description if available
|
|
223
|
+
description = finding.get('Description', '')
|
|
224
|
+
if description:
|
|
225
|
+
analysis += f'**Issue Description:**\n{description}\n\n'
|
|
226
|
+
|
|
227
|
+
analysis += '---\n\n'
|
|
228
|
+
analysis += '**COMPREHENSIVE ANALYSIS RESULTS:**\n\n'
|
|
229
|
+
analysis += detailed_result
|
|
230
|
+
|
|
231
|
+
return analysis
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def format_pagination_info(
|
|
235
|
+
has_wildcards: bool,
|
|
236
|
+
names_in_batch: list,
|
|
237
|
+
returned_next_token: Optional[str],
|
|
238
|
+
unix_start: int,
|
|
239
|
+
unix_end: int,
|
|
240
|
+
tool_name: str,
|
|
241
|
+
max_param_name: str,
|
|
242
|
+
max_param_value: int,
|
|
243
|
+
item_type: str = 'services',
|
|
244
|
+
) -> str:
|
|
245
|
+
"""Helper function to format pagination information for audit tools.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
has_wildcards: Whether wildcards were used
|
|
249
|
+
names_in_batch: List of item names processed in this batch
|
|
250
|
+
returned_next_token: Token for next batch, if any
|
|
251
|
+
unix_start: Start time as unix timestamp
|
|
252
|
+
unix_end: End time as unix timestamp
|
|
253
|
+
tool_name: Name of the audit tool (e.g., 'audit_services')
|
|
254
|
+
max_param_name: Name of the max parameter (e.g., 'max_services')
|
|
255
|
+
max_param_value: Value of the max parameter
|
|
256
|
+
item_type: Type of items being processed (e.g., 'services', 'SLOs')
|
|
257
|
+
|
|
258
|
+
Returns:
|
|
259
|
+
Formatted pagination information string
|
|
260
|
+
"""
|
|
261
|
+
if not has_wildcards or not names_in_batch:
|
|
262
|
+
return ''
|
|
263
|
+
|
|
264
|
+
result = ''
|
|
265
|
+
|
|
266
|
+
if returned_next_token:
|
|
267
|
+
# Convert unix timestamps to string format
|
|
268
|
+
start_time_str = str(unix_start)
|
|
269
|
+
end_time_str = str(unix_end)
|
|
270
|
+
result += f'\n\nđ Processed {len(names_in_batch)} {item_type} in this batch:\n'
|
|
271
|
+
for name in names_in_batch:
|
|
272
|
+
result += f' ⢠{name}\n'
|
|
273
|
+
|
|
274
|
+
result += f'\n\nđ PAGINATION: More {item_type} available!\n'
|
|
275
|
+
result += f'â ď¸ IMPORTANT: To continue auditing remaining {item_type}, use:\n'
|
|
276
|
+
result += f' {tool_name}(\n'
|
|
277
|
+
result += f' start_time="{start_time_str}",\n'
|
|
278
|
+
result += f' end_time="{end_time_str}",\n'
|
|
279
|
+
result += f' next_token="{returned_next_token}",\n'
|
|
280
|
+
result += f' {max_param_name}={max_param_value}\n'
|
|
281
|
+
result += ' )\n'
|
|
282
|
+
else:
|
|
283
|
+
result += f'\n\nâ
PAGINATION: Complete! This was the last batch of {item_type}.\n'
|
|
284
|
+
result += f'đ Processed {len(names_in_batch)} {item_type} in final batch:\n'
|
|
285
|
+
for name in names_in_batch:
|
|
286
|
+
result += f' ⢠{name}\n'
|
|
287
|
+
|
|
288
|
+
return result
|