Get the FREE Ultimate OpenClaw Setup Guide →

aws-cost-explorer

MCP server for understanding AWS spend

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio aarora79-aws-cost-explorer-mcp-server python server.py \
  --env AWS_REGION="us-east-1" \
  --env MCP_TRANSPORT="stdio" \
  --env AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID" \
  --env AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY" \
  --env BEDROCK_LOG_GROUP_NAME="YOUR_BEDROCK_LOG_GROUP_NAME" \
  --env CROSS_ACCOUNT_ROLE_NAME="ROLE_NAME_FOR_THE_ROLE_TO_ASSUME_IN_OTHER_ACCOUNTS"

How to use

This MCP server exposes AWS Cost Explorer data and Bedrock model invocation logs to Claude Desktop via the Model Context Protocol (MCP). You can run the Python-based server locally and connect to it through Claude Desktop or a LangGraph Agent to query spend information in natural language. The server fetches AWS spend breakdowns (EC2, services, and cross-account data) and Bedrock usage logs, enabling interactive exploration and reporting. To use it, start the server with the required environment variables (AWS credentials, region, Bedrock log group name, and optional cross-account role) and configure Claude Desktop to point at the local MCP server or a remote one depending on your setup. The MCP transport in this configuration uses stdio for local usage, but you can switch to other transports if you deploy remotely.

How to install

Prerequisites:

  • Python 3.12+ and a functioning Python environment
  • AWS credentials with Cost Explorer and CloudWatch access
  • Access to Bedrock logs (optional for Bedrock-related data)

Step-by-step:

  1. Install uv (optional if you prefer Docker or direct Python): curl -LsSf https://astral.sh/uv/install.sh | sh

  2. Clone the repository (replace with your own repo if applicable): git clone https://github.com/aarora79/aws-cost-explorer-mcp.git cd aws-cost-explorer-mcp

  3. Create and activate a Python virtual environment and install dependencies: uv venv --python 3.12 && source .venv/bin/activate && uv pip install --requirement pyproject.toml

  4. Prepare AWS credentials and environment variables as described in the mcp_config (or export them in your shell). Then run the server module directly if you are not using Docker: python server.py

  5. Configure Claude Desktop with the MCP server details (see the mcp_config example) or run remotely with an appropriate transport (stdio for local, sse for remote).

Additional notes

Tips and notes:

  • Ensure the AWS credentials you provide have read access to Cost Explorer and CloudWatch Logs for Bedrock invocation data.
  • If you plan to access spend info from multiple accounts, set CROSS_ACCOUNT_ROLE_NAME to enable cross-account role assumption and provide the target account IDs through the MCP client interactions.
  • For remote deployments, consider using the sse transport and securing the server with proper IAM and network controls.
  • If you encounter permission or policy issues with CloudWatch Logs, verify that the Bedrock log group name and associated IAM policies are correct and accessible by the running role.
  • When using Docker, expose necessary AWS credentials as environment variables and avoid hardcoding sensitive keys in configuration files.

Related MCP Servers

Sponsor this space

Reach thousands of developers