As cloud-native architectures grow increasingly complex and resource usage becomes more fragmented, managing and optimizing cloud costs has become a critical challenge for engineering teams and organizations alike. The key question is how to "spend smarter"—avoiding unnecessary compute overhead and hidden waste.
This is particularly relevant for teams running on AWS. While pay-as-you-go pricing offers flexibility, misconfigured or idle resources can lead to significant waste. That's why cost visibility and analysis are becoming essential capabilities to improve efficiency.
In this article, we’ll take a closer look at the Cost Analysis MCP Server, an open-source tool developed by AWS Labs. You’ll learn how it leverages the Model Context Protocol (MCP) to simplify cloud cost analysis and deliver actionable insights.
GitHub repo: https://github.com/awslabs/mcp/tree/main/src/cost-analysis-mcp-server
What Is the MCP Server?
The Model Context Protocol (MCP) is an open standard introduced by Anthropic. It provides a unified interface for large language models (LLMs) to interact with external data sources and tools.
The diagram below illustrates the key components of the MCP architecture:
- MCP Host: The LLM-powered application that initiates the request, such as Claude or an IDE.
- MCP Client: Maintains a 1:1 connection with the MCP Server, acting as a communication bridge.
- MCP Server: Supplies context, tools, and prompt information to the MCP Client.
Why Use MCP Server?
- Standardized Integration: MCP offers a consistent interface that simplifies the integration of AI models with external tools, accelerating development workflows.
- Real-Time Communication: Supports technologies like Server-Sent Events (SSE) to enable real-time data exchange between models and servers.
- Secure and Auditable: Built-in access control and logging features ensure secure and traceable interactions.
- Highly Extensible: Easily integrates with a variety of tools, allowing teams to tailor functionality to specific business needs.
In the context of cloud cost analysis, MCP Server acts as a bridge between AI models and AWS cost data—enabling real-time cost insights, analysis, and optimization directly from the model.
Key Features
✅ Visual AWS Cost Analysis
- Break down AWS costs with precision—organized by service, region, and usage tier.
- Quickly identify which services drive your cloud spend and uncover opportunities for targeted optimization.
💬 Natural Language Cost Queries
- No need to write complex queries. Ask questions like you would with ChatGPT: “Which service costs the most?” or “Why did my S3 spending spike?”
- The server pulls real-time data from AWS pricing pages and the AWS Pricing API—no manual digging required.
📊 One-Click Cost Reports and Optimization Suggestions
- Automatically scans your Infrastructure as Code (IaC) and generates tailored cost reports.
- Get intelligent recommendations based on actual usage—for example, whether to switch to Reserved Instances or identify underutilized resources.
Getting Started
Prerequisites
- Install
uv
via Astral - Use
uv python install 3.10
to install Python 3.10 - Set up credentials with permissions to access AWS services. Make sure you have:
- An AWS account with the necessary permissions
- AWS credentials configured via
aws configure
or environment variables - IAM roles or users with access to the AWS Pricing API
Installation
Step 1: Install the AWS CLI
Use the following command to install the AWS Command Line Interface (CLI):
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
Once the AWS CLI is installed, configure your credentials:
aws configure
You’ll be prompted to enter your AWS Access Key ID, Secret Access Key, region, and output format.
Make sure the IAM user or role you're using has permission to access the AWS Pricing API.
Step 2: Install Amazon Q
Download and install Amazon Q by following the official documentation: 👉 Installing Amazon Q
Follow the on-screen instructions in Amazon Q to register an account—just use your email address. Once registered, log in to access the Amazon Q interface.
Step 3: Set Up the Configuration File
Create a configuration file at the following path:
~/.aws/amazonq/mcp.json
This file will define how Amazon Q connects to the MCP Server.
{
"mcpServers": {
"awslabs.cost-analysis-mcp-server": {
"command": "uvx",
"args": ["awslabs.cost-analysis-mcp-server@latest"],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR",
"AWS_PROFILE": "your-aws-profile"
},
"disabled": false,
"autoApprove": []
}
}
}
AWS Authentication
The MCP Server uses the AWS credentials specified by the AWS_PROFILE
environment variable.
If AWS_PROFILE
is not set, it will fall back to the default
profile in your AWS CLI configuration.
"env": {
"AWS_PROFILE": "your-aws-profile"
}
Step 4: Start a Session
After installation, the MCP Server will create a boto3
session using the specified configuration file. This session will be used to authenticate with AWS services.
Your AWS IAM credentials will always remain local, used only for accessing AWS services.
q chat
Output (Start watching from 00:47 in the following video):
Conclusion
The AWS Cost Analysis MCP Server provides businesses with an efficient and intelligent solution for cloud cost analysis. By leveraging the standardized MCP protocol, companies can easily integrate cost analysis features to enhance their cloud cost management capabilities.
If you're ready to go beyond just cost analysis and begin optimizing your AWS cloud costs, consider trying CloudPilot AI, an intelligent cloud cost optimization platform. With just a few clicks, you can start optimizing your cloud spend. Below is a real-world example of the results our customers have achieved.
We offer a 30-day free trial — feel free to give it a try!