AWS Cost Explorer MCP Server

0.0.21 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import os
from awscostexplorer.mcp_server.app import create_app

# Set dummy environment variables if not already set, for illustration.
# In a real scenario, ensure valid AWS credentials are configured (e.g., ~/.aws/credentials,
# IAM roles, or actual environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).
os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY')
os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET')
os.environ['AWS_SESSION_TOKEN'] = os.environ.get('AWS_SESSION_TOKEN', '') # Optional
os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1') # Default region

# Create the Flask application instance
app = create_app()

if __name__ == '__main__':
    # Run the Flask development server.
    # For production, use a WSGI server (e.g., Gunicorn, uWSGI) instead of app.run().
    print(f"\nStarting AWS Cost Explorer MCP Server (Flask dev server) on http://127.0.0.1:5000/")
    print("Ensure valid AWS credentials and region are configured (e.g., via environment variables or ~/.aws/credentials).")
    print("Access the UI at http://127.0.0.1:5000/ and check server logs for errors.\n")
    app.run(debug=True, port=5000)

view raw JSON →