本项目借助 Anthropic 的 MCP 框架,能够快速搭建基于 AWS 成本数据的 SSE(Server-Sent Events)代理,实时获取并推送 AWS 账户的成本数据,为用户提供便捷的成本监控方案。
克隆仓库:
git clone https://github.com/yourusername/aws-cost-sse-proxy.git
cd aws-cost-sse-proxy
安装依赖项:
pip install -r requirements.txt
配置 AWS 凭证:
config.json 文件,添加以下内容:{
"aws_access_key_id": "YOUR_ACCESS_KEY",
"aws_secret_access_key": "YOUR_SECRET_KEY"
}
启动服务:
python app.py
使用测试客户端:
python client.py --host localhost --port 8000
若要将此代理部署到 AWS EC2 实例,可按以下步骤操作:
ssh -i your-key.pem ubuntu@your-ec2-instance-public-ip
为通过 HTTPS 提供代理服务,可使用 Nginx 作为反向代理,具体步骤如下:
安装 Nginx:
sudo apt-get install nginx
配置 Nginx 以反向代理到您的代理服务:
创建 /etc/nginx/conf.d/ec2.conf 文件,添加以下内容:
server {
listen 80;
server_name your-ec2-instance-public-ip;
# 将 HTTP 请求重定向到 HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your-ec2-instance-public-ip;
# SSL 证书路径
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/privatekey/privkey.pem;
# SSL 配置
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
重新加载 Nginx 配置:
sudo systemctl reload nginx
启动您的代理服务,并通过 HTTPS 访问:
https://your-ec2-instance-public-ip/sse
MIT License