awslabs.cost-explorer-mcp-server 0.0.4__tar.gz → 0.0.6__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 (39) hide show
  1. awslabs_cost_explorer_mcp_server-0.0.6/CHANGELOG.md +46 -0
  2. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/Dockerfile +4 -4
  3. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/PKG-INFO +44 -14
  4. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/README.md +41 -12
  5. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/comparison_handler.py +719 -0
  6. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/constants.py +106 -0
  7. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/cost_usage_handler.py +385 -0
  8. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/forecasting_handler.py +234 -0
  9. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/helpers.py +711 -0
  10. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/metadata_handler.py +88 -0
  11. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/models.py +70 -0
  12. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/server.py +92 -0
  13. awslabs_cost_explorer_mcp_server-0.0.6/awslabs/cost_explorer_mcp_server/utility_handler.py +50 -0
  14. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/pyproject.toml +3 -2
  15. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/tests/conftest.py +48 -8
  16. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_comparison_handler.py +1507 -0
  17. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_cost_usage_handler.py +1283 -0
  18. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_forecasting_handler.py +483 -0
  19. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_helpers.py +1195 -0
  20. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_metadata_handler.py +230 -0
  21. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_models.py +135 -0
  22. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_server.py +75 -0
  23. awslabs_cost_explorer_mcp_server-0.0.6/tests/test_utility_handler.py +52 -0
  24. awslabs_cost_explorer_mcp_server-0.0.6/uv-requirements.txt +26 -0
  25. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/uv.lock +32 -8
  26. awslabs_cost_explorer_mcp_server-0.0.4/.pre-commit-config.yaml +0 -14
  27. awslabs_cost_explorer_mcp_server-0.0.4/CHANGELOG.md +0 -11
  28. awslabs_cost_explorer_mcp_server-0.0.4/awslabs/cost_explorer_mcp_server/helpers.py +0 -278
  29. awslabs_cost_explorer_mcp_server-0.0.4/awslabs/cost_explorer_mcp_server/server.py +0 -495
  30. awslabs_cost_explorer_mcp_server-0.0.4/tests/test_helpers.py +0 -666
  31. awslabs_cost_explorer_mcp_server-0.0.4/tests/test_server.py +0 -885
  32. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/.gitignore +0 -0
  33. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/.python-version +0 -0
  34. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/LICENSE +0 -0
  35. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/NOTICE +0 -0
  36. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/awslabs/__init__.py +0 -0
  37. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/awslabs/cost_explorer_mcp_server/__init__.py +0 -0
  38. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/docker-healthcheck.sh +0 -0
  39. {awslabs_cost_explorer_mcp_server-0.0.4 → awslabs_cost_explorer_mcp_server-0.0.6}/tests/__init__.py +0 -0
@@ -0,0 +1,46 @@
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
+ ## [0.6.0] - 2025-06-20
9
+
10
+ ### Added
11
+ - **NEW AWS Cost Comparison Feature Integration**
12
+ - `get_cost_and_usage_comparisons` - Leverage AWS Cost Explorer's new Cost Comparison feature to compare costs between two time periods
13
+ - `get_cost_comparison_drivers` - Automatically analyze the top 10 most significant cost change drivers using AWS's new API
14
+ - Reduces manual cost analysis time from hours to seconds using AWS's built-in intelligence
15
+ - Provides detailed breakdowns of cost drivers, including usage and discount changes
16
+ **Cost Forecasting Capabilities**
17
+ - `get_cost_forecast` - Generate cost forecasts based on historical usage patterns with confidence intervals (80% or 95%)
18
+ - Support for daily and monthly forecast granularity for budget planning
19
+ **Modular Architecture**
20
+ - Refactored codebase into modular handler architecture for better maintainability
21
+ - Separate handlers for cost usage, comparison, forecasting, metadata, and utility functions
22
+ **Enhanced Testing**
23
+ - Comprehensive test coverage for comparison features
24
+ - Fixed duplicate test method definitions
25
+ - Improved test reliability and error handling
26
+
27
+ ## [0.5.0] - 2025-06-16
28
+
29
+ ### Added
30
+ - Enhanced documentation for UsageQuantity metric with specific filtering requirements
31
+ - Dynamic labeling for cost metrics based on grouping dimension (e.g., "Region Total" vs "Service Total")
32
+ - Metadata support for usage metrics including grouped_by, metric type, and period information
33
+ - Optimized JSON serialization that only runs stringify_keys when needed
34
+ - Added Match_Option Validation
35
+
36
+ ### Changed
37
+ - Usage metrics now return clean nested structure instead of complex pandas tuples
38
+ - Old: `{("2025-01-01", "Amount"): {"EC2": 100}, ("2025-01-01", "Unit"): {"EC2": "Hours"}}`
39
+ - New: `{"GroupedUsage": {"2025-01-01": {"EC2": {"amount": 100, "unit": "Hours"}}}}`
40
+ - Improved UsageQuantity documentation to emphasize need for SERVICE + USAGE_TYPE filtering
41
+ - Enhanced error handling for metric data processing
42
+
43
+ ## [0.1.0] - 2025-06-01
44
+
45
+ ### Added
46
+ - Initial release of the Cost Explorer MCP Server
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1 AS uv
15
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65 AS uv
16
16
 
17
17
  # Install the project into `/app`
18
18
  WORKDIR /app
@@ -30,11 +30,11 @@ ENV UV_PYTHON_PREFERENCE=only-system
30
30
  ENV UV_FROZEN=true
31
31
 
32
32
  # Copy the required files first
33
- COPY pyproject.toml uv.lock ./
33
+ COPY pyproject.toml uv.lock uv-requirements.txt ./
34
34
 
35
35
  # Install the project's dependencies using the lockfile and settings
36
36
  RUN --mount=type=cache,target=/root/.cache/uv \
37
- pip install uv && \
37
+ pip install --require-hashes --requirement uv-requirements.txt && \
38
38
  uv sync --frozen --no-install-project --no-dev --no-editable
39
39
 
40
40
  # Then, add the rest of the project source code and install it
@@ -46,7 +46,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
46
46
  # Make the directory just in case it doesn't exist
47
47
  RUN mkdir -p /root/.local
48
48
 
49
- FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1
49
+ FROM public.ecr.aws/sam/build-python3.10@sha256:d821662474d65f3cf2fc97dba2fa807a3adb580d02895fc4545527812550ea65
50
50
 
51
51
  # Place executables in the environment at the front of the path and include other binaries
52
52
  ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.cost-explorer-mcp-server
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: MCP server for analyzing AWS costs and usage data through the AWS Cost Explorer API
5
5
  Project-URL: Homepage, https://awslabs.github.io/mcp/
6
6
  Project-URL: Documentation, https://awslabs.github.io/mcp/servers/cost-explorer-mcp-server/
@@ -21,7 +21,8 @@ Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Programming Language :: Python :: 3.13
23
23
  Requires-Python: >=3.10
24
- Requires-Dist: boto3>=1.36.20
24
+ Requires-Dist: boto3>=1.38.40
25
+ Requires-Dist: loguru>=0.7.0
25
26
  Requires-Dist: mcp[cli]>=1.6.0
26
27
  Requires-Dist: pandas>=2.2.3
27
28
  Requires-Dist: pydantic>=2.10.6
@@ -40,17 +41,28 @@ MCP server for analyzing AWS costs and usage data through the AWS Cost Explorer
40
41
  - Query historical cost data for specific time periods
41
42
  - Filter costs by various dimensions, tags, and cost categories
42
43
 
44
+
45
+ ### Compare costs between time periods
46
+
47
+ - **NEW AWS Feature**: Leverage AWS Cost Explorer's new [Cost Comparison feature](https://docs.aws.amazon.com/cost-management/latest/userguide/ce-cost-comparison.html)
48
+ - Compare costs between two time periods to identify changes and trends
49
+ - Analyze cost drivers to understand what caused cost increases or decreases
50
+ - Get detailed insights into the top 10 most significant cost change drivers automatically
51
+ - Identify specific usage types, discount changes, and infrastructure changes affecting costs
52
+
53
+ ### Forecast future costs
54
+
55
+ - Generate cost forecasts based on historical usage patterns
56
+ - Get predictions with confidence intervals (80% or 95%)
57
+ - Support for daily and monthly forecast granularity
58
+ - Plan budgets and anticipate future AWS spending
59
+
43
60
  ### Query cost data with natural language
44
61
 
45
62
  - Ask questions about your AWS costs in plain English
46
63
  - Get instant answers about your AWS spending patterns
47
64
  - Retrieve historical cost data with simple queries
48
65
 
49
- ### Generate cost reports and insights
50
-
51
- - Generate comprehensive cost reports based on your AWS Cost Explorer data
52
- - Get cost breakdowns by various dimensions (service, region, account, etc.)
53
- - Analyze usage patterns and spending trends
54
66
 
55
67
  ## Prerequisites
56
68
 
@@ -63,6 +75,8 @@ MCP server for analyzing AWS costs and usage data through the AWS Cost Explorer
63
75
 
64
76
  ## Installation
65
77
 
78
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.cost-explorer-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuY29zdC1leHBsb3Jlci1tY3Atc2VydmVyQGxhdGVzdCIsImVudiI6eyJGQVNUTUNQX0xPR19MRVZFTCI6IkVSUk9SIiwiQVdTX1BST0ZJTEUiOiJ5b3VyLWF3cy1wcm9maWxlIn0sImRpc2FibGVkIjpmYWxzZSwiYXV0b0FwcHJvdmUiOltdfQ%3D%3D)
79
+
66
80
  Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
67
81
 
68
82
  ```json
@@ -146,6 +160,9 @@ The following IAM permissions are required for this MCP server:
146
160
  - ce:GetCostAndUsage
147
161
  - ce:GetDimensionValues
148
162
  - ce:GetTags
163
+ - ce:GetCostForecast
164
+ - ce:GetCostAndUsageComparisons
165
+ - ce:GetCostComparisonDrivers
149
166
 
150
167
 
151
168
 
@@ -157,26 +174,39 @@ The Cost Explorer MCP Server provides the following tools:
157
174
  2. `get_dimension_values` - Get available values for a specific dimension (e.g., SERVICE, REGION)
158
175
  3. `get_tag_values` - Get available values for a specific tag key
159
176
  4. `get_cost_and_usage` - Retrieve AWS cost and usage data with filtering and grouping options
177
+ 5. `get_cost_and_usage_comparisons` - Compare costs between two time periods to identify changes and trends
178
+ 6. `get_cost_comparison_drivers` - Analyze what drove cost changes between periods (top 10 most significant drivers)
179
+ 7. `get_cost_forecast` - Generate cost forecasts based on historical usage patterns
160
180
 
161
181
  ## Example Usage
162
182
 
163
- Here are some examples of how to use the Cost Explorer MCP Server:
164
-
183
+ Here are some examples of how to use the Cost Explorer MCP Server through natural language queries:
165
184
 
166
- ### Get dimension values
185
+ ### Cost Analysis Examples
167
186
 
168
187
  ```
169
- What AWS services did I use last month?
188
+ Show me my AWS costs for the last 3 months grouped by service in us-east-1 region
189
+ Break down my S3 costs by storage class for Q1 2025
190
+ Show me costs for production resources tagged with Environment=prod
191
+ What were my costs for reserved instances vs on-demand in May?
192
+ What was my EC2 instance usage by instance type?
170
193
  ```
171
194
 
172
- ### Generate a cost report
195
+ ### Cost Comparison Examples
173
196
 
174
197
  ```
175
- Show me my AWS costs for the last 3 months grouped by service in us-east-1 region
198
+ Compare my AWS costs between April and May 2025
199
+ How did my EC2 costs change from last month to this month?
200
+ Why did my AWS bill increase in June compared to May?
201
+ What caused the spike in my S3 costs last month?
176
202
  ```
177
203
 
204
+ ### Forecasting Examples
205
+
178
206
  ```
179
- What were my EC2 costs excluding us-east-2 for January 2025?
207
+ Forecast my AWS costs for next month
208
+ Predict my EC2 spending for the next quarter
209
+ What will my total AWS bill be for the rest of 2025?
180
210
  ```
181
211
 
182
212
  ## License
@@ -11,17 +11,28 @@ MCP server for analyzing AWS costs and usage data through the AWS Cost Explorer
11
11
  - Query historical cost data for specific time periods
12
12
  - Filter costs by various dimensions, tags, and cost categories
13
13
 
14
+
15
+ ### Compare costs between time periods
16
+
17
+ - **NEW AWS Feature**: Leverage AWS Cost Explorer's new [Cost Comparison feature](https://docs.aws.amazon.com/cost-management/latest/userguide/ce-cost-comparison.html)
18
+ - Compare costs between two time periods to identify changes and trends
19
+ - Analyze cost drivers to understand what caused cost increases or decreases
20
+ - Get detailed insights into the top 10 most significant cost change drivers automatically
21
+ - Identify specific usage types, discount changes, and infrastructure changes affecting costs
22
+
23
+ ### Forecast future costs
24
+
25
+ - Generate cost forecasts based on historical usage patterns
26
+ - Get predictions with confidence intervals (80% or 95%)
27
+ - Support for daily and monthly forecast granularity
28
+ - Plan budgets and anticipate future AWS spending
29
+
14
30
  ### Query cost data with natural language
15
31
 
16
32
  - Ask questions about your AWS costs in plain English
17
33
  - Get instant answers about your AWS spending patterns
18
34
  - Retrieve historical cost data with simple queries
19
35
 
20
- ### Generate cost reports and insights
21
-
22
- - Generate comprehensive cost reports based on your AWS Cost Explorer data
23
- - Get cost breakdowns by various dimensions (service, region, account, etc.)
24
- - Analyze usage patterns and spending trends
25
36
 
26
37
  ## Prerequisites
27
38
 
@@ -34,6 +45,8 @@ MCP server for analyzing AWS costs and usage data through the AWS Cost Explorer
34
45
 
35
46
  ## Installation
36
47
 
48
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-light.svg)](https://cursor.com/install-mcp?name=awslabs.cost-explorer-mcp-server&config=eyJjb21tYW5kIjoidXZ4IGF3c2xhYnMuY29zdC1leHBsb3Jlci1tY3Atc2VydmVyQGxhdGVzdCIsImVudiI6eyJGQVNUTUNQX0xPR19MRVZFTCI6IkVSUk9SIiwiQVdTX1BST0ZJTEUiOiJ5b3VyLWF3cy1wcm9maWxlIn0sImRpc2FibGVkIjpmYWxzZSwiYXV0b0FwcHJvdmUiOltdfQ%3D%3D)
49
+
37
50
  Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
38
51
 
39
52
  ```json
@@ -117,6 +130,9 @@ The following IAM permissions are required for this MCP server:
117
130
  - ce:GetCostAndUsage
118
131
  - ce:GetDimensionValues
119
132
  - ce:GetTags
133
+ - ce:GetCostForecast
134
+ - ce:GetCostAndUsageComparisons
135
+ - ce:GetCostComparisonDrivers
120
136
 
121
137
 
122
138
 
@@ -128,26 +144,39 @@ The Cost Explorer MCP Server provides the following tools:
128
144
  2. `get_dimension_values` - Get available values for a specific dimension (e.g., SERVICE, REGION)
129
145
  3. `get_tag_values` - Get available values for a specific tag key
130
146
  4. `get_cost_and_usage` - Retrieve AWS cost and usage data with filtering and grouping options
147
+ 5. `get_cost_and_usage_comparisons` - Compare costs between two time periods to identify changes and trends
148
+ 6. `get_cost_comparison_drivers` - Analyze what drove cost changes between periods (top 10 most significant drivers)
149
+ 7. `get_cost_forecast` - Generate cost forecasts based on historical usage patterns
131
150
 
132
151
  ## Example Usage
133
152
 
134
- Here are some examples of how to use the Cost Explorer MCP Server:
135
-
153
+ Here are some examples of how to use the Cost Explorer MCP Server through natural language queries:
136
154
 
137
- ### Get dimension values
155
+ ### Cost Analysis Examples
138
156
 
139
157
  ```
140
- What AWS services did I use last month?
158
+ Show me my AWS costs for the last 3 months grouped by service in us-east-1 region
159
+ Break down my S3 costs by storage class for Q1 2025
160
+ Show me costs for production resources tagged with Environment=prod
161
+ What were my costs for reserved instances vs on-demand in May?
162
+ What was my EC2 instance usage by instance type?
141
163
  ```
142
164
 
143
- ### Generate a cost report
165
+ ### Cost Comparison Examples
144
166
 
145
167
  ```
146
- Show me my AWS costs for the last 3 months grouped by service in us-east-1 region
168
+ Compare my AWS costs between April and May 2025
169
+ How did my EC2 costs change from last month to this month?
170
+ Why did my AWS bill increase in June compared to May?
171
+ What caused the spike in my S3 costs last month?
147
172
  ```
148
173
 
174
+ ### Forecasting Examples
175
+
149
176
  ```
150
- What were my EC2 costs excluding us-east-2 for January 2025?
177
+ Forecast my AWS costs for next month
178
+ Predict my EC2 spending for the next quarter
179
+ What will my total AWS bill be for the rest of 2025?
151
180
  ```
152
181
 
153
182
  ## License