- AWS Lambda Code (API Gateway Integration): This is a custom MCP that provides three main tools:
a. get_distribution_info - Fetches CloudFront distribution details
b. fetch_logs - Retrieves CloudFront logs from CloudWatch
c. analyze_logs - Analyzes logs for issues and suggests remediationsThe Lambda function has two main endpoints:
/list_tools(GET): Returns available tools and their schemas/call_tool(POST): Executes the requested tool with given parameters
- Client Code:
graph TD
A[User Input] --> B[Fetch Tool Schemas]
B --> C[Initialize Gemini AI]
C --> D[Interactive Loop]
D --> E[Call Tools via API]
E --> F[Process AI Response]
F --> G[Show Results/Get Follow-up]
G --> D
Key Components:
- API Integration:
async def call_tool(session, tool_name, parameters):
# Makes HTTP POST requests to Lambda API- Gemini Integration:
client = genai.Client(api_key=GEMINI_API_KEY)- Conversation Flow:
- Gets CloudFront distribution ID from user
- Uses Gemini AI to determine which tools to call
- Makes API calls to Lambda function
- Processes and displays results
- Handles follow-up questions
