{"id":7964,"library":"awslabs-cost-explorer-mcp-server","title":"AWS Cost Explorer MCP Server","description":"The `awslabs-cost-explorer-mcp-server` is a Python-based server application designed to analyze AWS costs and usage data by interacting with the AWS Cost Explorer API. Currently at version `0.0.21`, it provides a web interface for cost analysis and is primarily intended for deployment as a standalone service, often via Docker or AWS CDK, rather than as an embedded library. Its release cadence is infrequent, typical for experimental or early-stage AWS Labs projects.","status":"active","version":"0.0.21","language":"en","source_language":"en","source_url":"https://github.com/awslabs/mcp.git","tags":["aws","cost-management","cost-explorer","cloud","flask","server"],"install":[{"cmd":"pip install awslabs-cost-explorer-mcp-server","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"Required for AWS API interaction (Cost Explorer, EC2, etc.)","package":"boto3"},{"reason":"Web framework used for the server application","package":"Flask"}],"imports":[{"note":"This is the primary entry point for the Flask application if embedding programmatically. Typical usage is to run the server directly via `flask run` or a WSGI server.","symbol":"create_app","correct":"from awscostexplorer.mcp_server.app import create_app"}],"quickstart":{"code":"import os\nfrom awscostexplorer.mcp_server.app import create_app\n\n# Set dummy environment variables if not already set, for illustration.\n# In a real scenario, ensure valid AWS credentials are configured (e.g., ~/.aws/credentials,\n# IAM roles, or actual environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).\nos.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY')\nos.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET')\nos.environ['AWS_SESSION_TOKEN'] = os.environ.get('AWS_SESSION_TOKEN', '') # Optional\nos.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1') # Default region\n\n# Create the Flask application instance\napp = create_app()\n\nif __name__ == '__main__':\n    # Run the Flask development server.\n    # For production, use a WSGI server (e.g., Gunicorn, uWSGI) instead of app.run().\n    print(f\"\\nStarting AWS Cost Explorer MCP Server (Flask dev server) on http://127.0.0.1:5000/\")\n    print(\"Ensure valid AWS credentials and region are configured (e.g., via environment variables or ~/.aws/credentials).\")\n    print(\"Access the UI at http://127.0.0.1:5000/ and check server logs for errors.\\n\")\n    app.run(debug=True, port=5000)\n","lang":"python","description":"Installs the server and demonstrates how to run it locally using Flask's development server. This quickstart programmatically starts the server; alternatively, you can use `export FLASK_APP=awscostexplorer.mcp_server.app && flask run` from your shell. Requires AWS credentials and a default region to be configured in the environment or via other boto3-supported methods."},"warnings":[{"fix":"Review release notes for each update. Pin dependencies to specific patch versions in production environments.","message":"As a `0.0.x` version, the API and internal structure of the `awslabs-cost-explorer-mcp-server` may not be stable. Backward incompatible changes could occur in minor or patch releases.","severity":"breaking","affected_versions":"All versions below 1.0.0"},{"fix":"Ensure your environment has valid `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION` (or equivalent `~/.aws/credentials` setup, or IAM role for EC2/ECS). Grant necessary `ce:*` and `tag:*` permissions, and potentially `ec2:DescribeInstances` etc. as needed by the server's logic.","message":"The server relies heavily on correct AWS credentials and IAM permissions to access the Cost Explorer API and other AWS services. Incorrect or missing credentials/permissions are a very common source of errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Consider running the server as a standalone service and interacting with its web interface, rather than trying to embed its internal components directly into custom Python scripts, unless explicitly developing extensions for it.","message":"This library is primarily designed as a server application to be run directly (e.g., via `flask run`, Docker, or AWS CDK) rather than being imported and used as a traditional Python library within other applications. While programmatic embedding is possible, it's not the main use case.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Configure AWS credentials using environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`), an AWS config file (`~/.aws/credentials`), or by deploying on an EC2 instance/ECS task with an attached IAM role.","cause":"The server attempted to make an AWS API call (e.g., to Cost Explorer) but could not find any valid AWS credentials configured in the environment or standard locations.","error":"botocore.exceptions.NoCredentialsError: Unable to locate credentials"},{"fix":"Change the port the server tries to run on (e.g., `app.run(port=5001)` in Python, or `flask run --port 5001` from the shell), or terminate the process currently using the desired port.","cause":"The Flask development server (or any other process) tried to start on a port that is already in use by another application.","error":"OSError: [Errno 98] Address already in use"},{"fix":"Ensure the package is installed with `pip install awslabs-cost-explorer-mcp-server`. If running with `flask run`, set `FLASK_APP=awscostexplorer.mcp_server.app` before execution.","cause":"The `awslabs-cost-explorer-mcp-server` package is not installed, or the `FLASK_APP` environment variable (if using `flask run`) is incorrectly set, preventing Flask from finding the application entry point.","error":"ModuleNotFoundError: No module named 'awscostexplorer.mcp_server.app'"}]}