mcpField
A
aws-cost-explorer

aws-cost-explorer

github.com/oldwinterCloud & DevOps1044 installsUpdated 1w ago
Repository

About aws-cost-explorer

A skill for querying AWS cost and usage data, suited to operators reviewing cloud spend. It supports service summaries and usage-type drill-downs with date, cost, and output controls.

Key features

  1. 01Daily costs by AWS service
  2. 02Usage-type breakdowns
  3. 03Date and minimum-cost filters
  4. 04Table or JSON output

Use cases

  1. 01Review daily spend across services
  2. 02Investigate a service’s usage charges
  3. 03Show only costs above a threshold

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/oldwinter/skills --skill aws-cost-explorer

After installing, type/aws-cost-explorerin Claude Code to confirm it loaded.

Bundled filesscripts/cost_query.py

Details

From the project README

AWS Cost Explorer

Query AWS costs and usage details with flexible granularity - from service-level overview to detailed usage type breakdown.

Capabilities

  • Query daily AWS costs by service (e.g., EC2, S3, OpenSearch, DocumentDB)
  • Drill down to usage type details for specific services (e.g., instance types, storage, data transfer)
  • Filter results by minimum cost threshold
  • Support both relative dates (days ago) and absolute dates (YYYY-MM-DD)
  • Output in human-readable table or JSON format

Usage

Quick Commands

To query costs, use the bundled script at scripts/cost_query.py:

# Query costs from 2 days ago (default) by service
python3 <skill-path>/scripts/cost_query.py

# Query yesterday's costs, show items > $5
python3 <skill-path>/scripts/cost_query.py --days-ago 1 --min-cost 5

# Query specific date
python3 <skill-path>/scripts/cost_query.py --date 2026-01-15

# Query specific service's usage breakdown
python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1

# Query all services with usage type details
python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5

# Output as JSON
python3 <skill-path>/scripts/cost_query.py --json --min-cost 5
Script Options
OptionShortDescription
--days-ago-dQuery N days ago (default: 2, i.e., day before yesterday)
--dateQuery specific date (YYYY-MM-DD format)
--min-cost-mMinimum cost threshold to display (default: 0)
--service-sQuery usage type breakdown for a specific service
--detailedShow all services with usage type breakdown
--json-jOutput in JSON format

Common Service Names

When using --service, use the exact AWS service names:

Common NameAWS Service Name
OpenSearchAmazon OpenSearch Service
DocumentDB/MongoDBAmazon DocumentDB (with MongoDB compatibility)
EC2 ComputeAmazon Elastic Compute Cloud - Compute
EC2 Other (EBS, NAT)EC2 - Other
EFSAmazon Elastic File System
S3Amazon Simple Storage Service
RDSAmazon Relational Database Service
EKSAmazon Elastic Container Service for Kubernetes
VPCAmazon Virtual Private Cloud
BedrockAmazon Bedrock
LambdaAWS Lambda
CloudWatchAmazonCloudWatch

Understanding Usage Types

Common usage type patterns:

PatternMeaning
BoxUsage:*EC2 instance hours (e.g., BoxUsage:m7i.large)
ESInstance:*OpenSearch instance hours
EBS:VolumeUsage.*EBS storage (e.g., EBS:VolumeUsage.gp3)
TimedStorage-ByteHrsS3/EFS storage capacity
DataTransfer-*Data transfer costs
NatGateway-*NAT Gateway costs
VpcEndpoint-*VPC Endpoint costs
*-input-tokens / *-output-tokensBedrock token usage
Elastic*UsageDocumentDB Elastic costs

Prerequisites

  • AWS CLI configured with appropriate credentials
  • IAM permissions for ce:GetCostAndUsage

Example Workflow

  1. First, get service-level overview:

    python3 <skill-path>/scripts/cost_query.py --min-cost 5
    
  2. Identify high-cost services, then drill down:

    python3 <skill-path>/scripts/cost_query.py --service "Amazon OpenSearch Service" --min-cost 1
    
  3. For comprehensive analysis, use detailed mode:

    python3 <skill-path>/scripts/cost_query.py --detailed --min-cost 5
    

Comments

Markdown supported