AWS Cost Explorer
Query AWS spend, forecasts, cost allocation tags, and Savings Plans or Reserved Instance utilization via the Cost Explorer API.
Overview
Connect AWS Cost Explorer so AI clients can query historical AWS spend, cost forecasts, dimension values (services, regions, linked accounts), cost allocation tags, and Savings Plans / Reserved Instance utilization.
This integration uses the AWS Cost Explorer API with IAM access keys stored encrypted in stackgate.ai. API usage is billed to your AWS account ($0.01 per request).
For infrastructure logs and metrics, use AWS CloudWatch. For S3 artifact costs in context of CI, see AWS CodeBuild.
Prerequisites
- An AWS account with Cost Explorer enabled (AWS Billing console → Cost Explorer → Enable; can take up to 24 hours)
- For organization-wide linked-account data: IAM credentials from the management/payer account
- A stackgate.ai account
Getting credentials
- In the AWS IAM console, create an IAM user (or use an existing automation user) with programmatic access.
- Attach a least-privilege policy. Example for read-only Cost Explorer:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage",
"ce:GetCostForecast",
"ce:GetDimensionValues",
"ce:GetTags",
"ce:GetUsageForecast",
"ce:GetSavingsPlansUtilization",
"ce:GetSavingsPlansCoverage",
"ce:GetReservationUtilization",
"ce:GetReservationCoverage",
"ce:GetCostCategories"
],
"Resource": "*"
}
]
}
- Create an access key and copy the key ID and secret.
- In stackgate.ai, open My Integrations → AWS Cost Explorer.
- Click Activate and enter access key ID, secret access key, and AWS region (stored for consistency; the Cost Explorer API always uses the
us-east-1endpoint).
You can reuse the same IAM user as Amazon S3, AWS CloudWatch, or other AWS integrations with a merged policy.
Using with AI clients
- Dedicated endpoint:
POST /mcp/cost-explorerwith a Sanctum bearer token - Private gateway: one config for all integrations — use
cost-explorer__*namespaced tools
Typical workflow:
- get_dimension_values — discover services, regions, or linked accounts (
dimension:SERVICE,REGION,LINKED_ACCOUNT) - get_tags — list cost allocation tag keys or values
- get_cost_and_usage — query historical spend (
group_by, filter byservices,region, or tags) - get_cost_forecast — forecast upcoming spend
- get_savings_plans_utilization / get_reservation_utilization — commitment utilization
See Documentation for HTTP authentication and private gateway setup.
Troubleshooting
- 422 integration not configured — complete all required credential fields in My Integrations.
- 403 / AccessDenied from AWS — verify IAM policy includes
ce:Get*actions and Cost Explorer is enabled on the account. - DataUnavailableException / empty results — Cost Explorer may not be enabled yet, or the date range has no billing data.
- LimitExceededException — you made too many API calls in a short period. Each request costs $0.01; avoid rapid repeated queries.
- Linked account data missing — use management/payer account credentials for organization-wide
LINKED_ACCOUNTdimensions. - HOURLY granularity charges — hourly data has additional AWS fees beyond the per-request API cost. Prefer
DAILYorMONTHLYunless needed.
Available tools
-
get_dimension_values
List available dimension values (services, regions, linked accounts, etc.) for a time period.
-
get_cost_and_usage
Query historical AWS cost and usage for a time period.
-
get_cost_forecast
Forecast AWS spend for a future time period based on historical costs.
-
get_tags
List cost allocation tag keys or values active during a time period.
-
get_usage_forecast
Forecast AWS usage quantity for a future time period.
-
get_savings_plans_utilization
Retrieve Savings Plans utilization for a time period.
-
get_savings_plans_coverage
Retrieve Savings Plans coverage for a time period.
-
get_reservation_utilization
Retrieve Reserved Instance utilization for a time period.
-
get_reservation_coverage
Retrieve Reserved Instance coverage for a time period.
-
get_cost_categories
List cost category names available for a time period.
MCP endpoint:
https://stackgate.ai/mcp/cost-explorer
(HTTP) or via the
private gateway.
Related workflows
Multi-integration playbooks that use AWS Cost Explorer to solve concrete business outcomes.