Analyze AWS Spending with Natural Language
Query AWS EC2 and Bedrock spending conversationally through Cost Explorer and CloudWatch usage logs.
Why it matters
Gain insights into your AWS spending patterns and Amazon Bedrock usage through natural language queries. This asset connects to AWS Cost Explorer and CloudWatch logs to provide detailed cost breakdowns and usage statistics.
Outcomes
What it gets done
Query AWS spending data using natural language.
Analyze EC2 and Bedrock costs by region, service, and user.
Generate daily and hourly usage statistics for Bedrock models.
Provide detailed cost breakdowns for the last 30 days.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-aws-cost-explorer | bash Capabilities
Tools your agent gets
Retrieves EC2 spending data for the previous day
Provides comprehensive cost analysis by regions, services, and instance types
Provides daily model usage statistics by regions and users
Provides hourly model usage statistics by regions and users
Overview
AWS Cost Explorer MCP Server
An MCP server analyzing AWS spending via Cost Explorer and Bedrock model usage via CloudWatch logs, answering natural-language cost questions. Use it when you want to query AWS EC2/service spend or Bedrock usage conversationally - requires Cost Explorer and CloudWatch Logs IAM permissions.
What it does
This MCP server analyzes AWS spending data through Cost Explorer and Amazon Bedrock usage statistics through model invocation logs in CloudWatch, letting you ask natural-language questions about AWS spending patterns. It provides get_ec2_spend_last_day for the previous day's EC2 costs, get_detailed_breakdown_by_day for cost analysis by region, service, and instance type, and get_bedrock_daily_usage_stats / get_bedrock_hourly_usage_stats for Bedrock model usage broken down by region and user.
It supports cross-account access via IAM role assumption to retrieve spending information from other AWS accounts, and can run as a remote server on EC2 with HTTPS via an nginx reverse proxy (though the notes point out Claude Desktop does not currently support remote MCP servers).
docker build -t aws-cost-explorer-mcp .
docker run -v ~/.aws:/root/.aws aws-cost-explorer-mcp
It can also be installed from source with uv (uv venv --python 3.12 && source .venv/bin/activate && uv pip install --requirement pyproject.toml), or run locally as a plain Python process with MCP_TRANSPORT, BEDROCK_LOG_GROUP_NAME, and CROSS_ACCOUNT_ROLE_NAME set as environment variables before python server.py.
When to use - and when NOT to
Use this when you want to ask an AI assistant questions like "how much did I spend on EC2 yesterday?", "show me the top 5 AWS services by cost for the last month", "analyze my spending by regions for the last 14 days", "which instance types are costing me the most?", or "help me understand my Bedrock spending over the last few weeks" instead of navigating the AWS Cost Explorer console manually.
Do NOT use this without AWS credentials configured with Cost Explorer access and appropriate IAM permissions for CloudWatch Logs - both are required. To track Bedrock usage specifically, you must first configure model invocation logging in CloudWatch (BEDROCK_LOG_GROUP_NAME).
Inputs and outputs
Inputs are natural-language cost questions that map to time ranges, regions, services, or instance types; outputs are structured spend breakdowns and Bedrock usage statistics by region and user.
Integrations
AWS Cost Explorer, Amazon Bedrock (via CloudWatch model invocation logs), and cross-account IAM role assumption. Optional remote deployment on EC2 with nginx for HTTPS, and integration with a Chainlit chatbot interface via a LangGraph Agent.
Who it's for
FinOps teams, cloud engineers, and anyone tracking AWS costs who wants to query EC2 spend, per-service cost breakdowns, and Bedrock model usage conversationally instead of digging through the AWS console. Claude Desktop can be configured against either the Docker image or a local uv-managed checkout, both taking the same AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_REGION/BEDROCK_LOG_GROUP_NAME/CROSS_ACCOUNT_ROLE_NAME environment variables.
Source README
An MCP server for analyzing AWS spending data through Cost Explorer and Amazon Bedrock usage statistics through model invocation logs in Amazon CloudWatch, enabling natural language queries about AWS spending patterns.
Installation
From Source with UV
git clone https://github.com/aarora79/aws-cost-explorer-mcp.git
cd aws-cost-explorer-mcp
uv venv --python 3.12 && source .venv/bin/activate && uv pip install --requirement pyproject.toml
Docker
docker build -t aws-cost-explorer-mcp .
docker run -v ~/.aws:/root/.aws aws-cost-explorer-mcp
Local Server
export MCP_TRANSPORT=stdio
export BEDROCK_LOG_GROUP_NAME=YOUR_BEDROCK_CW_LOG_GROUP_NAME
export CROSS_ACCOUNT_ROLE_NAME=ROLE_NAME_FOR_THE_ROLE_TO_ASSUME_IN_OTHER_ACCOUNTS
python server.py
Configuration
Claude Desktop - Docker
{
"mcpServers": {
"aws-cost-explorer": {
"command": "docker",
"args": [ "run", "-i", "--rm", "-e", "AWS_ACCESS_KEY_ID", "-e", "AWS_SECRET_ACCESS_KEY", "-e", "AWS_REGION", "-e", "BEDROCK_LOG_GROUP_NAME", "-e", "MCP_TRANSPORT", "-e", "CROSS_ACCOUNT_ROLE_NAME", "aws-cost-explorer-mcp:latest" ],
"env": {
"AWS_ACCESS_KEY_ID": "YOUR_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY": "YOUR_SECRET_ACCESS_KEY",
"AWS_REGION": "us-east-1",
"BEDROCK_LOG_GROUP_NAME": "YOUR_CLOUDWATCH_BEDROCK_MODEL_INVOCATION_LOG_GROUP_NAME",
"CROSS_ACCOUNT_ROLE_NAME": "ROLE_NAME_FOR_THE_ROLE_TO_ASSUME_IN_OTHER_ACCOUNTS",
"MCP_TRANSPORT": "stdio"
}
}
}
}
Claude Desktop - UV
{
"mcpServers": {
"aws_cost_explorer": {
"command": "uv",
"args": [
"--directory",
"/path/to/aws-cost-explorer-mcp-server",
"run",
"server.py"
],
"env": {
"AWS_ACCESS_KEY_ID": "YOUR_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY": "YOUR_SECRET_ACCESS_KEY",
"AWS_REGION": "us-east-1",
"BEDROCK_LOG_GROUP_NAME": "YOUR_CLOUDWATCH_BEDROCK_MODEL_INVOCATION_LOG_GROUP_NAME",
"CROSS_ACCOUNT_ROLE_NAME": "ROLE_NAME_FOR_THE_ROLE_TO_ASSUME_IN_OTHER_ACCOUNTS",
"MCP_TRANSPORT": "stdio"
}
}
}
}
Available Tools
| Tool | Description |
|---|---|
get_ec2_spend_last_day |
Retrieves EC2 spending data for the previous day |
get_detailed_breakdown_by_day |
Provides comprehensive cost analysis by regions, services, and instance types |
get_bedrock_daily_usage_stats |
Provides daily model usage statistics by regions and users |
get_bedrock_hourly_usage_stats |
Provides hourly model usage statistics by regions and users |
Features
- Amazon EC2 spending analysis: View detailed breakdown of EC2 costs for the last day
- Amazon Bedrock spending analysis: View breakdown by regions, users, and models for the last 30 days
- Service spending reports: Analyze AWS service spending across all services for the last 30 days
- Detailed cost breakdown: Get granular cost data by days, regions, services, and instance types
- Interactive interface: Use Claude to query cost data in natural language
- Cross-account access: Retrieve AWS spending information from other accounts with proper IAM role assumption
- Remote MCP server support: Run the server on Amazon EC2 with HTTPS support via nginx reverse proxy
- LangGraph Agent integration: Use with Chainlit application for chatbot interface
Environment Variables
Required
MCP_TRANSPORT- Transport method for MCP (stdio for local, sse for remote)BEDROCK_LOG_GROUP_NAME- CloudWatch log group name for Bedrock model invocation logsAWS_ACCESS_KEY_ID- AWS access key ID for authenticationAWS_SECRET_ACCESS_KEY- AWS secret access key for authenticationAWS_REGION- AWS region to use
Optional
CROSS_ACCOUNT_ROLE_NAME- Role name for assuming roles in other AWS accounts to retrieve cross-account spending information
Usage Examples
Help me understand my Bedrock spending over the last few weeks
How much did I spend on EC2 yesterday?
Show me the top 5 AWS services by cost for the last month
Analyze my spending by regions for the last 14 days
Which instance types are costing me the most?
Notes
Requires AWS credentials with access to Cost Explorer and appropriate IAM permissions for CloudWatch Logs. To track Bedrock usage, you must configure model invocation logs in Amazon CloudWatch. Supports both local and remote deployment with HTTPS support via nginx reverse proxy. Note that Claude Desktop currently does not support remote MCP servers.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.