AWS Cost Explorer MCP Server
Enables querying AWS costs and usage data from Claude Desktop through the Cost Explorer API.
README
AWS Cost Explorer MCP Server
A Model Context Protocol (MCP) server that provides AWS Cost Explorer API access to Claude Desktop. Query your AWS costs and usage data directly from Claude conversations.
Architecture
Local MCP Server (Current Implementation)
graph TB
subgraph "Your Machine"
CD[Claude Desktop]
MCP[MCP Server<br/>Node.js Process]
ENV[.env file<br/>AWS Credentials]
CD -->|stdio| MCP
MCP -->|reads| ENV
end
subgraph "AWS Cloud"
CE[Cost Explorer API]
end
MCP -->|HTTPS| CE
style CD fill:#4A90E2
style MCP fill:#50C878
style CE fill:#FF9900
Component Flow
sequenceDiagram
participant Claude Desktop
participant MCP Server
participant AWS Cost Explorer
Claude Desktop->>MCP Server: Request cost data (stdio)
MCP Server->>MCP Server: Load AWS credentials from env
MCP Server->>AWS Cost Explorer: GetCostAndUsage API call
alt API Success
AWS Cost Explorer-->>MCP Server: Cost data response
MCP Server-->>Claude Desktop: Formatted cost data
else Rate Limited
AWS Cost Explorer-->>MCP Server: ThrottlingException
MCP Server-->>Claude Desktop: Error: Rate limit exceeded
else Other Error
AWS Cost Explorer-->>MCP Server: Error response
MCP Server-->>Claude Desktop: Error message
end
System Architecture
graph LR
subgraph "MCP Server Components"
A[index.ts<br/>MCP Protocol Handler]
B[cost-explorer.ts<br/>AWS Client Wrapper]
end
A -->|uses| B
B -->|AWS SDK| C[Cost Explorer API]
style A fill:#E8F4F8
style B fill:#FFF4E6
style C fill:#FF9900
Features
- Simple Cost Queries: Get cost and usage data for any time period
- Flexible Grouping: Group costs by Service, Usage Type, Region, Account, etc.
- Multiple Metrics: BlendedCost, UnblendedCost, AmortizedCost, and more
- Rate Limit Handling: Respects AWS API constraints with proper error handling
- Secure: Credentials stay local, no hardcoded secrets
Prerequisites
- Node.js 18+
- AWS Account with Cost Explorer enabled
- AWS IAM credentials with
ce:GetCostAndUsagepermission - Claude Desktop application
Installation
-
Clone the repository
git clone <repository-url> cd aws-mcp-cost-explorer -
Install dependencies
npm install -
Configure environment variables
cp .env.example .envEdit
.envand configure for your authentication method:Option A: AWS SSO (Recommended)
AWS_REGION=us-west-2 AWS_PROFILE=your-sso-profile-nameThen login via SSO:
aws sso login --profile your-sso-profile-nameOption B: IAM Credentials
AWS_ACCESS_KEY_ID=your_access_key_here AWS_SECRET_ACCESS_KEY=your_secret_key_here AWS_REGION=us-east-1 -
Build the project
npm run build
Configuration
Claude Desktop Setup
Add this configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Option A: AWS SSO (Recommended)
{
"mcpServers": {
"aws-cost-explorer": {
"command": "node",
"args": ["/absolute/path/to/aws-mcp-cost-explorer/build/index.js"],
"env": {
"AWS_REGION": "us-west-2",
"AWS_PROFILE": "your-sso-profile-name"
}
}
}
}
Option B: IAM Credentials
{
"mcpServers": {
"aws-cost-explorer": {
"command": "node",
"args": ["/absolute/path/to/aws-mcp-cost-explorer/build/index.js"],
"env": {
"AWS_ACCESS_KEY_ID": "your_access_key",
"AWS_SECRET_ACCESS_KEY": "your_secret_key",
"AWS_REGION": "us-east-1"
}
}
}
}
Option C: Use default AWS credentials
{
"mcpServers": {
"aws-cost-explorer": {
"command": "node",
"args": ["/absolute/path/to/aws-mcp-cost-explorer/build/index.js"]
}
}
}
This uses credentials from ~/.aws/credentials or environment variables automatically.
Required IAM Permissions
Your AWS IAM user/role needs these permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:GetCostAndUsage"
],
"Resource": "*"
}
]
}
Available Tools
get_cost_and_usage
Query AWS Cost Explorer for cost and usage data.
Parameters:
startDate(required): Start date in YYYY-MM-DD formatendDate(required): End date in YYYY-MM-DD formatgranularity(optional): DAILY, MONTHLY, or HOURLY (default: DAILY)metrics(optional): Array of metrics to retrieve (default: BlendedCost, UnblendedCost)- Available:
BlendedCost,UnblendedCost,AmortizedCost,NetAmortizedCost,UsageQuantity,NormalizedUsageAmount
- Available:
groupBy(optional): Array of dimensions to group by- Example:
[{"type": "DIMENSION", "key": "SERVICE"}] - Common dimensions:
SERVICE,USAGE_TYPE,REGION,LINKED_ACCOUNT,INSTANCE_TYPE
- Example:
Example Queries in Claude:
"What were my AWS costs last month?"
"Show me daily costs for the last 7 days grouped by service"
"Get my AWS costs from 2024-01-01 to 2024-01-31 by service"
AWS API Limits & Constraints
Important Rate Limits:
- Cost Explorer API has a rate limit of approximately 1-2 requests per second
- Exceeded limits result in
ThrottlingExceptionerrors - The server handles throttling gracefully with error messages
Best Practices:
- Avoid rapid successive queries
- Use appropriate granularity (MONTHLY for long periods)
- Limit groupBy dimensions to reduce response size
- Cost data typically has 24-48 hour delay
Cost Explorer Pricing:
- API calls are not free
- First query per month: free
- Additional queries: $0.01 per request
- Check AWS pricing for current rates
Development
Build the project:
npm run build
Watch mode for development:
npm run dev
Run the server:
npm start
Security Notes
- ✅ No secrets hardcoded in source code
- ✅
.envfile is gitignored - ✅
.env.exampleprovided as template - ✅ AWS credentials stay on local machine
- ⚠️ Ensure your
.envfile has proper permissions (chmod 600) - ⚠️ Never commit AWS credentials to git
Troubleshooting
Server not appearing in Claude Desktop:
- Check config file path is correct
- Verify absolute path to
build/index.js - Restart Claude Desktop after config changes
- Check Claude Desktop logs for errors
AWS Authentication Errors:
- Verify credentials in
.envfile - Check IAM permissions include
ce:GetCostAndUsage - Ensure AWS Cost Explorer is enabled in your account
Rate Limit Errors:
- Wait a few seconds between queries
- Cost Explorer has low rate limits by design
- Consider caching results for repeated queries
Future Enhancements
Remote Deployment (Planned)
Future versions may support remote deployment with SSE transport for:
- Team-wide access
- Centralized credential management
- Higher availability
This would require:
- HTTP server with SSE endpoints
- Authentication/authorization layer
- Secure credential storage (AWS Secrets Manager, etc.)
- HTTPS/TLS configuration
License
MIT
Contributing
Contributions welcome! Please ensure:
- No secrets in commits
- Follow existing code style
- Update README for new features
- Test with Claude Desktop before submitting
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。