Enables web search capabilities through DuckDuckGo search engine as part of a multi-engine search approach with parallel execution and result deduplication
Provides web search functionality through Startpage search engine as part of a comprehensive multi-engine search system with source attribution
WebSearch MCP Server
High-performance Model Context Protocol (MCP) server for web search and content extraction with intelligent fallback system.
β¨ Features
π Fast: Async implementation with parallel execution
π Multi-Engine: Google, Bing, DuckDuckGo, Startpage, Brave Search
π‘οΈ Intelligent Fallbacks: GoogleβStartpage, BingβDuckDuckGo, Brave (standalone)
π Content Extraction: Clean text extraction from web pages
πΎ Smart Caching: LRU cache with compression and deduplication
π API Integration: Google Custom Search, Brave Search APIs with quota management
β‘ Resilient: Automatic failover and comprehensive error handling
π¦ Installation
Production Use (Recommended)
Development
βοΈ Configuration
Q CLI
Claude Desktop
Add to your MCP settings file:
ποΈ File Structure (Installation Independent)
The server automatically creates and manages files in a unified user directory:
Environment Variable Overrides
WEBSEARCH_HOME
: Base directory (default:~/.websearch
)WEBSEARCH_CONFIG_DIR
: Config directory overrideWEBSEARCH_LOG_DIR
: Log directory override
π§ Usage
The server provides two main tools with multiple search modes:
Search Web
Search Engines:
Google Custom Search API (with Startpage fallback)
Bing (with DuckDuckGo fallback)
Brave Search API (standalone)
DuckDuckGo (scraping)
Startpage (scraping)
Fetch Page Content
ποΈ Architecture
π§ Advanced Configuration
Environment Variables
How to Get API Keys
Google Custom Search API
API Key: Go to https://developers.google.com/custom-search/v1/introduction and click "Get a Key"
CSE ID: Go to https://cse.google.com/cse/ and follow prompts to create a search engine
Brave Search API
Go to Brave Search API
Sign up for a free account
Go to your dashboard
Copy the API key as
BRAVE_API_KEY
Free tier: 2000 requests/month
Quota Management
Unified System: Single quota manager for all APIs
Google: Daily quota (default 100 requests/day)
Brave: Monthly quota (default 2000 requests/month)
Storage: Quota files stored in
~/.websearch/
directoryAuto-reset: Quotas automatically reset at period boundaries
Fallback: Automatic fallback to scraping when quotas exhausted
Search Modes
Standard Mode: Uses all 5 engines for maximum coverage
Fallback Mode: Uses 3 engines with intelligent fallbacks for efficiency
API-First Mode: Prioritizes API calls over scraping when keys available
π Troubleshooting
Issue | Solution |
No results | Check internet connection and logs |
API quota exhausted | System automatically falls back to scraping |
Google API errors | Verify
and
|
Brave API errors | Check
and quota status |
Permission denied |
|
Import errors | Ensure Python 3.12+ and dependencies installed |
Circular import warnings | Fixed in v2.0+ (10.00/10 pylint score) |
Debug Mode
API Status Check
π Performance & Monitoring
Metrics
Pylint Score: 10.00/10 (perfect code quality)
Search Speed: ~2-3 seconds for 5-engine search
Fallback Speed: ~1-2 seconds for 3-engine search
Cache Hit Rate: ~85% for repeated queries
API Quota Efficiency: Automatic fallback prevents service interruption
Monitoring
Logs are written to web-search.log
with structured format:
π Security
No hardcoded secrets: All API keys via environment variables
Clean git history: Secrets scrubbed from all commits
Input validation: Comprehensive sanitization of search queries
Rate limiting: Built-in quota management for API calls
Secure defaults: HTTPS-only requests, timeout protection
π Performance Tips
Use fallback mode for faster searches when you don't need maximum coverage
Set API keys to reduce reliance on scraping (faster + more reliable)
Enable caching for repeated queries (enabled by default)
Tune batch sizes for content extraction based on your needs
π€ Contributing
Fork the repository
Create feature branch (
git checkout -b feature/amazing-feature
)Run tests (
pytest
)Commit changes (
git commit -m 'Add amazing feature'
)Push to branch (
git push origin feature/amazing-feature
)Open Pull Request
π License
MIT License - see LICENSE file for details.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables web search across multiple search engines (DuckDuckGo, Bing, Startpage) with parallel execution and result deduplication. Also provides web page content extraction capabilities.