main
功能: - search_aws_documentation: 搜索 AWS 文档 - get_aws_doc: 获取完整文档内容(Markdown) - recommend_aws_content: 获取推荐内容 - get_aws_services_list: 获取服务列表 特性: - 支持 AWS 文档网站直接访问 - 集成 Pydantic AI 进行结果整理和解释 - 提供 REST API 和 MCP 协议端点 - 支持 API Key 验证 - 支持 AWS 全球分区和中国分区
AWS Documentation Agent
基于 Pydantic AI 和 FastMCP 的 AWS 文档查询 Agent。
功能概述
AWS Documentation Agent 提供以下功能:
- 搜索 AWS 文档 - 在 AWS 官方文档中搜索服务指南、API 参考、教程等
- 获取文档内容 - 根据 URL 获取完整的文档内容(Markdown 格式)
- 获取推荐内容 - 根据文档获取相关推荐内容
- 获取服务列表 - 查看 AWS 服务列表
快速开始
1. 环境变量配置
# LiteLLM Gateway 配置
export LITELLM_GATEWAY_URL="https://litellm.graystone-fb459c5d.southeastasia.azurecontainerapps.io/v1"
export OPENAI_API_KEY="your-api-key"
# AWS 文档分区(可选,默认 aws)
export AWS_DOCUMENTATION_PARTITION="aws" # 或 "aws-cn" 用于中国区域
# 服务端口(可选,默认 8000)
export API_PORT=8000
2. 本地测试
cd aws-documentation
pip install -r requirements.txt
python run_api_server.py
3. 构建镜像
docker build -t aws-documentation:latest .
4. 运行容器
docker run -d -p 8000:8000 \
-e LITELLM_GATEWAY_URL="https://..." \
-e OPENAI_API_KEY="your-key" \
-e AWS_DOCUMENTATION_PARTITION="aws" \
aws-documentation:latest
项目结构
aws-documentation/
├── Dockerfile
├── requirements.txt
├── run_api_server.py # 启动脚本
└── src/
├── __init__.py
└── server/
├── __init__.py
├── api_server.py # FastAPI + MCP HTTP
└── mcp_server.py # MCP 工具定义
API 端点
REST API
GET /- 服务信息GET /health- 健康检查POST /api/v1/search- 搜索文档(需要 API Key)POST /api/v1/doc- 获取文档内容(需要 API Key)POST /api/v1/recommend- 获取推荐内容(需要 API Key)GET /api/v1/services- 获取服务列表(需要 API Key)
MCP 端点
POST /mcp- MCP HTTP 端点GET /mcp/sse- MCP SSE 端点POST /mcp/sse- MCP SSE POST 端点
使用示例
搜索文档
curl -X POST http://localhost:8000/api/v1/search \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"query": "S3 bucket naming",
"limit": 5
}'
获取文档内容
curl -X POST http://localhost:8000/api/v1/doc \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"doc_url": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html"
}'
获取推荐内容
curl -X POST http://localhost:8000/api/v1/recommend \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"doc_url": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html"
}'
MCP 调用
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_aws_documentation",
"arguments": {
"query": "Lambda Python",
"limit": 10
}
}
}'
环境变量
| 变量 | 必需 | 说明 |
|---|---|---|
| LITELLM_GATEWAY_URL | 是 | LiteLLM Gateway URL |
| OPENAI_API_KEY | 是 | LLM API Key |
| AWS_DOCUMENTATION_PARTITION | 否 | AWS 分区,默认 aws(可选:aws-cn 用于中国区域) |
| API_PORT | 否 | 服务端口,默认 8000 |
工具说明
search_aws_documentation
搜索 AWS 文档。
参数:
query(string, 必需): 搜索关键词limit(integer, 可选): 最大返回结果数,默认 10
示例:
{
"query": "S3 bucket",
"limit": 5
}
get_aws_doc
获取 AWS 文档内容。
参数:
doc_url(string, 必需): AWS 文档 URL
示例:
{
"doc_url": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/..."
}
recommend_aws_content
获取 AWS 文档推荐内容。
参数:
doc_url(string, 必需): AWS 文档 URL
get_aws_services_list
获取 AWS 服务列表。
参数: 无
注册到 Agent Manager
在 k8s_manager.py 中添加:
# TEMPLATE_PORTS
"aws-documentation": 8000,
# image_map
"aws-documentation": "agnettaiji.azurecr.io/ai-agents/aws-documentation:latest",
在 app.py 的 valid_templates 中添加 "aws-documentation"。
Languages
Python
98.2%
Dockerfile
1.8%