Provides search functionality for products on Amazon
Allows searching for apps in the Apple App Store
Enables search capabilities through the Baidu search engine
Enables search capabilities through the DuckDuckGo search engine
Supports searching for products and listings on eBay
Enables web search with knowledge graph integration, related questions, search suggestions, multi-language support, region-specific results, time range filtering, and safe search options
Provides place and service search functionality, detailed place information retrieval, user reviews access, and location coordinate lookups
Supports searching news content through the Google News service
Allows searching for apps and content in the Google Play Store
Enables search capabilities through the Naver search engine
Provides video search functionality with support for filtering by duration, source, and upload time
SearchAPI MCP Server
A production-ready Model Context Protocol (MCP) server providing comprehensive search capabilities through SearchAPI.io. Enable AI assistants to search Google, Maps, Flights, Hotels, and more with built-in caching, retry logic, and circuit breakers.
一个基于 Model Context Protocol (MCP) 的生产级搜索服务器,通过 SearchAPI.io 提供全面的搜索功能。使 AI 助手能够搜索 Google、地图、航班、酒店等,内置缓存、重试逻辑和熔断器。
Features • Quick Start • Installation • Configuration • Available Tools
Features
🔍 Search Engines
Google Search - Web results, knowledge graph, answer boxes, related questions
Google Videos - Video search with filtering by duration, source, and upload time
Google AI Mode - AI-generated overviews with cited sources and structured content
Google Maps - Places, businesses, reviews, and location details
Google Maps Place - Detailed information for specific locations (hours, photos, amenities)
Google Events - Find concerts, conferences, festivals, and local activities
Google Flights - Flight search with comprehensive filtering and price calendars
Google Flights Location Search - Airport code lookup and autocomplete
Google Travel Explore - Discover destinations and travel inspiration
Google Hotels - Accommodation search with amenities, ratings, and price filters
🏗️ Production-Ready Architecture
Connection Pooling - Efficient HTTP connection management with httpx
Response Caching - Configurable TTL-based caching with LRU eviction
Retry Logic - Exponential backoff for transient failures
Circuit Breaker - Fail-safe pattern preventing cascading failures
Metrics Collection - Request counts, latencies, cache hit rates, error tracking
Health Checks - Monitor API connectivity and service status
⚙️ Configuration & Monitoring
Pydantic Validation - Type-safe configuration with environment variable support
Structured Logging - Configurable log levels with detailed request tracing
Resource Management - Automatic cleanup and graceful shutdown
Environment Variables - Flexible configuration for different deployments
Related MCP server: Google Search MCP Server
Quick Start
Prerequisites
Python 3.10 or higher
SearchAPI.io API key (Get one here)
Installation with UV (Recommended)
The fastest way to get started is using uvx:
Installation
Method 1: UV (Recommended)
UV is the fastest and most convenient method:
Method 2: pip
Method 3: From Source
Configuration
Environment Variables
Create a .env file in the project root:
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop configuration file:
Location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Using UV (Recommended):
Using Python directly:
Using virtual environment:
VS Code (Continue, Cline)
Add to .vscode/mcp.json in your workspace or use the "MCP: Open User Configuration" command:
With UV:
Zed Editor
Add to ~/.config/zed/settings.json:
Cline (VS Code Extension)
In Cline settings, add to MCP Servers:
Generic MCP Client
For any MCP-compatible client:
Available Tools
Health & Monitoring
health_check
Check the health and performance of the SearchAPI service.
Returns:
API connectivity status
Response latency
Circuit breaker state
Cache statistics
Request metrics
Example:
Time & Date Utilities
get_current_time
Get current time and travel date suggestions. Essential for flight and hotel bookings.
Parameters:
format- Date format: "iso", "slash", "chinese", "timestamp", "full"days_offset- Days from today (can be negative)return_future_dates- Return array of future datesfuture_days- Number of future dates (if return_future_dates=true)
Example:
Google Search
search_google
Search Google for web results, knowledge graphs, and answer boxes.
Parameters:
q(required) - Search querylocation- Location name (e.g., "New York, NY")gl- Country code (default: "us")hl- Language code (default: "en")time_period- Time filter: "last_hour", "last_day", "last_week", "last_month", "last_year"num- Results per page (default: "10")safe- Safe search: "off", "active"
Example:
search_google_videos
Search Google Videos for video content.
Parameters: Similar to search_google with video-specific filters
q(required) - Search querytime_period- Filter by upload timedevice- "desktop" or "mobile"
Example:
search_google_ai_mode
Search with AI-generated overviews and cited sources.
Parameters:
q- Search query (required unless url provided)url- Image URL to searchlocation- Location for localized results
Returns:
AI-generated overview with citations
Structured content blocks (paragraphs, lists, tables, code)
Reference links
Web results
Example:
Google Maps
search_google_maps
Search for places, businesses, and services.
Parameters:
query(required) - Search querylocation_ll- Lat/lng coordinates (format: "@lat,lng,zoom")
Example:
search_google_maps_place
Get detailed information for a specific place.
Parameters:
place_id(required if no data_id) - Google Maps place IDdata_id- Alternative place identifiergoogle_domain- Google domain (default: "google.com")hl- Language code (default: "en")
Example:
search_google_maps_reviews
Get reviews for a specific place.
Parameters:
place_id(required if no data_id) - Google Maps place IDdata_id- Alternative place identifiersort_by- "most_relevant", "newest", "highest_rating", "lowest_rating"rating- Filter by rating: "1"-"5"
Example:
Google Events
search_google_events
Search for events, concerts, conferences, and activities.
Parameters:
q(required) - Search query (e.g., "concerts in NYC", "tech conferences")location- Location name for localized resultschips- Date filter ("today", "tomorrow", "week", "weekend", "month") or event typegl- Country code (default: "us")hl- Language code (default: "en")page- Page number (default: "1")
Example:
Google Flights
search_google_flights
Search for flights with comprehensive filtering.
Parameters:
departure_id(required) - Airport code (e.g., "JFK")arrival_id(required) - Airport code (e.g., "LAX")outbound_date(required) - Departure date (YYYY-MM-DD)flight_type- "one_way", "round_trip", "multi_city"return_date- Return date (required for round_trip)travel_class- "economy", "premium_economy", "business", "first"stops- "0" (nonstop), "1", "2"adults- Number of adultscurrency- Currency code (e.g., "USD")
Example:
search_google_flights_calendar
Get price calendar for flexible date planning.
Parameters:
flight_type(required) - "one_way" or "round_trip"departure_id(required) - Airport codearrival_id(required) - Airport codeoutbound_date(required) - Reference datereturn_date- Required for round_trip
Example:
search_google_flights_location_search
Search for airport codes and locations.
Parameters:
q(required) - Search query (airport name, city, or code)gl- Country code (default: "us")hl- Language code (default: "en")
Example:
search_google_travel_explore
Explore travel destinations and find inspiration.
Parameters:
departure_id(required) - Departure airport code or locationarrival_id- Destination (defaults to anywhere)time_period- Travel period (e.g., "two_week_trip_in_december")interests- Filter by interests: "popular", "outdoors", "beaches", "museums", "history", "skiing"travel_class- "economy", "premium_economy", "business", "first_class"adults- Number of adults (default: "1")currency- Currency code (default: "USD")
Example:
Google Hotels
search_google_hotels
Search for hotels and accommodation.
Parameters:
q(required) - Location querycheck_in_date(required) - Check-in date (YYYY-MM-DD)check_out_date(required) - Check-out date (YYYY-MM-DD)adults- Number of adults (default: "2")rating- Minimum rating: "3", "4", "5"hotel_class- Star rating: "2"-"5"price_min/price_max- Price rangeamenities- Filter by amenities (e.g., "pool,wifi,parking")free_cancellation- "true" or "false"
Example:
search_google_hotels_property
Get detailed information for a specific hotel.
Parameters:
property_token(required) - Property ID from search resultscheck_in_date(required) - Check-in datecheck_out_date(required) - Check-out dateadults- Number of adults
Example:
Usage Examples
Example 1: Discover and Plan a Trip
Example 2: Research with AI Mode
Example 3: Monitor Service Health
Development
Running Tests
Code Structure
Key Components
mcp_server_refactored.py - MCP server implementation using FastMCP
Tool definitions with comprehensive docstrings
Health checks and monitoring endpoints
Clean shutdown and resource management
config.py - Configuration management
Pydantic models for type-safe configuration
Environment variable validation
Sensible defaults with override options
client.py - Production-ready HTTP client
Connection pooling with httpx
Exponential backoff retry logic
TTL-based response caching
Circuit breaker pattern
Metrics collection
Debugging
Use the MCP Inspector to test tools:
Set environment variable for verbose logging:
Troubleshooting
Common Issues
Issue: "Invalid API key" error
Solution: Ensure
SEARCHAPI_API_KEYis set correctly in environment or .env fileGet an API key at https://www.searchapi.io/
Issue: "Circuit breaker is OPEN" error
Cause: Too many consecutive API failures
Solution: Check your internet connection and API key. Wait 60 seconds for circuit to reset, or restart the server
Issue: Connection timeouts
Solution: Increase timeout in .env:
TIMEOUT=60.0Check network connectivity to SearchAPI.io
Issue: High latency
Solution: Enable caching if disabled:
ENABLE_CACHE=trueIncrease cache size:
CACHE_MAX_SIZE=5000Check
health_checktool for metrics
Issue: Windows encoding errors
Solution: Set environment variable in your MCP client config:
"env": { "PYTHONIOENCODING": "utf-8", "SEARCHAPI_API_KEY": "your_key" }
Getting Help
Check the MCP Documentation
Review SearchAPI.io Documentation
Open an issue on GitHub
Performance Tuning
Cache Configuration
For higher cache hit rates:
For memory-constrained environments:
Connection Pool
For high-traffic scenarios:
For low-traffic scenarios:
Security Considerations
⚠️ Important Security Notes:
API Key Protection
Never commit
.envfile to version controlUse environment variables in production
Rotate API keys regularly
Rate Limiting
SearchAPI.io has rate limits based on your plan
Built-in retry logic respects rate limits
Monitor usage with
health_checktool
Data Privacy
Search queries are sent to SearchAPI.io
Responses are cached locally (configurable)
Review SearchAPI.io privacy policy
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Model Context Protocol - Protocol specification by Anthropic
FastMCP - Python MCP framework
SearchAPI.io - Search API service provider
httpx - Modern HTTP client for Python
Pydantic - Data validation framework
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Fork the repository
Create your feature branch (
git checkout -b feature/AmazingFeature)Commit your changes (
git commit -m 'Add some AmazingFeature')Push to the branch (
git push origin feature/AmazingFeature)Open a Pull Request
Changelog
v1.1.0 (Current)
✅ New: Google Maps Place API - Detailed place information
✅ New: Google Events API - Event and activity search
✅ New: Google Travel Explore API - Destination discovery
✅ New: Google Flights Location Search API - Airport lookup
✅ Enhanced tourism and travel research capabilities
✅ Comprehensive travel planning workflow support
v1.0.0
✅ Production-ready architecture with FastMCP
✅ Connection pooling and retry logic
✅ Response caching with TTL
✅ Circuit breaker pattern
✅ Comprehensive health checks and metrics
✅ Google Search, Videos, AI Mode
✅ Google Maps and Reviews
✅ Google Flights and Calendar
✅ Google Hotels and Property details
✅ Time utilities for travel planning
Made with ❤️ for the MCP community