Skip to main content
Glama

ce-get_cost_and_usage

Retrieve and analyze AWS cost and usage data across services, accounts, and custom dimensions for cost optimization, budgeting, and financial reporting.

Instructions

Retrieve comprehensive AWS cost and usage data with advanced filtering, grouping, and time-based analysis.

This tool provides detailed cost analysis across AWS services, accounts, and custom dimensions.
Essential for cost optimization, budgeting, chargeback reporting, and financial governance.
Supports multiple granularities, cost metrics, and complex filtering for precise analysis.

**Required Parameters:**
- profile_name (str): AWS profile name from ~/.aws/credentials
- region (str): AWS region (e.g., 'us-east-1') - Cost Explorer is global but requires region
- start (str): Start date in YYYY-MM-DD format (e.g., '2024-01-01')
- end (str): End date in YYYY-MM-DD format (e.g., '2024-01-31')
  * Maximum 12 months range for daily data
  * Maximum 12 months range for monthly data
  * Maximum 1 week range for hourly data

**Optional Parameters:**
- granularity (str): Time granularity for cost breakdown. Default: 'MONTHLY'
  * 'DAILY': Day-by-day cost breakdown (max 12 months)
  * 'MONTHLY': Month-by-month cost breakdown (max 12 months)
  * 'HOURLY': Hour-by-hour cost breakdown (max 1 week)

- group_by (List[Dict[str, str]]): Grouping dimensions for cost analysis
  **Service Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'SERVICE'}] - Group by AWS service

  **Account Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'LINKED_ACCOUNT'}] - Group by AWS account

  **Geographic Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'REGION'}] - Group by AWS region
  [{'Type': 'DIMENSION', 'Key': 'AVAILABILITY_ZONE'}] - Group by AZ

  **Resource Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'INSTANCE_TYPE'}] - Group by EC2 instance type
  [{'Type': 'DIMENSION', 'Key': 'USAGE_TYPE'}] - Group by usage type
  [{'Type': 'DIMENSION', 'Key': 'OPERATION'}] - Group by operation

  **Tag-based Grouping:**
  [{'Type': 'TAG', 'Key': 'Environment'}] - Group by Environment tag
  [{'Type': 'TAG', 'Key': 'Project'}] - Group by Project tag
  [{'Type': 'TAG', 'Key': 'Owner'}] - Group by Owner tag

  **Multiple Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'SERVICE'}, {'Type': 'TAG', 'Key': 'Environment'}]

- metrics (List[str]): Cost metrics to retrieve. Default: ['BlendedCost']
  * 'BlendedCost': Cost after applying Reserved Instance and Savings Plans discounts
  * 'UnblendedCost': On-demand cost without discounts
  * 'NetBlendedCost': BlendedCost minus credits and refunds
  * 'NetUnblendedCost': UnblendedCost minus credits and refunds
  * 'UsageQuantity': Usage amount (hours, GB, requests, etc.)
  * 'NormalizedUsageAmount': Usage normalized to equivalent units

- filter_expression (Dict[str, Any]): Advanced filtering for targeted analysis
  **Service Filters:**
  {'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Elastic Compute Cloud - Compute']}}

  **Account Filters:**
  {'Dimensions': {'Key': 'LINKED_ACCOUNT', 'Values': ['123456789012']}}

  **Region Filters:**
  {'Dimensions': {'Key': 'REGION', 'Values': ['us-east-1', 'us-west-2']}}

  **Tag Filters:**
  {'Tags': {'Key': 'Environment', 'Values': ['production', 'staging']}}

  **Complex Filters (AND/OR/NOT):**
  {'And': [{'Dimensions': {'Key': 'SERVICE', 'Values': ['EC2']}}, {'Tags': {'Key': 'Environment', 'Values': ['production']}}]}

- next_page_token (str): Pagination token from previous response
  * Use NextPageToken from previous call for large datasets

**Common Use Cases:**
1. **Monthly service breakdown:** granularity='MONTHLY', group_by=[{'Type': 'DIMENSION', 'Key': 'SERVICE'}]
2. **Daily cost trends:** granularity='DAILY', metrics=['BlendedCost']
3. **Environment cost analysis:** group_by=[{'Type': 'TAG', 'Key': 'Environment'}]
4. **EC2 cost optimization:** filter_expression={'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Elastic Compute Cloud - Compute']}}
5. **Multi-account analysis:** group_by=[{'Type': 'DIMENSION', 'Key': 'LINKED_ACCOUNT'}]
6. **Regional cost comparison:** group_by=[{'Type': 'DIMENSION', 'Key': 'REGION'}]

**Response includes:** Time periods, cost amounts by specified metrics, grouping dimensions,
and metadata for comprehensive cost analysis and reporting.

**Best Practices:**
- Use monthly granularity for trend analysis
- Apply service filters to focus on specific cost areas
- Combine dimension and tag grouping for detailed insights
- Use pagination for large datasets
- Consider NetBlendedCost for accurate cost reporting

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
profile_nameYes
regionYes
startYes
endYes
granularityNoMONTHLY
group_byNo
metricsNo
filter_expressionNo
next_page_tokenNo
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing behavioral traits: it explains time range limitations (max 12 months for daily/monthly, 1 week for hourly), mentions pagination behavior via next_page_token, and describes response content. However, it doesn't cover authentication requirements beyond profile_name or potential rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is comprehensive but lengthy with multiple sections. While well-structured with clear headings, it could be more front-loaded; the core purpose appears early, but detailed parameter explanations dominate. Some redundancy exists (e.g., repeating grouping examples).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 9 parameters, 0% schema coverage, and no output schema, the description is largely complete: it covers purpose, parameters, usage examples, and response content. However, it lacks explicit error handling information and doesn't fully explain the output structure beyond listing included data types.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Given 0% schema description coverage, the description fully compensates by providing detailed parameter semantics: it explains all 9 parameters with examples, valid values, defaults, and constraints. It adds substantial meaning beyond the bare schema, including granularity options, grouping dimensions, filter expressions, and pagination usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as retrieving AWS cost and usage data with advanced filtering, grouping, and time-based analysis. It specifies the resource (AWS cost and usage data) and distinguishes from siblings like 'ce-get_cost_and_usage_with_resources' by focusing on comprehensive data analysis rather than resource-level details.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance through 'Common Use Cases' (e.g., monthly service breakdown, daily cost trends) and 'Best Practices' sections. It distinguishes when to use specific parameter combinations and mentions pagination for large datasets, though it doesn't explicitly contrast with sibling tools beyond the purpose differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Havoc24k/aws-sa-tools-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server