Travel Advisor AI
Provides personalized travel recommendations by analyzing climate, currency exchange rates, safety, and budget constraints through AI agents and multiple public APIs.
README
Travel Advisor AI 🌍✈️
An intelligent travel recommendation system built with Clean Architecture, Python 3, AI Agents, and HTTP Streamable MCP Protocol.
🎯 Project Overview
Travel Advisor AI is a sophisticated travel recommendation system that answers complex queries like:
"I want to travel with $4000, to a warm destination, safe, where the local currency is weaker than USD."
The system integrates multiple public APIs through HTTP streamable endpoints, uses intelligent agents for contextual analysis, and provides personalized travel recommendations with real-time streaming based on climate, currency exchange rates, safety, and budget constraints.
🚀 New Features - HTTP Streamable Protocol
- Real-time Streaming: Server-Sent Events (SSE) for live progress updates
- HTTP REST API: Easy integration with web applications and mobile apps
- Auto-generated Documentation: Interactive API docs at
/docs - Health Monitoring: Built-in health checks and service status
- CORS Support: Cross-origin requests enabled for web integration
- No Complex Handshake: Direct HTTP calls without MCP initialization
🏗️ Architecture & Methodologies
Clean Architecture Implementation
This project follows Clean Architecture principles with clear separation of concerns:
src/
├── domain/ # Business entities and rules (innermost layer)
│ ├── entities/ # Core business objects
│ ├── repositories/ # Abstract interfaces
│ └── value_objects/# Domain value objects
├── application/ # Use cases and application services
│ ├── services/ # Application services
│ └── use_cases/ # Business use cases
├── infrastructure/ # External concerns (outermost layer)
│ ├── adapters/ # External service implementations
│ └── container.py # Dependency injection
└── presentation/ # UI and controllers
├── controllers/ # Request handlers
└── ui/ # User interfaces
SOLID Principles Applied
- Single Responsibility: Each class has one reason to change
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Interfaces can be substituted by implementations
- Interface Segregation: Small, focused interfaces
- Dependency Inversion: Depend on abstractions, not concretions
Design Patterns
- Repository Pattern: Data access abstraction
- Dependency Injection: Loose coupling between components
- Strategy Pattern: Multiple recommendation algorithms
- Factory Pattern: Object creation abstraction
- Observer Pattern: Event-driven architecture
🚀 Features
Core Functionality
- ✅ Multi-factor Analysis: Climate, currency, safety, and distance
- ✅ Personalized Recommendations: Budget-based intelligent suggestions
- ✅ Real-time Data: Live weather, exchange rates, and country information
- ✅ Persistent Storage: SQLite database for recommendations and history
- ✅ Rich CLI Interface: Interactive console with beautiful formatting
- ✅ HTTP/REST API: Web-accessible endpoints
- ✅ MCP Protocol: Native MCP server implementation
Technical Features
- ✅ Comprehensive Testing: Unit, integration, and end-to-end tests
- ✅ Type Safety: Full type hints with mypy support
- ✅ Error Handling: Robust error handling and fallbacks
- ✅ Async/Await: Asynchronous programming throughout
- ✅ Code Quality: Black formatting, flake8 linting
- ✅ Documentation: Comprehensive docstrings and comments
🌐 API Integrations
MCP Servers
- Countries Service: RestCountries API + geolocation data
- Currency Service: ExchangeRate API for real-time rates
- Climate Service: Open-Meteo API for weather data
External APIs Used
- RestCountries: Country information and geographical data
- ExchangeRate API: Currency exchange rates (free tier)
- Open-Meteo: Weather and meteorological data (no API key required)
📦 Installation
Prerequisites
- Python 3.11 or higher
- pip package manager
Setup
# Clone the repository
git clone <repository-url>
cd travelling_mcp
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
🎮 Usage
Option 1: MCP Server (Native Protocol) 🚀
python3 mcp_travel_server.py
- Protocol: Native MCP over stdio
- Usage: For MCP-compatible clients (Claude Desktop, Cline, etc.)
- Features: Full MCP protocol support, tool calls, resources
Option 2: HTTP Streamable Server (Web API)
python3 http_server.py --host 0.0.0.0 --port 8000
- URL: http://localhost:8000
- Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
- Streaming: http://localhost:8000/stream
- Features: Real-time streaming, auto-docs, CORS support
Option 3: Interactive Console
python3 main.py
Option 4: Legacy HTTP Server
python3 http_server.py --host 0.0.0.0 --port 8000
Option 5: Demonstration Mode
python3 main.py --demo
Option 6: Run Tests
python3 main.py --test
# or
python3 run_tests.py
🌐 HTTP Streamable API Endpoints
Core Endpoints
GET /- Server information and available endpointsGET /health- Health check and service statusGET /tools- List all available tools/functionsPOST /mcp- Direct MCP tool calls (JSON-RPC style)POST /stream- Streaming responses with Server-Sent EventsGET /resources/{path}- Access MCP resources (countries, regions)
Example Usage
Direct API Call
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"method": "search_countries", "params": {"query": "Brazil", "limit": 5}}'
Streaming API Call
curl -X POST http://localhost:8000/stream \
-H "Content-Type: application/json" \
-d '{"method": "get_travel_recommendations", "params": {"user_id": "user123", "budget": 4000}}' \
--no-buffer
Health Check
curl http://localhost:8000/health
🔧 MCP Client Configuration
The server can be used with MCP-compatible clients like Claude Desktop, Cline, or other MCP clients. Here are configuration examples:
Claude Desktop Configuration
Add to your Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"travel-server": {
"command": "/usr/bin/python3",
"args": [
"/home/matheus/projetos_praticos/travelling_mcp/mcp_travel_server.py"
],
"cwd": "/home/matheus/projetos_praticos/travelling_mcp"
}
}
}
Note: The MCP server uses the native MCP protocol over stdio, not HTTP. This is the correct way to integrate with MCP clients.
Cline/VSCode MCP Configuration
Add to your Cline MCP settings:
{
"mcpServers": {
"travel-server": {
"command": "python3",
"args": [
"/path/to/your/travelling_mcp/mcp_travel_server.py"
],
"cwd": "/path/to/your/travelling_mcp",
"env": {
"PYTHONPATH": "/path/to/your/travelling_mcp"
}
}
}
}
Direct Execution Methods
The project provides two different MCP server implementations for different use cases:
1. Native MCP Server (stdio protocol)
# Run native MCP server with stdio protocol for MCP clients
python3 mcp_travel_server.py
Use case: Integration with MCP-compatible clients (Claude Desktop, etc.) Protocol: Native MCP over stdio Communication: Standard input/output streams
2. Streamable HTTP MCP Server
# Run MCP server with HTTP transport for web integration
python3 mcp_travel_server_proper.py --port 8000 --host 0.0.0.0
Use case: Web applications, REST API clients, HTTP-based integrations Protocol: MCP over Streamable HTTP Communication: HTTP POST/GET requests Endpoints:
- Root:
http://localhost:8000/- Server information - Health:
http://localhost:8000/health- Health check - MCP:
http://localhost:8000/mcp- MCP protocol endpoint
3. Legacy HTTP Server (deprecated)
# Run legacy HTTP server for web/REST API access
python3 http_server.py --host 0.0.0.0 --port 8000
Note: This is the legacy implementation. Use option 2 for new integrations.
4. Using the Main Module
# From project directory
python3 -m mcp_travel_server
🔧 Server Comparison
| Feature | Native MCP (stdio) | Streamable HTTP MCP | Legacy HTTP |
|---|---|---|---|
| File | mcp_travel_server.py |
mcp_travel_server_proper.py |
http_server.py |
| Protocol | MCP over stdio | MCP over HTTP | Custom REST API |
| Use Case | MCP clients | Web applications | Legacy integrations |
| Communication | stdin/stdout | HTTP requests | HTTP requests |
| MCP Compatible | ✅ Full | ✅ Full | ❌ No |
| Web Integration | ❌ No | ✅ Yes | ✅ Yes |
| Documentation | - | Auto-generated | Manual |
| Real-time | ✅ Yes | ✅ Yes | ❌ Limited |
📁 Project Structure
Root Level Files
travelling_mcp/
├── main.py # Main application entry point
├── mcp_travel_server.py # Native MCP Server (stdio protocol)
├── mcp_travel_server_proper.py # Streamable HTTP MCP Server
├── http_server.py # Legacy HTTP/REST API server
├── start_server.py # Server launcher utility
├── demo.py # Demonstration script
├── test_apis.py # API testing utilities
├── run_tests.py # Test runner
├── requirements.txt # Python dependencies
├── pytest.ini # Pytest configuration
├── .coveragerc # Coverage configuration
└── README.md # This file
Core Modules
MCP Servers (mcp_servers/)
countries_server.py: Country data and geographical informationcurrency_server.py: Exchange rates and purchasing power analysisclimate_server.py: Weather data and climate information
Intelligent Agent (agent/)
travel_agent.py: AI agent for contextual travel recommendations
Database Layer (database/)
travel_database.py: SQLite database operations and data persistence
Services Layer (services/)
travel_service.py: Business logic coordination
Controllers (controllers/)
travel_controller.py: Request handling and response formatting
User Interface (ui/)
console_interface.py: Rich CLI interface with interactive menus
Clean Architecture (src/)
- Domain Layer: Core business logic and entities
- Application Layer: Use cases and application services
- Infrastructure Layer: External integrations and adapters
- Presentation Layer: Controllers and user interfaces
Testing (tests/)
- Unit Tests: Individual component testing
- Integration Tests: Component interaction testing
- End-to-End Tests: Full system workflow testing
Data Storage (data/)
cache/: Temporary data storagequeries/: Query history and indexing
🧪 Testing
Test Coverage
- 42 Tests: Comprehensive test suite
- Unit Tests: Database, services, controllers, agents
- Integration Tests: End-to-end workflows, HTTP server, MCP server
- Mocking: External API calls mocked for reliability
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test categories
pytest tests/unit/ # Unit tests only
pytest tests/integration/ # Integration tests only
🔧 Configuration
Environment Variables
# Optional: Set custom API endpoints
export COUNTRIES_API_URL="https://restcountries.com/v3.1"
export EXCHANGE_API_URL="https://api.exchangerate-api.com/v4/latest"
export WEATHER_API_URL="https://api.open-meteo.com/v1"
Database Configuration
- Default: SQLite database (
travel_recommendations.db) - Location: Project root directory
- Auto-creation: Database and tables created automatically
🚀 Deployment
Development
python3 http_server.py --reload
Production
python3 http_server.py --host 0.0.0.0 --port 8000
Docker Support
Docker configuration files are available but currently unused:
Dockerfile: Container configurationdocker-compose.yml: Multi-service orchestrationdocker-entrypoint.sh: Container entry point
📊 API Endpoints
HTTP Server Endpoints
GET /: API information and statusGET /health: Health check with service statusGET /tools: Available MCP toolsPOST /mcp: MCP protocol endpointPOST /stream: Streaming MCP responsesGET /resources/{path}: MCP resources
MCP Tools
get_travel_recommendations: Get personalized travel suggestionssearch_countries: Search and filter countriesget_weather_forecast: Weather data for locationsconvert_currency: Currency conversionanalyze_purchasing_power: Purchasing power analysisget_user_travel_history: User query historyget_popular_destinations: Popular destination statisticsget_server_statistics: System statistics
🛠️ MCP Server Function Examples
The following examples demonstrate how to use the MCP server functions. These can be called through MCP-compatible clients or via the HTTP API endpoints.
Main Functions
1. Function: search_countries
Example 1: Search countries with "Brazil" and limit of 10
{
"method": "search_countries",
"params": {
"query": "Brazil",
"limit": 10
}
}
Example 2: Search countries with "South America" (region) and limit of 5
{
"method": "search_countries",
"params": {
"query": "South America",
"limit": 5
}
}
Example 3: Search countries with "Americas" (region) and limit of 3
{
"method": "search_countries",
"params": {
"query": "Americas",
"limit": 3
}
}
2. Function: get_travel_recommendations
Example: Get travel recommendations with user_id "user123", budget 3000, duration 10, preferences ["tropical climate", "beach", "culture activities"] and origin_country "Brazil"
{
"method": "get_travel_recommendations",
"params": {
"user_id": "user123",
"budget": 3000,
"duration": 10,
"preferences": {
"climate": "tropical climate",
"activities": ["beach", "culture activities"]
},
"origin_country": "Brazil"
}
}
3. Function: get_weather_forecast
Example: Get weather forecast for Rio de Janeiro (latitude -22.9068, longitude -43.1729) for 5 days
{
"method": "get_weather_forecast",
"params": {
"location": "Rio de Janeiro",
"days": 5
}
}
4. Function: convert_currency
Example: Convert currency from BRL to USD with amount 1000
{
"method": "convert_currency",
"params": {
"from_currency": "BRL",
"to_currency": "USD",
"amount": 1000
}
}
5. Function: analyze_purchasing_power
Example: Analyze purchasing power for Argentina with budget_usd 2000
{
"method": "analyze_purchasing_power",
"params": {
"origin_country": "Brazil",
"destination_country": "Argentina",
"budget_usd": 2000
}
}
Auxiliary Functions
6. Function: get_popular_destinations
Example: Get popular destinations with limit 5
{
"method": "get_popular_destinations",
"params": {
"limit": 5
}
}
7. Function: get_user_travel_history
Example: Get user travel history with user_id "user123"
{
"method": "get_user_travel_history",
"params": {
"user_id": "user123"
}
}
8. Function: get_server_statistics
Example: Get server statistics (no parameters required)
{
"method": "get_server_statistics",
"params": {}
}
Usage via HTTP API
You can call these functions via HTTP POST to the /mcp endpoint:
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"method": "search_countries", "params": {"query": "Brazil", "limit": 5}}'
For streaming responses, use the /stream endpoint:
curl -X POST http://localhost:8000/stream \
-H "Content-Type: application/json" \
-d '{"method": "get_travel_recommendations", "params": {"user_id": "user123", "budget": 3000}}' \
--no-buffer
🤝 Contributing
Code Quality Standards
- Formatting: Black code formatter
- Linting: Flake8 for code quality
- Type Checking: mypy for type safety
- Testing: Pytest with high coverage requirements
- Documentation: Comprehensive docstrings
Development Workflow
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Ensure all tests pass
- Format code with Black
- Submit a pull request
📈 Performance
Optimization Features
- Async/Await: Non-blocking I/O operations
- Connection Pooling: Efficient HTTP client usage
- Caching: Response caching for external APIs
- Database Indexing: Optimized query performance
- Memory Management: Efficient data structures
Monitoring
- Health Checks: Service availability monitoring
- Error Tracking: Comprehensive error logging
- Performance Metrics: Response time tracking
- Resource Usage: Memory and CPU monitoring
🔒 Security
Security Measures
- Input Validation: Pydantic models for data validation
- SQL Injection Prevention: Parameterized queries
- CORS Configuration: Controlled cross-origin access
- Error Sanitization: Safe error message exposure
- Dependency Security: Regular security updates
📚 Documentation
Additional Resources
DEMO_RESULTS.md: Demonstration results and examplesDADOS_TESTE_APIS.md: API testing data and examplesdeploy_guide.md: Deployment guide and best practices
Code Documentation
- Docstrings: Comprehensive function and class documentation
- Type Hints: Full type annotation coverage
- Comments: Inline code explanations
- Architecture Diagrams: Visual system overview
🎉 Acknowledgments
Technologies Used
- Python 3: Core programming language
- FastAPI: Modern web framework
- FastMCP: MCP protocol implementation
- SQLite: Embedded database
- Rich: Beautiful terminal formatting
- Pytest: Testing framework
- Pydantic: Data validation
- HTTPX: Async HTTP client
Design Principles
- Clean Architecture: Robert C. Martin's architectural pattern
- SOLID Principles: Object-oriented design principles
- Domain-Driven Design: Business logic focus
- Test-Driven Development: Quality assurance approach
Developed with ❤️ using Clean Architecture + Python 3 + AI Agents + MCP
For questions, issues, or contributions, please refer to the project documentation or create an issue in the repository.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。