MCP

Analyze AWS Spending with Natural Language

Analyze AWS spending data through Cost Explorer and Amazon Bedrock usage statistics via natural language queries.

Works with awscloudwatchbedrock

90
Spark score
out of 100
Updated 4 months ago
Version 1.0.0
Models

Add to Favorites

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

01

Query AWS spending data using natural language.

02

Analyze EC2 and Bedrock costs by region, service, and user.

03

Generate daily and hourly usage statistics for Bedrock models.

04

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

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

Overview

AWS Cost Explorer MCP Server

What it does

This MCP server analyzes 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 can be done from source:

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

Or via Docker:

docker build -t aws-cost-explorer-mcp .
docker run -v ~/.aws:/root/.aws aws-cost-explorer-mcp

Available tools include get_ec2_spend_last_day, get_detailed_breakdown_by_day, get_bedrock_daily_usage_stats, and get_bedrock_hourly_usage_stats.

How it connects

2024-05-15T19:07:23.123456Z

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 logs
  • AWS_ACCESS_KEY_ID - AWS access key ID for authentication
  • AWS_SECRET_ACCESS_KEY - AWS secret access key for authentication
  • AWS_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.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.