1. Overview
This demo shows how to run the Billing & Cost Management MCP Server locally and connect it to Amazon Q Developer CLI to query AWS cost data in natural language.
You’ll be able to ask questions like:
- “What was my AWS cost last month by service?”
- “Show CloudFront costs grouped by usage type.”
- “Compare EC2 vs S3 costs over the past 6 months.”
2. Prerequisites
- AWS Account with Cost Explorer enabled.
- AWS CLI installed and configured (aws configure).
- Python 3.10+ (for MCP server).
- uv / uvx (package runner from Astral).
- Amazon Q Developer CLI installed.
- IAM Policy with read-only access to:
- Cost Explorer (ce:*)
- Budgets (budgets:*)
- Compute Optimizer (compute-optimizer:*)
- (Optional) S3 + Athena + Glue for Storage Lens
- Install uv (Astral)
sudo apt update
sudo apt install -y curl unzip
curl -LsSf https://astral.sh/uv/install.sh | sh
4. Configure MCP Server
Create ~/.aws/amazonq/mcp.json:
{
"mcpServers": {
"awslabs.billing-cost-management-mcp-server": {
"command": "uvx",
"args": [
"awslabs.billing-cost-management-mcp-server@latest"
],
"env": {
"AWS_PROFILE": "default",
"AWS_REGION": "us-east-1"
},
"disabled": false,
"autoApprove": []
}
}
}
Replace "default" with your AWS profile name if different.
5. Run MCP Server (manual test)
uvx awslabs.billing-cost-management-mcp-server@latest
Starting FastMCP...
Registered tool: use_aws
6. Install Amazon Q CLI
Download & install:
curl --proto '=https' --tlsv1.2 -sSf \
"https://desktop-release.q.us-east-1.amazonaws.com/latest/q-x86_64-linux.zip" \
-o q.zip
unzip q.zip -d ~/q
cd ~/q
chmod +x install.sh
./install.sh
Follow prompts:
Select Yes when asked to update shell config.
Log in with AWS Builder ID when prompted.
Verify:
q --version
7. Connect Q CLI to MCP Server
Start a chat session:
q chat
8. Ask queries like:
Show my AWS costs grouped by service for the last 3 months.
9. IAM Policy (Minimal Read-Only)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage",
"ce:GetCostAndUsageWithResources",
"ce:GetCostForecast",
"ce:GetReservationUtilization",
"ce:ListCostCategoryDefinitions"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"budgets:DescribeBudgets",
"budgets:ViewBudget"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"compute-optimizer:DescribeRecommendations",
"compute-optimizer:GetRecommendationSummaries"
],
"Resource": "*"
}
]
}
✅ Conclusion
By setting up the AWS Billing & Cost Management MCP Server locally and integrating it with the Amazon Q Developer CLI, we can easily query AWS billing and usage data in natural language.
This setup enables:
Faster cost analysis using Cost Explorer without writing complex CLI commands.
CloudFront cost insights (via UsageType breakdowns like data transfer and requests).
Easy access to budgets, savings plans, and Graviton recommendations for optimization.
A repeatable demo environment that can be extended to other AWS services (CloudWatch, Config, Security Hub, etc.) using additional MCP servers.
In short, this approach simplifies cloud financial management, makes cost visibility more accessible to both engineers and business users, and provides a practical way to demonstrate AWS billing insights during workshops, demos, or team discussions.
Prithiviraj Rengarajan
DevOps Engineer
Top comments (0)