AWS Billing and Cost Management MCP Server

0.0.17 · active · verified Thu Apr 16

The AWS Billing and Cost Management Model Context Protocol (MCP) server provides tools to analyze historical spending, identify cost optimization opportunities, and estimate new workload costs by wrapping boto3 SDK functions. Released by AWS Labs, it is currently at version 0.0.17 and is actively maintained, with updates released as part of the broader `awslabs/mcp` repository development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart describes how to run the AWS Billing and Cost Management MCP server using `uvx` and provides an example configuration for an MCP client like Amazon Q Developer CLI. The server itself is designed to be run as a separate process, and AI clients then connect to it to leverage its capabilities via natural language queries. Ensure `uv` is installed and AWS credentials with appropriate permissions are configured.

import os

# Prerequisites: Install uv (e.g., curl -LsSf https://astral.sh/uv/install.sh | sh)
# Ensure AWS credentials are configured (e.g., via ~/.aws/credentials or environment variables)
# Minimum IAM permissions for Cost Explorer (ce:*), Budgets (budgets:*), Compute Optimizer (compute-optimizer:*)

# Example of running the server via uvx and configuring an MCP client (like Amazon Q Developer CLI)
# This code snippet demonstrates how to run the server in a way that an MCP client can connect.
# It's not a direct Python import/call, but a shell command typically executed to start the server.

# Set environment variables for AWS credentials if not using default profile
# os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_AWS_ACCESS_KEY_ID')
# os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_AWS_SECRET_ACCESS_KEY')
# os.environ['AWS_SESSION_TOKEN'] = os.environ.get('AWS_SESSION_TOKEN', '') # Optional for temporary credentials
os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')
os.environ['AWS_PROFILE'] = os.environ.get('AWS_PROFILE', 'default')

print("Starting AWS Billing and Cost Management MCP Server...")
print("Run 'uvx awslabs.billing-cost-management-mcp-server@latest' in your terminal.")
print("Then, configure your MCP client (e.g., Amazon Q Developer CLI) to connect.")
print("Example client configuration for ~/.aws/amazonq/mcp.json:")
print("{")
print("  \"mcpServers\": {")
print("    \"awslabs.billing-cost-management-mcp-server\": {")
print("      \"command\": \"uvx\",")
print("      \"args\": [ \"awslabs.billing-cost-management-mcp-server@latest\" ],")
print("      \"env\": {")
print("        \"AWS_PROFILE\": \"" + os.environ['AWS_PROFILE'] + "\",")
print("        \"AWS_REGION\": \"" + os.environ['AWS_REGION'] + "\"")
print("      },")
print("      \"disabled\": false,")
print("      \"autoApprove\": []")
print("    }")
print("  }")
print("}")

view raw JSON →