awslabs.billing-cost-management-mcp-server: A Model Context Protocol (MCP) server that provides tools for AWS Billing and Cost Management by wrapping boto3 SDK functions. · Pythie
MCP server for accessing AWS Billing and Cost Management capabilities.
Important Note: This server accesses cost and usage data from AWS Billing and Cost Management APIs. All API calls are performed using the caller's AWS credentials and follow AWS service limits and quotas.
Cost Explorer insights: Analyze historical and forecasted AWS costs with flexible grouping and filtering
Usage metrics analysis: Track resource usage trends across your AWS environment
Budget monitoring: Check existing budgets and their status against actual spending, plus their configured enforcement actions and alert notifications (per-budget or account-wide)
Cost anomaly detection: Identify unusual spending patterns and their root causes
Cost Optimization Recommendations
Compute Optimizer recommendations: Get right-sizing suggestions for EC2, Lambda, EBS, and more
Cost Optimization Hub: Access cost-saving opportunities across your AWS environment
Savings Plans and Reserved Instanaces
Reserved Instance planning: Analyze RI coverage and receive purchase recommendations
Savings Plans performance: Analyze how much eligible spend existing plans cover and how much of their commitment is consumed over a lookback window
Savings Plans inventory: Describe the plans an account owns with their state, term, payment option, commitment, and expiry, including the queued, returned, and payment-failed plans that Cost Explorer does not report; a large inventory is offloaded to session SQL to save tokens
Savings Plans rates and offerings: Look up the rates locked in on plans already owned, and the offerings available to purchase with their rates, to compare terms and payment options against real numbers. A large result from any of these describe operations is offloaded to session SQL (queryable with the tool) to save tokens
session-sql
Savings Plans recommendations: Get personalized purchase recommendations based on usage patterns, the hourly data-points behind a recommendation, and the history of when recommendations were generated
Savings Plans purchase analysis: Run Purchase Analyzer what-if analyses — maximum savings, a specific commitment, or a target average coverage — and retrieve the projected cost, coverage, and utilization once an analysis completes
S3 Storage Lens Analysis
Storage metrics querying: Run SQL queries against Storage Lens metrics data
Storage cost breakdown: Analyze S3 storage costs by bucket, storage class, and region
Storage optimization opportunities: Identify lifecycle policy opportunities and cost-saving measures
Cost and Usage Comparison
Month-over-month comparisons: Compare cost and usage between time periods with detailed breakdown
Multi-account analysis: Analyze costs across multiple linked accounts
AWS Billing and Cost Management Pricing Calculator
Workload estimate insights: Query workload estimates to see what usage you have estimated
AWS Billing Conductor & Proforma Cost Analysis
Billing group management: List and filter billing groups with details on type, status, pricing plans, and member accounts
Account associations: View linked account associations with billing groups, filter by monitored/unmonitored status
Billing group cost reports: Retrieve cost report summaries comparing actual AWS charges vs proforma costs with margin analysis
Detailed cost breakdowns: Get billing group cost reports broken down by service name or billing period
Pricing rules and plans: List pricing rules (MARKUP, DISCOUNT, TIERING) and pricing plans with their associations
Custom line items: List custom cost allocations including support fees, shared service costs, taxes, credits, and RI/SP distribution
Billing transfer preferences: Check whether billing groups are created automatically for new end customers in a two-level billing transfer, and which pricing plan they use
Cost Allocation Tags
Tag activation status: List cost allocation tags with filters by status (Active/Inactive), type (AWSGenerated/UserDefined), and specific tag keys
Backfill history: Retrieve the history of tag backfill requests that retroactively apply activation status to historical billing data
Cost Category Definitions
Describe cost categories: Get the full definition of a cost category including rules, split charge rules, and processing status
List cost categories: List all cost category definitions in the account with summary metadata and filtering by effective date or supported resource types
AWS Invoicing
Invoice summaries: List invoice-level details (invoice ID, type, billing period, issued/due dates, issuing entity, and amounts with discount/tax/fee breakdowns across base, tax, and payment currencies) for an account (filtered by month or date range) or a single invoice
Invoice units: List and retrieve invoice unit definitions (groups of accounts that receive a separate invoice, with their receiver account and linked-account rules), filtered by name, receiver, or member account; and fetch invoice receiver profiles (legal name, address, tax registration number) for a set of accounts
Procurement portal preferences: List and retrieve procurement portal connections (SAP Business Network, Coupa) and e-invoice delivery / purchase-order retrieval settings
AWS Billing Preferences
Discount sharing configuration: Retrieve which member accounts participate in the Reserved Instance / Savings Plans discount pool and in credit sharing, whether newly created accounts join automatically, and whether sharing is open — the authoritative answer to "is this account excluded from commitment sharing", which cannot be inferred from RI/SP coverage data
Sharing history: The per-billing-period record of those settings, for reconciling a closed billing period against the sharing state that was actually in force at the time
Billing alerts: Whether billing alerts are enabled
AWS Enterprise Support
Enterprise Support charge summary: Retrieve a billing period's Enterprise Support charge with the Support-eligible spend it was calculated from, the effective pricing plan, and any applied discounts
Support contract details: Review the contract terms that govern how a billing period's charge is allocated, including the allocation method, Reserved Instance and Savings Plan treatment, and the payer accounts covered
Per-account charge breakdown: Break a billing period's charge down by linked account with prorated Support-eligible spend, subscription periods, and per-service spend
AWS Business Support
Account charges: Retrieve a billing month's Business Support charges per account, with the Support-eligible spend each charge was calculated from, the tiered charge breakdown, any applied discount, and the profile-wide totals. The current month is returned as an estimate
Subscription history: Review the Support plan contracts in effect for a billing month or a date range, including the plan and the contract start and end dates
Specialized Cost Optimization Prompts
Graviton migration analysis: Guided analysis to identify EC2 instances suitable for AWS Graviton migration
Savings Plans analysis: Structured recommendations for optimal Savings Plans purchases based on usage patterns
NOTE: Your credentials will need to be kept refreshed from your host
Storage Lens Configuration
To use the Storage Lens functionality, you'll need to set the following environment variables:
STORAGE_LENS_MANIFEST_LOCATION: S3 URI to your Storage Lens manifest file or folder (e.g., s3://bucket-name/storage-lens/manifests/)
STORAGE_LENS_OUTPUT_LOCATION (optional): S3 location for Athena query results (defaults to the same bucket as the manifest with an athena-results/ suffix)
List tools take max_items (the total number of items to return) and next_token. Without max_items a tool fetches every page; with it, the tool stops before a page that could take the result past max_items (the first page is always returned). ri-performanceget_reservation_utilization grouped by SUBSCRIPTION_ID takes max_pages instead of max_items: its next_token only works with the same page size, so it returns whole pages of 500 groups; omit max_pages to fetch every page. Billing Conductor get-billing-group-cost-report requests pages of 200 to 300 results, the range the service accepts, so a max_items below 200 can return up to 200. next_token in a response is the AWS service's own continuation token: pass it back, with every other parameter unchanged, to get the next items.
A response that stops before the end of the data leads with complete_dataset: false and a warning, and every paginated response carries a pagination block:
The pagination block comes before the data, so it is read before the data itself.
has_more is true only when next_token can continue the result. A result can be partial with has_more: false, for example when a page failed in a way that invalidates the token or when one region of a multi-region call failed; the warning then says how to recover.
One call also stops paging, on a page boundary, when it reaches the server's time limit. The result is then partial and continues with next_token.
Environment variable
Default
Limit
BCM_MCP_PAGINATION_MAX_SECONDS
300
Seconds one call spends paging
A rejected or expired next_token returns error_type: invalid_next_token; call again without next_token to restart.
Error responses
Tool errors are returned with isError: true and a JSON body that includes:
Field
Description
status
Always error
error_type
Stable classification. AWS API errors pass the AWS error code through (ThrottlingException, AccessDeniedException, ...); local errors use lowercase values (validation_error, no_results, invalid_operation, ...)
message
Human-readable explanation
retry_strategy
What the caller should do next: retry_same_request, modify_request, or do_not_retry
hint
Optional fixed recovery guidance
retry_strategy is derived from error_type:
retry_strategy
error_type values
retry_same_request
Throttling (ThrottlingException, Throttling, ThrottledException, TooManyRequestsException, RequestLimitExceeded, LimitExceededException, RequestThrottled, RequestThrottledException, ProvisionedThroughputExceededException, TransactionInProgressException, PriorRequestNotComplete, EC2ThrottledException, SlowDown, BandwidthLimitExceeded, throttling_error), aws_connection_error (transient botocore errors only: connection failures, no client-side request capacity, response body cut short or corrupted; other botocore errors set their own retry_strategy, see below), server-side errors (InternalServerException, InternalErrorException, InternalError, IDPCommunicationError, ServiceUnavailable, service_unavailable, ...), timeouts (unknown_timeouterror), and any otherwise unmapped AWS error with an HTTP 5xx status
AccessDenied*, access_denied, UnauthorizedOperation, UnauthorizedException, AuthFailure, OptInRequiredException, opt_in_required, enrollment_error, DataUnavailableException, and any missing or unrecognized error_type
A tool can override the mapping for a specific error by passing retry_strategy= and hint= to format_response. Session SQL errors from invalid queries are modify_request, and when every region of a multi-region call fails, retry_strategy is combined from each region's own error. A botocore ParamValidationError (malformed request parameters, rejected before any request is sent) is a validation_error. aws_connection_error is retry_same_request only for transient failures: botocore's ConnectionError and HTTPClientError classes (such as EndpointConnectionError and ReadTimeoutError), CapacityNotAvailableError (raised by botocore's client-side token bucket when no request capacity is available; kept retryable), and a response body cut short or corrupted in transit (IncompleteReadError, ChecksumError, FlexibleChecksumError); boto_error_type names the botocore class. Every other botocore error keeps error_type: aws_connection_error but sets its own retry_strategy: modify_request for botocore's other argument checks (UnknownParameterError, RangeError, ...), and do_not_retry for credential and configuration errors (NoCredentialsError, CredentialRetrievalError from a failed credential_process, an expired SSO token, NoRegionError, ProfileNotFound, ...) and any other SDK-side failure, since a retry fails the same way. The full mapping is in utilities/error_contract.py.
Supported AWS Services
The server currently supports the following AWS services
get-billing-view: retrieve metadata for a specific billing view
list-billing-views: list billing views available for a given time period
list-source-views-for-billing-view: list source views that a custom billing view is built from
get-resource-policy: retrieve the resource-based policy attached to a billing view
list-billing-view-segments: list billing view segments over a time period to determine billing domain (BILLABLE vs PRO_FORMA) and account relationships
awslabs.aws-iac-mcp-serverAn Infrastructure as Code MCP server that provides CloudFormation template validation, compliance checking, and deployment troubleshooting capabilities.