awslabs.cloudwatch-mcp-server 0.0.3__tar.gz

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 (36) hide show
  1. awslabs_cloudwatch_mcp_server-0.0.3/.gitignore +59 -0
  2. awslabs_cloudwatch_mcp_server-0.0.3/.python-version +1 -0
  3. awslabs_cloudwatch_mcp_server-0.0.3/CHANGELOG.md +22 -0
  4. awslabs_cloudwatch_mcp_server-0.0.3/Dockerfile +77 -0
  5. awslabs_cloudwatch_mcp_server-0.0.3/LICENSE +175 -0
  6. awslabs_cloudwatch_mcp_server-0.0.3/NOTICE +2 -0
  7. awslabs_cloudwatch_mcp_server-0.0.3/PKG-INFO +157 -0
  8. awslabs_cloudwatch_mcp_server-0.0.3/README.md +128 -0
  9. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/__init__.py +16 -0
  10. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/__init__.py +17 -0
  11. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_alarms/models.py +156 -0
  12. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_alarms/tools.py +700 -0
  13. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_logs/models.py +194 -0
  14. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_logs/tools.py +649 -0
  15. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_metrics/data/metric_metadata.json +13883 -0
  16. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_metrics/models.py +150 -0
  17. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/cloudwatch_metrics/tools.py +821 -0
  18. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/common.py +51 -0
  19. awslabs_cloudwatch_mcp_server-0.0.3/awslabs/cloudwatch_mcp_server/server.py +56 -0
  20. awslabs_cloudwatch_mcp_server-0.0.3/docker-healthcheck.sh +26 -0
  21. awslabs_cloudwatch_mcp_server-0.0.3/pyproject.toml +139 -0
  22. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_alarms/test_active_alarms.py +575 -0
  23. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_alarms/test_alarm_history.py +512 -0
  24. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_alarms/test_alarm_history_integration.py +657 -0
  25. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_alarms/test_alarms_error_handling.py +528 -0
  26. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_logs/test_logs_error_handling.py +388 -0
  27. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_logs/test_logs_models.py +67 -0
  28. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_logs/test_logs_server.py +394 -0
  29. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_metrics/test_metrics_error_handling.py +548 -0
  30. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_metrics/test_metrics_models.py +346 -0
  31. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_metrics/test_metrics_server.py +611 -0
  32. awslabs_cloudwatch_mcp_server-0.0.3/tests/cloudwatch_metrics/test_validation_error.py +63 -0
  33. awslabs_cloudwatch_mcp_server-0.0.3/tests/test_common_and_server.py +279 -0
  34. awslabs_cloudwatch_mcp_server-0.0.3/tests/test_init.py +52 -0
  35. awslabs_cloudwatch_mcp_server-0.0.3/tests/test_main.py +52 -0
  36. awslabs_cloudwatch_mcp_server-0.0.3/uv.lock +1323 -0
@@ -0,0 +1,59 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .venv
27
+ env/
28
+ venv/
29
+ ENV/
30
+
31
+ # IDE
32
+ .idea/
33
+ .vscode/
34
+ *.swp
35
+ *.swo
36
+
37
+ # Testing
38
+ .tox/
39
+ .coverage
40
+ .coverage.*
41
+ htmlcov/
42
+ .pytest_cache/
43
+
44
+ # Ruff
45
+ .ruff_cache/
46
+
47
+ # Build
48
+ *.manifest
49
+ *.spec
50
+ .pybuilder/
51
+ target/
52
+
53
+ # Environments
54
+ .env
55
+ .env.local
56
+ .env.*.local
57
+
58
+ # PyPI
59
+ .pypirc
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## Unreleased
9
+
10
+ ## [0.0.1] - 2025-07-02
11
+
12
+ ### Added
13
+
14
+ - Added Support for CloudWatch Alarms Tools
15
+ - Added Support for CloudWatch Metrics Tools
16
+ - Added Support for CloudWatch Logs Tools
17
+
18
+ ## [0.0.0] - 2025-06-19
19
+
20
+ ### Added
21
+
22
+ - Initial project setup
@@ -0,0 +1,77 @@
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
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65 AS uv
16
+
17
+ # Install the project into `/app`
18
+ WORKDIR /app
19
+
20
+ # Enable bytecode compilation
21
+ ENV UV_COMPILE_BYTECODE=1
22
+
23
+ # Copy from the cache instead of linking since it's a mounted volume
24
+ ENV UV_LINK_MODE=copy
25
+
26
+ # Prefer the system python
27
+ ENV UV_PYTHON_PREFERENCE=only-system
28
+
29
+ # Run without updating the uv.lock file like running with `--frozen`
30
+ ENV UV_FROZEN=true
31
+
32
+ # Copy the required files first
33
+ COPY pyproject.toml uv.lock ./
34
+
35
+ # Install the project's dependencies using the lockfile and settings
36
+ RUN --mount=type=cache,target=/root/.cache/uv \
37
+ pip install uv==0.7.11 && \
38
+ uv sync --frozen --no-install-project --no-dev --no-editable
39
+
40
+ # Then, add the rest of the project source code and install it
41
+ # Installing separately from its dependencies allows optimal layer caching
42
+ COPY . /app
43
+ RUN --mount=type=cache,target=/root/.cache/uv \
44
+ uv sync --frozen --no-dev --no-editable
45
+
46
+ # Make the directory just in case it doesn't exist
47
+ RUN mkdir -p /root/.local
48
+
49
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65
50
+
51
+ # Place executables in the environment at the front of the path and include other binaries
52
+ ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
53
+
54
+ # Install lsof for the healthcheck
55
+ # Install other tools as needed for the MCP server
56
+ # Add non-root user and ability to change directory into /root
57
+ RUN yum update -y && \
58
+ yum install -y lsof && \
59
+ yum clean all -y && \
60
+ rm -rf /var/cache/yum && \
61
+ groupadd --force --system app && \
62
+ useradd app -g app -d /app && \
63
+ chmod o+x /root
64
+
65
+ # Get the project from the uv layer
66
+ COPY --from=uv --chown=app:app /root/.local /root/.local
67
+ COPY --from=uv --chown=app:app /app/.venv /app/.venv
68
+
69
+ # Get healthcheck script
70
+ COPY ./docker-healthcheck.sh /usr/local/bin/docker-healthcheck.sh
71
+
72
+ # Run as non-root
73
+ USER app
74
+
75
+ # When running the container, add --db-path and a bind mount to the host's db file
76
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "docker-healthcheck.sh" ]
77
+ ENTRYPOINT ["awslabs.cloudwatch-mcp-server"]
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
@@ -0,0 +1,2 @@
1
+ awslabs.cloudwatch-mcp-server
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: awslabs.cloudwatch-mcp-server
3
+ Version: 0.0.3
4
+ Summary: An AWS Labs Model Context Protocol (MCP) server for cloudwatch
5
+ Project-URL: homepage, https://awslabs.github.io/mcp/
6
+ Project-URL: docs, https://awslabs.github.io/mcp/servers/cloudwatch-mcp-server/
7
+ Project-URL: documentation, https://awslabs.github.io/mcp/servers/cloudwatch-mcp-server/
8
+ Project-URL: repository, https://github.com/awslabs/mcp.git
9
+ Project-URL: changelog, https://github.com/awslabs/mcp/blob/main/src/cloudwatch-mcp-server/CHANGELOG.md
10
+ Author: Amazon Web Services
11
+ Author-email: AWSLabs MCP <203918161+awslabs-mcp@users.noreply.github.com>, Isaiah Lemmon <ilemmon@amazon.com>
12
+ License: Apache-2.0
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: boto3>=1.38.22
25
+ Requires-Dist: loguru>=0.7.0
26
+ Requires-Dist: mcp[cli]>=1.6.0
27
+ Requires-Dist: pydantic>=2.10.6
28
+ Description-Content-Type: text/markdown
29
+
30
+ # AWS Labs cloudwatch MCP Server
31
+
32
+ This AWS Labs Model Context Protocol (MCP) server for CloudWatch enables your troubleshooting agents to use CloudWatch data to do AI-powered root cause analysis and provide recommendations. It offers comprehensive observability tools that simplify monitoring, reduce context switching, and help teams quickly diagnose and resolve service issues. This server will provide AI agents with seamless access to CloudWatch telemetry data through standardized MCP interfaces, eliminating the need for custom API integrations and reducing context switching during troubleshooting workflows. By consolidating access to all CloudWatch capabilities, we enable powerful cross-service correlations and insights that accelerate incident resolution and improve operational visibility.
33
+
34
+ ## Instructions
35
+
36
+ The CloudWatch MCP Server provides specialized tools to address common operational scenarios including alarm troubleshooting, understand metrics definitions, alarm recommendations and log analysis. Each tool encapsulates one or multiple CloudWatch APIs into task-oriented operations.
37
+
38
+ ## Features
39
+
40
+ Alarm Based Troubleshooting - Identifies active alarms, retrieves related metrics and logs, and analyzes historical alarm patterns to determine root causes of triggered alerts. Provides context-aware recommendations for remediation.
41
+
42
+ Log Analyzer - Analyzes a CloudWatch log group for anomalies, message patterns, and error patterns within a specified time window.
43
+
44
+ Metric Definition Analyzer - Provides comprehensive descriptions of what metrics represent, how they're calculated, recommended statistics to use for metric data retrieval
45
+
46
+ Alarm Recommendations - Suggests recommended alarm configurations for CloudWatch metrics, including thresholds, evaluation periods, and other alarm settings.
47
+
48
+ ## Prerequisites
49
+
50
+ 1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
51
+ 2. Install Python using `uv python install 3.10`
52
+ 3. An AWS account with [CloudWatch Telemetry](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html)
53
+ 4. This MCP server can only be run locally on the same host as your LLM client.
54
+ 5. Set up AWS credentials with access to AWS services
55
+ - You need an AWS account with appropriate permissions
56
+ - Configure AWS credentials with `aws configure` or environment variables
57
+
58
+ ## Available Tools
59
+
60
+ ### Tools for CloudWatch Metrics
61
+ * `get_metric_data` - Retrieves detailed CloudWatch metric data for any CloudWatch metric. Use this for general CloudWatch metrics that aren't specific to Application Signals. Provides ability to query any metric namespace, dimension, and statistic
62
+ * `get_metric_metadata` - Retrieves comprehensive metadata about a specific CloudWatch metric
63
+ * `get_recommended_metric_alarms` - Gets recommended alarms for a CloudWatch metric
64
+
65
+ ### Tools for CloudWatch Alarms
66
+ * `get_active_alarms` - Identifies currently active CloudWatch alarms across the account
67
+ * `get_alarm_history` - Retrieves historical state changes and patterns for a given CloudWatch alarm
68
+
69
+ ### Tools for CloudWatch Logs
70
+ * `describe_log_groups` - Finds metadata about CloudWatch log groups
71
+ * `analyze_log_group` - Analyzes CloudWatch logs for anomalies, message patterns, and error patterns
72
+ * `execute_log_insights_query` - Executes CloudWatch Logs insights query on CloudWatch log group(s) with specified time range and query syntax, returns a unique ID used to retrieve results
73
+ * `get_logs_insight_query_results` - Retrieves the results of an executed CloudWatch insights query using the query ID. It is used after `execute_log_insights_query` has been called
74
+ * `cancel_logs_insight_query` - Cancels in progress CloudWatch logs insights query
75
+
76
+ ### Required IAM Permissions
77
+ * `cloudwatch:DescribeAlarms`
78
+ * `cloudwatch:DescribeAlarmHistory`
79
+ * `cloudwatch:GetMetricData`
80
+ * `cloudwatch:ListMetrics`
81
+
82
+ * `logs:DescribeLogGroups`
83
+ * `logs:DescribeQueryDefinitions`
84
+ * `logs:ListLogAnomalyDetectors`
85
+ * `logs:ListAnomalies`
86
+ * `logs:StartQuery`
87
+ * `logs:GetQueryResults`
88
+ * `logs:StopQuery`
89
+
90
+ ## Installation
91
+
92
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://www.cursor.com/install-mcp?name=awslabs.cloudwatch-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLW1jcC1zZXJ2ZXJAbGF0ZXN0IiwiZW52Ijp7IkFXU19QUk9GSUxFIjoiW1RoZSBBV1MgUHJvZmlsZSBOYW1lIHRvIHVzZSBmb3IgQVdTIGFjY2Vzc10iLCJBV1NfUkVHSU9OIjoiW1RoZSBBV1MgcmVnaW9uIHRvIHJ1biBpbl0iLCJGQVNUTUNQX0xPR19MRVZFTCI6IkVSUk9SIn0sInRyYW5zcG9ydFR5cGUiOiJzdGRpbyJ9)
93
+
94
+ Example for Amazon Q Developer CLI (~/.aws/amazonq/mcp.json):
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "awslabs.cloudwatch-mcp-server": {
100
+ "autoApprove": [],
101
+ "disabled": false,
102
+ "timeout": 60,
103
+ "command": "uvx",
104
+ "args": [
105
+ "awslabs.cloudwatch-mcp-server@latest"
106
+ ],
107
+ "env": {
108
+ "AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
109
+ "FASTMCP_LOG_LEVEL": "ERROR"
110
+ },
111
+ "transportType": "stdio"
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Please reference [AWS documentation](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) to create and manage your credentials profile
118
+
119
+ ### Build and install docker image locally on the same host of your LLM client
120
+
121
+ 1. `git clone https://github.com/awslabs/mcp.git`
122
+ 2. Go to sub-directory 'src/cloudwatch-mcp-server/'
123
+ 3. Run 'docker build -t awslabs/cloudwatch-mcp-server:latest .'
124
+
125
+ ### Add or update your LLM client's config with following:
126
+ ```file
127
+ # fictitious `.env` file with AWS temporary credentials
128
+ AWS_ACCESS_KEY_ID=<from the profile you set up>
129
+ AWS_SECRET_ACCESS_KEY=<from the profile you set up>
130
+ AWS_SESSION_TOKEN=<from the profile you set up>
131
+ ```
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "awslabs.cloudwatch-mcp-server": {
137
+ "command": "docker",
138
+ "args": [
139
+ "run",
140
+ "--rm",
141
+ "--interactive",
142
+ "--env-file",
143
+ "/full/path/to/file/above/.env",
144
+ "awslabs/cloudwatch-mcp-server:latest"
145
+ ],
146
+ "env": {},
147
+ "disabled": false,
148
+ "autoApprove": []
149
+ }
150
+ }
151
+ }
152
+ ```
153
+ NOTE: Your credentials will need to be kept refreshed from your host
154
+
155
+ ## Contributing
156
+
157
+ Contributions are welcome! Please see the [CONTRIBUTING.md](../../CONTRIBUTING.md) in the monorepo root for guidelines.
@@ -0,0 +1,128 @@
1
+ # AWS Labs cloudwatch MCP Server
2
+
3
+ This AWS Labs Model Context Protocol (MCP) server for CloudWatch enables your troubleshooting agents to use CloudWatch data to do AI-powered root cause analysis and provide recommendations. It offers comprehensive observability tools that simplify monitoring, reduce context switching, and help teams quickly diagnose and resolve service issues. This server will provide AI agents with seamless access to CloudWatch telemetry data through standardized MCP interfaces, eliminating the need for custom API integrations and reducing context switching during troubleshooting workflows. By consolidating access to all CloudWatch capabilities, we enable powerful cross-service correlations and insights that accelerate incident resolution and improve operational visibility.
4
+
5
+ ## Instructions
6
+
7
+ The CloudWatch MCP Server provides specialized tools to address common operational scenarios including alarm troubleshooting, understand metrics definitions, alarm recommendations and log analysis. Each tool encapsulates one or multiple CloudWatch APIs into task-oriented operations.
8
+
9
+ ## Features
10
+
11
+ Alarm Based Troubleshooting - Identifies active alarms, retrieves related metrics and logs, and analyzes historical alarm patterns to determine root causes of triggered alerts. Provides context-aware recommendations for remediation.
12
+
13
+ Log Analyzer - Analyzes a CloudWatch log group for anomalies, message patterns, and error patterns within a specified time window.
14
+
15
+ Metric Definition Analyzer - Provides comprehensive descriptions of what metrics represent, how they're calculated, recommended statistics to use for metric data retrieval
16
+
17
+ Alarm Recommendations - Suggests recommended alarm configurations for CloudWatch metrics, including thresholds, evaluation periods, and other alarm settings.
18
+
19
+ ## Prerequisites
20
+
21
+ 1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
22
+ 2. Install Python using `uv python install 3.10`
23
+ 3. An AWS account with [CloudWatch Telemetry](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html)
24
+ 4. This MCP server can only be run locally on the same host as your LLM client.
25
+ 5. Set up AWS credentials with access to AWS services
26
+ - You need an AWS account with appropriate permissions
27
+ - Configure AWS credentials with `aws configure` or environment variables
28
+
29
+ ## Available Tools
30
+
31
+ ### Tools for CloudWatch Metrics
32
+ * `get_metric_data` - Retrieves detailed CloudWatch metric data for any CloudWatch metric. Use this for general CloudWatch metrics that aren't specific to Application Signals. Provides ability to query any metric namespace, dimension, and statistic
33
+ * `get_metric_metadata` - Retrieves comprehensive metadata about a specific CloudWatch metric
34
+ * `get_recommended_metric_alarms` - Gets recommended alarms for a CloudWatch metric
35
+
36
+ ### Tools for CloudWatch Alarms
37
+ * `get_active_alarms` - Identifies currently active CloudWatch alarms across the account
38
+ * `get_alarm_history` - Retrieves historical state changes and patterns for a given CloudWatch alarm
39
+
40
+ ### Tools for CloudWatch Logs
41
+ * `describe_log_groups` - Finds metadata about CloudWatch log groups
42
+ * `analyze_log_group` - Analyzes CloudWatch logs for anomalies, message patterns, and error patterns
43
+ * `execute_log_insights_query` - Executes CloudWatch Logs insights query on CloudWatch log group(s) with specified time range and query syntax, returns a unique ID used to retrieve results
44
+ * `get_logs_insight_query_results` - Retrieves the results of an executed CloudWatch insights query using the query ID. It is used after `execute_log_insights_query` has been called
45
+ * `cancel_logs_insight_query` - Cancels in progress CloudWatch logs insights query
46
+
47
+ ### Required IAM Permissions
48
+ * `cloudwatch:DescribeAlarms`
49
+ * `cloudwatch:DescribeAlarmHistory`
50
+ * `cloudwatch:GetMetricData`
51
+ * `cloudwatch:ListMetrics`
52
+
53
+ * `logs:DescribeLogGroups`
54
+ * `logs:DescribeQueryDefinitions`
55
+ * `logs:ListLogAnomalyDetectors`
56
+ * `logs:ListAnomalies`
57
+ * `logs:StartQuery`
58
+ * `logs:GetQueryResults`
59
+ * `logs:StopQuery`
60
+
61
+ ## Installation
62
+
63
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://www.cursor.com/install-mcp?name=awslabs.cloudwatch-mcp-server&config=eyJhdXRvQXBwcm92ZSI6W10sImRpc2FibGVkIjpmYWxzZSwidGltZW91dCI6NjAsImNvbW1hbmQiOiJ1dnggYXdzbGFicy5jbG91ZHdhdGNoLW1jcC1zZXJ2ZXJAbGF0ZXN0IiwiZW52Ijp7IkFXU19QUk9GSUxFIjoiW1RoZSBBV1MgUHJvZmlsZSBOYW1lIHRvIHVzZSBmb3IgQVdTIGFjY2Vzc10iLCJBV1NfUkVHSU9OIjoiW1RoZSBBV1MgcmVnaW9uIHRvIHJ1biBpbl0iLCJGQVNUTUNQX0xPR19MRVZFTCI6IkVSUk9SIn0sInRyYW5zcG9ydFR5cGUiOiJzdGRpbyJ9)
64
+
65
+ Example for Amazon Q Developer CLI (~/.aws/amazonq/mcp.json):
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "awslabs.cloudwatch-mcp-server": {
71
+ "autoApprove": [],
72
+ "disabled": false,
73
+ "timeout": 60,
74
+ "command": "uvx",
75
+ "args": [
76
+ "awslabs.cloudwatch-mcp-server@latest"
77
+ ],
78
+ "env": {
79
+ "AWS_PROFILE": "[The AWS Profile Name to use for AWS access]",
80
+ "FASTMCP_LOG_LEVEL": "ERROR"
81
+ },
82
+ "transportType": "stdio"
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ Please reference [AWS documentation](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) to create and manage your credentials profile
89
+
90
+ ### Build and install docker image locally on the same host of your LLM client
91
+
92
+ 1. `git clone https://github.com/awslabs/mcp.git`
93
+ 2. Go to sub-directory 'src/cloudwatch-mcp-server/'
94
+ 3. Run 'docker build -t awslabs/cloudwatch-mcp-server:latest .'
95
+
96
+ ### Add or update your LLM client's config with following:
97
+ ```file
98
+ # fictitious `.env` file with AWS temporary credentials
99
+ AWS_ACCESS_KEY_ID=<from the profile you set up>
100
+ AWS_SECRET_ACCESS_KEY=<from the profile you set up>
101
+ AWS_SESSION_TOKEN=<from the profile you set up>
102
+ ```
103
+
104
+ ```json
105
+ {
106
+ "mcpServers": {
107
+ "awslabs.cloudwatch-mcp-server": {
108
+ "command": "docker",
109
+ "args": [
110
+ "run",
111
+ "--rm",
112
+ "--interactive",
113
+ "--env-file",
114
+ "/full/path/to/file/above/.env",
115
+ "awslabs/cloudwatch-mcp-server:latest"
116
+ ],
117
+ "env": {},
118
+ "disabled": false,
119
+ "autoApprove": []
120
+ }
121
+ }
122
+ }
123
+ ```
124
+ NOTE: Your credentials will need to be kept refreshed from your host
125
+
126
+ ## Contributing
127
+
128
+ Contributions are welcome! Please see the [CONTRIBUTING.md](../../CONTRIBUTING.md) in the monorepo root for guidelines.
@@ -0,0 +1,16 @@
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.
@@ -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
+ """awslabs.cloudwatch-mcp-server"""
16
+
17
+ MCP_SERVER_VERSION = '0.0.1'