Cost Explorer MCP Server
Enables querying and analyzing AWS cost and usage data through the AWS Cost Explorer API. Supports cost comparisons, forecasting, dimension filtering, and cost change driver analysis with streamable HTTP deployment to Amazon Bedrock Agentcore Runtime.
README
Cost Explorer MCP Server - Agentcore Runtime Deployment
This directory contains the Cost Explorer MCP Server configured for deployment to Amazon Bedrock Agentcore Runtime with streamable HTTP support on port 8000.
🏗️ Architecture
- Original: STDIO-based MCP server for local development
- Converted: Streamable HTTP server for Agentcore Runtime deployment
- Protocol: MCP (Model Context Protocol)
- Transport: Streamable HTTP on port 8000
- Deployment: Agentcore Runtime (no Agentcore memory)
📁 Project Structure
cost-explorer-agentcore-deployment/
├── mcp_server.py # Main MCP server with streamable HTTP
├── requirements.txt # Python dependencies
├── __init__.py # Python package marker
├── awslabs/ # Cost Explorer implementation
│ └── cost_explorer_mcp_server/
├── deploy.py # Deployment automation script
├── test_mcp_client.py # Local testing client
├── test_remote_client.py # Remote testing client
└── README.md # This file
🚀 Quick Start
1. Prerequisites
# Install required tools
pip install bedrock-agentcore-starter-toolkit
pip install mcp[cli]
# Configure AWS credentials
aws configure
2. Test Locally First
# Install dependencies
pip install -r requirements.txt
# Start the MCP server locally
python mcp_server.py
In another terminal:
# Test the local server
python test_mcp_client.py
3. Deploy to Agentcore Runtime
# Run the deployment script
python deploy.py
The script will:
- Check prerequisites
- Configure the deployment
- Deploy to Agentcore Runtime
- Save the Agent ARN to
agent_arn.txt
4. Test Remote Deployment
# Set environment variables
export AGENT_ARN="your-agent-arn-from-deployment"
export BEARER_TOKEN="your-oauth-token"
# Test the deployed server
python test_remote_client.py
🔧 Manual Deployment Steps
If you prefer manual deployment:
1. Configure Deployment
agentcore configure -e mcp_server.py --protocol MCP
Follow the prompts:
- Protocol: MCP
- Entry point: mcp_server.py
- Authentication: Choose OAuth or Cognito based on your needs
2. Deploy
agentcore launch
🔐 Authentication Setup
Option 1: Cognito User Pool (Recommended)
- Create a Cognito User Pool in AWS Console
- Configure the user pool for your application
- Use the provided credentials during deployment configuration
Option 2: OAuth with Auth0
- Set up Auth0 application with Dynamic Client Registration
- Configure OAuth settings during deployment
- Use Auth0 tokens for authentication
🧪 Testing
Local Testing
# Start server
python mcp_server.py
# Test in another terminal
python test_mcp_client.py
Remote Testing
# Set environment variables
export AGENT_ARN="arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/cost-explorer-xyz123"
export BEARER_TOKEN="your-oauth-token"
# Test deployed server
python test_remote_client.py
🛠️ Available Tools
The Cost Explorer MCP Server provides these tools:
- get_today_date - Get current date for relative queries
- get_dimension_values - Get available values for dimensions (SERVICE, REGION, etc.)
- get_tag_values - Get available tag values
- get_cost_and_usage - Retrieve cost and usage data with filtering
- get_cost_and_usage_comparisons - Compare costs between periods
- get_cost_comparison_drivers - Analyze cost change drivers
- get_cost_forecast - Generate cost forecasts
💰 Cost Considerations
Important: Each AWS Cost Explorer API call costs $0.01. The server includes optimizations to minimize API calls, but be aware of potential charges when using the tools extensively.
🔍 Troubleshooting
Local Server Issues
# Check if port 8000 is available
lsof -i :8000
# Check server logs
python mcp_server.py
Deployment Issues
# Check AWS credentials
aws sts get-caller-identity
# Verify agentcore CLI
agentcore --version
# Check deployment status
agentcore status
Remote Connection Issues
- Verify BEARER_TOKEN is valid and not expired
- Check AGENT_ARN format and encoding
- Ensure OAuth/Cognito is properly configured
- Verify server deployment status
📚 References
- Agentcore Runtime MCP Documentation
- Converting STDIO to Streamable HTTP
- MCP Protocol Documentation
- AWS Cost Explorer API
🆘 Support
For issues with:
- MCP Server: Check the original cost-explorer-mcp-server documentation
- Agentcore Runtime: Refer to AWS Bedrock Agentcore documentation
- Authentication: Check your OAuth/Cognito configuration
- AWS Costs: Review AWS Cost Explorer API pricing and usage
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。