Skip to main content
Glama

ce-get_cost_and_usage_with_resources

Retrieve detailed AWS cost and usage data with individual resource-level granularity for EC2 instances, RDS databases, and S3 buckets to enable cost allocation, rightsizing analysis, and optimization opportunities.

Instructions

Retrieve detailed AWS cost and usage data with individual resource-level granularity and identification.

This tool provides the most granular cost analysis available, showing costs for individual AWS resources
such as specific EC2 instances, RDS databases, and S3 buckets. Essential for detailed cost allocation,
rightsizing analysis, and identifying cost optimization opportunities at the resource level.

**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')
  * **Note:** Maximum 14 days range for resource-level data
  * Hourly granularity not supported for resource-level analysis

**Optional Parameters:**
- granularity (str): Time granularity for cost breakdown. Default: 'MONTHLY'
  * 'DAILY': Day-by-day resource cost breakdown (max 14 days)
  * 'MONTHLY': Month-by-month resource cost breakdown (max 14 days)
  * **Note:** HOURLY not supported for resource-level data

- group_by (List[Dict[str, str]]): Grouping dimensions for resource analysis
  **Resource Grouping:**
  [{'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}] - Group by individual resources

  **Service + Resource:**
  [{'Type': 'DIMENSION', 'Key': 'SERVICE'}, {'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

  **Tag-based Resource Analysis:**
  [{'Type': 'TAG', 'Key': 'Name'}, {'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]
  [{'Type': 'TAG', 'Key': 'Environment'}, {'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

- 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': Resource usage amount (hours, GB, requests, etc.)
  * 'NormalizedUsageAmount': Usage normalized to equivalent units

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

  **Resource Type Filters:**
  {'Dimensions': {'Key': 'INSTANCE_TYPE', 'Values': ['t3.micro', 'm5.large']}}

  **Tag-based Resource Filters:**
  {'Tags': {'Key': 'Environment', 'Values': ['production']}}
  {'Tags': {'Key': 'Owner', 'Values': ['team-a', 'team-b']}}

  **Complex Resource Filters:**
  {'And': [{'Dimensions': {'Key': 'SERVICE', 'Values': ['EC2']}}, {'Tags': {'Key': 'Environment', 'Values': ['production']}}]}

- next_page_token (str): Pagination token from previous response
  * Essential for resource-level data due to large result sets

**Common Use Cases:**
1. **EC2 instance cost analysis:**
   filter_expression={'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Elastic Compute Cloud - Compute']}}
   group_by=[{'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

2. **RDS database cost breakdown:**
   filter_expression={'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Relational Database Service']}}
   group_by=[{'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

3. **S3 bucket cost analysis:**
   filter_expression={'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Simple Storage Service']}}
   group_by=[{'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

4. **Team-based resource costs:**
   filter_expression={'Tags': {'Key': 'Team', 'Values': ['backend', 'frontend']}}
   group_by=[{'Type': 'TAG', 'Key': 'Team'}, {'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

5. **Environment resource breakdown:**
   filter_expression={'Tags': {'Key': 'Environment', 'Values': ['production']}}
   group_by=[{'Type': 'DIMENSION', 'Key': 'RESOURCE_ID'}]

**Response includes:** Time periods, individual resource identifiers, cost amounts,
resource metadata, and grouping dimensions for granular cost analysis.

**Important Limitations:**
- Maximum 14-day date range (AWS limitation for resource-level data)
- Large result sets require pagination
- Not all services provide resource-level cost data
- Higher API costs compared to standard cost analysis

**Best Practices:**
- Use specific service filters to reduce data volume
- Implement pagination for comprehensive analysis
- Focus on high-cost services for optimization
- Combine with tagging strategies for better insights
- Use for detailed cost allocation and chargeback reporting

Input Schema

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

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

With no annotations provided, the description carries the full burden of behavioral disclosure and does so comprehensively. It explains critical behavioral traits: the 14-day maximum date range, pagination requirements ('Large result sets require pagination'), API cost implications ('Higher API costs compared to standard cost analysis'), and service limitations ('Not all services provide resource-level cost data'). It also describes the response format and provides best practices.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, required/optional parameters, use cases, limitations, best practices) and uses bullet points effectively. However, at approximately 800 words, it is quite lengthy. While most content is valuable, some repetition (e.g., restating the 14-day limit) could be trimmed for better conciseness.

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

Completeness5/5

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

Given the tool's complexity (9 parameters, no annotations, no output schema), the description is exceptionally complete. It covers purpose, usage guidelines, detailed parameter semantics, behavioral constraints, common use cases with examples, response content, limitations, and best practices. This provides all necessary context for an AI agent to understand and correctly invoke this tool.

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?

With 0% schema description coverage for 9 parameters, the description fully compensates by providing extensive parameter semantics. Each parameter is documented with purpose, format, constraints, and examples. For complex parameters like 'group_by' and 'filter_expression', it provides multiple concrete examples with syntax. The description adds significant value beyond what the bare schema provides.

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: 'Retrieve detailed AWS cost and usage data with individual resource-level granularity and identification.' It specifies the verb ('retrieve'), resource ('AWS cost and usage data'), and key differentiator ('resource-level granularity'). It distinguishes from sibling tools like 'ce-get_cost_and_usage' by emphasizing resource-level detail.

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 guidance on when to use this tool versus alternatives. It states this is 'the most granular cost analysis available' and is 'essential for detailed cost allocation, rightsizing analysis, and identifying cost optimization opportunities at the resource level.' The 'Common Use Cases' section gives concrete examples, and the 'Important Limitations' section clarifies constraints like the 14-day maximum range.

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