r-huijts/WebsearchTool
If you are the rightful owner of WebsearchTool and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Tavily Search Server is an enterprise-grade server designed to enhance OpenWebUI's search capabilities with intelligent, AI-optimized web search through Tavily API integration.
š MCP Tavily Search Server
Enterprise-grade MCP server designed to replace OpenWebUI's default search with intelligent, robust web search capabilities through Tavily API integration
šÆ Purpose & Overview
Primary Goal: Replace OpenWebUI's basic search functionality with a sophisticated, AI-optimized search system that provides:
- š§ Intelligent tool selection based on query intent
- š¼ļø Rich visual content with images and diagrams
- š° Specialized news search for current events
- ā” Cost-optimized searches from quick facts to deep research
- š”ļø Enterprise reliability with fallback strategies and error handling
This MCP server transforms web search from a basic utility into a powerful AI assistant capability, enabling OpenWebUI to provide research-grade search results with visual content, specialized tools, and intelligent query routing.
š Key Features
- š§ Intelligent Tool Selection - AI automatically chooses the best search tool for each query type
- š¼ļø Advanced Visual Search - Specialized image, diagram, and visual content discovery
- š° Enhanced News Search - Real-time news with comprehensive analysis and visual content
- ā” Performance Optimized - From instant QNA to deep research, credit-aware tool selection
- š”ļø Enterprise Reliability - 3-tier fallback system with smart retry logic and health monitoring
- šÆ Context-Aware Search - Temporal awareness, domain specialization, and RAG optimization
- š§ OpenWebUI Integration - Drop-in replacement for default search with superior capabilities
šļø Architecture
OpenWebUI ā Port 18000 ā MCPO (port 8001) ā MCP-Tavily (port 8000/mcp)
Container Services
mcp-tavily
- Main MCP server with Tavily integrationmcpo
- MCP OpenAPI Proxy (converts MCP protocol to REST)nginx-auth
- Optional authentication layer (currently disabled)
š Quick Start
Prerequisites
- Docker & Docker Compose
- Tavily API Key (Get one here)
- Portainer (recommended for deployment)
1. Environment Setup
# Set your Tavily API key
export TAVILY_API_KEY="tvly-YOUR_API_KEY"
2. Deploy with Docker Compose
# Clone the repository
git clone <repository-url>
cd WebsearchTool
# Deploy the stack
docker-compose up -d
3. Deploy with Portainer
- Add stack in Portainer
- Upload
docker-compose.yml
- Set environment variable:
TAVILY_API_KEY=tvly-YOUR_API_KEY
- Deploy stack
- Access via
http://your-server:18000
š ļø Enhanced Tool Arsenal
š§ AI-Guided Tool Selection
The LLM automatically selects the optimal tool based on query intent:
Tool | Purpose | LLM Triggers | Credits |
---|---|---|---|
qna_search š„ | Quick factual answers | "What is...", "Who is...", "When did..." | <1 |
smart_search šÆ | Comprehensive research | "analyze", "compare", "research", complex topics | 1-2 |
detailed_news_search š° | Current events analysis | "latest news", "recent developments", "current events" | 2 |
visual_search š¼ļø | Image-focused search | "image", "photo", "picture", visual content | 2 |
diagram_search š | Educational diagrams | "diagram", "flowchart", "chart", "illustration" | 2 |
š Core Search Tools
š§ Context & Utility Tools
Tool | Purpose | Auto-Selected For |
---|---|---|
get_current_date š
| Temporal awareness | "today", "recent", "current", "this week" |
get_search_context š§ | RAG-optimized context | "research for me to analyze", AI processing |
tavily_health_check š„ | API diagnostics | Search failures, troubleshooting |
š Content Extraction Tools
Tool | Purpose | Features |
---|---|---|
tavily_extract | URL content extraction | Batch processing (20 URLs) |
tavily_crawl | Website crawling | Depth control, filtering |
tavily_map | Site structure analysis | Architecture discovery |
š” OpenWebUI Integration Examples
š§ Intelligent Query Routing
The LLM automatically selects the best tool - no manual tool specification needed!
User: "What is machine learning?"
ā LLM selects: qna_search (quick facts)
ā Result: Direct answer, <1 credit
User: "Find diagrams explaining neural networks"
ā LLM selects: diagram_search (visual educational content)
ā Result: Diagrams with AI descriptions, 2 credits
User: "Research renewable energy innovations and trends"
ā LLM selects: smart_search (comprehensive research)
ā Result: Rich analysis with images, 1-2 credits
User: "Latest news on climate summit"
ā LLM selects: detailed_news_search (current events)
ā Result: News analysis with sources, 2 credits
š¼ļø Enhanced Visual Content
User: "Show me a diagram of how LLMs work"
ā Automatic tool: diagram_search
ā Enhanced query: "how LLMs work diagram flowchart illustration"
ā Result: Educational diagrams with AI descriptions
User: "Images of solar panel installations"
ā Automatic tool: visual_search
ā Result: Photos with descriptions and technical details
š° Intelligent News Analysis
User: "What happened this week in politics?"
ā Auto sequence: get_current_date ā detailed_news_search
ā Result: Comprehensive news with temporal context
User: "Recent developments in AI technology"
ā Automatic tool: detailed_news_search with auto-optimization
ā Result: Latest AI news with analysis and sources
šÆ Cost-Optimized Search Strategy
Simple Facts ā qna_search (cheapest)
Complex Research ā smart_search (optimized)
Current Events ā detailed_news_search (specialized)
Visual Content ā visual_search/diagram_search (rich media)
š”ļø Robustness Features
3-Tier Fallback System
- Tier 1 (Original) - Full functionality with requested parameters
- Tier 2 (Reduced) - Basic search with fewer results, maintained quality
- Tier 3 (Minimal) - Emergency fallback for basic results
Intelligent Error Handling
- Parameter Validation - Comprehensive validation with clear error messages
- Smart Retry Logic - Exponential backoff for timeouts, immediate retry for transient errors
- Error Classification - Specific handling for quota, network, timeout, and authentication errors
- Dynamic Timeouts - Automatically calculated based on search complexity
Performance Optimization
- Credit Management - Automatic fallback to lower-cost searches
- Timeout Optimization - Dynamic calculation based on search parameters
- Response Caching - Efficient resource utilization
- Health Monitoring - Real-time API status and performance metrics
š Advanced OpenWebUI Capabilities
š¤ Automatic AI Optimization
Tavily's AI automatically optimizes search parameters based on query analysis:
- Topic Detection: Automatically selects general/news/finance/health/scientific/travel
- Search Depth: AI decides between basic (1 credit) vs advanced (2 credits)
- Time Range: Smart temporal filtering for time-sensitive queries
- Content Type: Optimizes for text, visual, or mixed content needs
š¼ļø Superior Visual Content Discovery
Far beyond basic web search - intelligent visual content extraction:
- Diagram Recognition: Specialized educational diagram discovery
- Image Descriptions: AI-generated descriptions of visual content
- Visual Context: Images integrated with comprehensive text explanations
- Rich Media: Favicons, thumbnails, and visual metadata
š Performance vs. Default OpenWebUI Search
Feature | Default OpenWebUI | Enhanced MCP Server |
---|---|---|
Search Intelligence | Basic web search | AI-guided tool selection |
Visual Content | Limited | Specialized image/diagram tools |
News Analysis | Generic results | Dedicated news search with analysis |
Cost Optimization | No awareness | Credit-optimized tool routing |
Error Handling | Basic | 3-tier fallback with diagnostics |
Temporal Awareness | None | Date context and time-based routing |
Content Quality | Variable | Advanced search with AI summaries |
š§ Configuration
Environment Variables
Variable | Required | Default | Description |
---|---|---|---|
TAVILY_API_KEY | ā Yes | - | Your Tavily API key |
MCP_HOST | No | 0.0.0.0 | Server bind address |
MCP_PORT | No | 8000 | Server port |
AUTH_TOKEN | No | - | Optional authentication token |
Docker Compose Override
# docker-compose.override.yml
version: "3.8"
services:
mcp-tavily:
environment:
- TAVILY_API_KEY=your-key-here
- MCP_PORT=8000
mcpo:
ports:
- "8001:8001" # Expose MCPO directly for testing
š Troubleshooting
Common Issues
1. API Connection Errors
# Check health status
curl http://localhost:18000/tool/tavily_health_check
2. Container Communication
# Verify network connectivity
docker network inspect websearchtool_mcpnet
3. Port Conflicts
# Check port usage
netstat -tlnp | grep 18000
Error Codes & Solutions
Error | Cause | Solution |
---|---|---|
QuotaExceeded | API credit limit | Check Tavily billing, use basic search |
ValidationError | Invalid parameters | Review parameter constraints |
NetworkError | Connectivity issue | Check internet, firewall settings |
TimeoutError | Request timeout | Reduce complexity, check network |
š Performance Tuning
Credit Optimization
- Use
qna_search
for simple questions (lowest cost) - Set
search_depth="basic"
to use 1 credit instead of 2 - Disable
auto_parameters
to prevent automatic advanced search - Monitor usage with
tavily_health_check
Response Time Optimization
- Set appropriate
max_results
(5-10 for speed, 15-20 for research) - Use
timeout
parameter to prevent hanging requests - Enable fallback strategies for automatic optimization
- Monitor response times via health check
š Development & Architecture
Project Structure
WebsearchTool/
āāā server.py # Main MCP server (10 intelligent tools)
āāā docker-compose.yml # Container orchestration
āāā Dockerfile # Container definition
āāā requirements.txt # Python dependencies
āāā nginx.conf # Optional auth configuration
āāā .cursor/rules/ # Comprehensive development rules
ā āāā mcp-server-structure.mdc # Project overview
ā āāā tavily-api-patterns.mdc # Implementation patterns
ā āāā robustness-patterns.mdc # Error handling
ā āāā performance-optimization.mdc # Performance guidelines
ā āāā tool-arsenal.mdc # Complete tool reference
āāā README.md # This comprehensive guide
šÆ OpenWebUI Integration Architecture
OpenWebUI Chat Interface
ā (User Query)
OpenWebUI LLM Processing
ā (Intelligent Tool Selection)
MCP Tools via MCPO Proxy
ā (Optimized Search)
Tavily API with Enhanced Parameters
ā (Rich Results)
OpenWebUI Enhanced Response
Adding New Tools
- Follow patterns in
.cursor/rules/tavily-api-patterns.mdc
- Implement parameter validation with
validate_search_params()
- Use
robust_tavily_search_with_fallback()
for reliability - Add LLM guidance with clear "USE WHEN" and "DON'T USE FOR" sections
- Include emoji indicators and credit cost information
- Test tool selection logic with OpenWebUI integration
Testing
# Health check
curl http://localhost:18000/tool/tavily_health_check
# Basic search test
curl -X POST http://localhost:18000/tool/qna_search \
-H "Content-Type: application/json" \
-d '{"query": "test question"}'
š OpenWebUI Integration Reference
š Connection Setup
- Deploy MCP Server: Use docker-compose or Portainer
- OpenWebUI Discovery: Tools auto-discovered via MCPO proxy
- Immediate Enhancement: OpenWebUI search is instantly upgraded
š§ Tool Selection Intelligence
The LLM automatically routes queries to optimal tools:
Fact Questions ā qna_search (fast, cheap)
"What is X?" ā Direct answer, <1 credit
Research Queries ā smart_search (comprehensive)
"Research X" ā AI-optimized with visuals, 1-2 credits
News Queries ā detailed_news_search (specialized)
"Latest news on X" ā Rich news analysis, 2 credits
Visual Queries ā visual_search or diagram_search
"Diagram of X" ā Educational diagrams, 2 credits
Temporal Queries ā get_current_date ā specialized tool
"Recent X" ā Date context + appropriate search
šÆ Superior Search Results
Compared to default OpenWebUI search:
- ā 10x more intelligent tool routing
- ā Rich visual content with AI descriptions
- ā Specialized news analysis with multiple sources
- ā Cost optimization from instant facts to deep research
- ā Enterprise reliability with fallback strategies
- ā Temporal awareness for time-sensitive queries
š API Documentation
- OpenAPI Spec:
http://your-server:18000/openapi.json
- MCP Protocol: Latest standard with HTTP/SSE streaming
- Tool Discovery: Automatic via OpenWebUI integration
š¤ Contributing
Development Setup
- Clone repository
- Install dependencies:
pip install -r requirements.txt
- Set environment variables
- Run locally:
python server.py
Code Standards
- Follow patterns defined in
.cursor/rules/
- Implement robust error handling
- Add comprehensive parameter validation
- Include fallback strategies for reliability
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Acknowledgments
- Tavily - Powerful web search API
- FastMCP - MCP server framework
- OpenWebUI - AI interface integration
- MCPO - MCP to OpenAPI proxy
Built with ā¤ļø to enhance OpenWebUI's search capabilities
Ready to replace basic web search with AI-powered intelligence? Deploy now and transform your OpenWebUI experience with enterprise-grade search capabilities! š
šÆ Why This MCP Server?
Default OpenWebUI Search Limitations:
- ā Basic web search with limited intelligence
- ā No visual content discovery
- ā No cost optimization or tool selection
- ā Limited error handling and reliability
- ā No specialized search types (news, diagrams, etc.)
Enhanced MCP Search Capabilities:
- ā AI-guided tool selection for optimal results
- ā Rich visual content with diagrams and images
- ā Cost-optimized routing from facts to research
- ā Enterprise reliability with robust error handling
- ā Specialized tools for news, visuals, and context
- ā Seamless integration as drop-in OpenWebUI enhancement
Transform your OpenWebUI from basic search to AI-powered research assistant! š§ āØ