{"type":"mcp_server","name":"aws-cost-explorer-mcp-server","description":"This repository provides an MCP server for accessing AWS Cost Explorer and Amazon Bedrock usage data through CloudWatch Logs, enabling users to analyze and visualize AWS spending data using Anthropic's Claude.","category":"System Tools","language":"Python","stars":127,"forks":16,"owner":"aarora79","github_url":"https://github.com/aarora79/aws-cost-explorer-mcp-server","homepage":null,"setup":"## Setup\n1. Install `uv`:\n   ```bash\n   # On macOS and Linux\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n   ```\n   \n   ```powershell\n   # On Windows\n   powershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n   ```\n\n2. Clone this repository:\n   ```\n   git clone https://github.com/aarora79/aws-cost-explorer-mcp.git\n   cd aws-cost-explorer-mcp\n   ```\n\n3. Set up the Python virtual environment and install dependencies:\n   ```\n   uv venv --python 3.12 && source .venv/bin/activate && uv pip install --requirement pyproject.toml\n   ```\n   \n4. Configure your AWS credentials:\n   ```\n   mkdir -p ~/.aws\n   # Set up your credentials in ~/.aws/credentials and ~/.aws/config\n   ```\n\n### Prerequisites\n\n1. Setup [model invocation logs](https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html#setup-cloudwatch-logs-destination) in Amazon CloudWatch.\n2. Ensure that the IAM user/role being used has full read-only access to Amazon Cost Explorer and Amazon CloudWatch, this is required for the MCP server to retrieve data from these services.\n\n### Local setup\nUses `stdio` as a transport for MCP, both the MCP server and client are running on your local machine.\n\n#### Starting the Server (local)\n\nRun the server using:\n\n```\nexport MCP_TRANSPORT=stdio\nexport BEDROCK_LOG_GROUP_NAME=YOUR_BEDROCK_CW_LOG_GROUP_NAME\npython server.py\n```\n\n#### Claude Desktop Configuration\n\nThere are two ways to configure this tool with Claude Desktop:\n\n##### Option 1: Using Docker\n\nAdd the following to your Claude Desktop configuration file.\n\n```json\n{\n  \"mcpServers\": {\n    \"aws-cost-explorer\": {\n      \"command\": \"docker\",\n      \"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\", \"aws-cost-explorer-mcp:latest\" ],\n      \"env\": {\n        \"AWS_ACCESS_KEY_ID\": \"YOUR_ACCESS_KEY_ID\",\n        \"AWS_SECRET_ACCESS_KEY\": \"YOUR_SECRET_ACCESS_KEY\",\n        \"AWS_REGION\": \"us-east-1\",\n        \"BEDROCK_LOG_GROUP_NAME\": \"YOUR_CLOUDWATCH_BEDROCK_MODEL_INVOCATION_LOG_GROUP_NAME\",\n        \"MCP_TRANSPORT\": \"stdio\"\n      }\n    }\n  }\n}\n```\n\n##### Option 2: Using UV (without Docker)\n\n```json\n{\n  \"mcpServers\": {\n    \"aws_cost_explorer\": {\n      \"command\": \"uv\",\n      \"args\": [\n          \"--directory\",\n          \"/path/to/aws-cost-explorer-mcp-server\",\n          \"run\",\n          \"server.py\"\n      ],\n      \"env\": {\n        \"AWS_ACCESS_KEY_ID\": \"YOUR_ACCESS_KEY_ID\",\n        \"AWS_SECRET_ACCESS_KEY\": \"YOUR_SECRET_ACCESS_KEY\",\n        \"AWS_REGION\": \"us-east-1\",\n        \"BEDROCK_LOG_GROUP_NAME\": \"YOUR_CLOUDWATCH_BEDROCK_MODEL_INVOCATION_LOG_GROUP_NAME\",\n        \"MCP_TRANSPORT\": \"stdio\"\n      }\n    }\n  }\n}\n```\n\n### Remote setup\nUses `sse` as a transport for MCP, the MCP servers on EC2 and the client is running on your local machine.\n\n#### Starting the Server (remote)\n\nRun the server using:\n\n```\nexport MCP_TRANSPORT=sse\nexport BEDROCK_LOG_GROUP_NAME=YOUR_BEDROCK_CW_LOG_GROUP_NAME\npython server.py\n```\n\n1. The MCP server will start listening on TCP port 8000.\n2. Configure an ingress rule in the security group associated with your EC2 instance to allow access to TCP port 8000 from your local machine.\n","tools":"## Available Tools\n\n1.  **Amazon EC2 Spend Analysis** (View detailed breakdowns of EC2 spending for the last day)\n2.  **Amazon Bedrock Spend Analysis** (View breakdown by region, users and models over the last 30 days)\n3.  **Service Spend Reports** (Analyze spending across all AWS services for the last 30 days)\n4.  **Detailed Cost Breakdown** (Get granular cost data by day, region, service, and instance type)\n5.  **Interactive Interface** (Use Claude to query your cost data through natural language)\n6.  **`get_ec2_spend_last_day()`** (Retrieves EC2 spending data for the previous day)\n7.  **`get_detailed_breakdown_by_day(days=7)`** (Delivers a comprehensive analysis of costs by region, service, and instance type)\n8.  **`get_bedrock_daily_usage_stats(days=7, region='us-east-1', log_group_name='BedrockModelInvocationLogGroup')`** (Delivers a per-day breakdown of model usage by region and users)\n9.  **`get_bedrock_hourly_usage_stats(days=7, region='us-east-1', log_group_name='BedrockModelInvocationLogGroup')`** (Delivers a per-day per-hour breakdown of model usage by region and users)","faq":null,"created_at":"2025-03-09T16:50:17+00:00","updated_at":"2025-03-28T22:00:28+00:00","source_url":"https://model-context-protocol.com/servers/aws-cost-explorer-mcp-server-analyze","related_articles":[]}