Overview
This example demonstrates:- Multi-API Integration: Google Maps via MCP + Open Meteo weather API
- Complex Graph Strategy: Sophisticated state machine with multiple subgraphs
- Iterative Planning: User feedback loops for plan refinement
- Structured Output: Type-safe trip plans with validation
- MCP Integration: Model Context Protocol for external tool access
Architecture
The agent uses a multi-stage strategy:- Clarify User Plan: Collect destination, dates, preferences
- Suggest Plan: Use Google Maps and weather data to create itinerary
- Get Feedback: Present plan to user and collect feedback
- Iterate: Refine plan based on user corrections
Prerequisites
Get API Keys
You’ll need keys for:
- OpenAI (for main agent)
- Anthropic (optional, for multi-LLM)
- Google AI (Gemini, optional)
- Google Maps (for location data)
Complete Implementation
Main Entry Point
Agent Strategy
The strategy orchestrates the trip planning workflow:Agent.kt (excerpt)
Planning Strategy Graph
The core strategy uses subgraphs and conditional edges:Planning Strategy
Key Features Explained
1. MCP Integration
Model Context Protocol enables access to Google Maps tools:maps_search_places: Search for places by querymaps_get_place_details: Get detailed info about a placemaps_get_directions: Calculate routes between locations
2. Weather Integration
Custom tools fetch weather forecasts:Weather Tools
3. Iterative Refinement
The strategy includes a feedback loop:- Agent presents suggested plan to user
- User provides feedback (accept or request changes)
- If changes requested, agent refines plan with new constraints
- Loop continues until user accepts
4. History Compression
Large plans consume context quickly. The strategy compresses history after each major stage:Running the Example
Example Output
Advanced Customization
Add Custom Tools
Extend the agent with additional data sources:Modify Planning Strategy
Customize the planning logic in the strategy function to add:- Budget constraints
- Accessibility requirements
- Transportation preferences
- Group size considerations
Source Code
View on GitHub
Explore the complete trip planning example source code
Next Steps
MCP Integration
Learn more about Model Context Protocol
Custom Strategies
Build your own graph strategies