Web Search MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Web Search MCP Serverfind recent articles about quantum computing"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Web Search MCP Server
A production-ready Model Context Protocol (MCP) Server that acts as a universal web search and content retrieval tool for AI agents.
Features
š Universal search ā any topic, any language query
š Multi-provider ā Tavily, Brave, Bing, SerpAPI, Google CSE (pluggable)
š Content extraction ā HTTP + BeautifulSoup (primary), Playwright (fallback for SPAs)
ā” Async-first ā parallel page fetching, connection pooling
šļø Caching ā in-memory TTL cache to save API quota
š Retry logic ā exponential back-off via tenacity
š Structured JSON ā Pydantic v2 models, MCP-compliant output
šŖµ Structured logging ā JSON or text format
Related MCP server: Web Search MCP Server
Project Structure
web_search_mcp/
ā
āāā server.py ā FastMCP server + tool registration
āāā tools.py ā Tool orchestration (search ā extract ā rank)
āāā search.py ā Pluggable search providers
āāā extractor.py ā HTML content extraction (BS4 + Playwright)
āāā browser.py ā Playwright browser manager
āāā models.py ā Pydantic data models
āāā config.py ā Settings (pydantic-settings + .env)
āāā logger.py ā Structured logging
āāā utils.py ā Shared helpers
āāā requirements.txt
āāā .env ā Configuration (fill in your API keys)
āāā README.mdQuick Start
1. Prerequisites
Python 3.11 or higher
pip
2. Install Dependencies
pip install -r requirements.txt3. Install Playwright Browser
playwright install chromiumThis downloads the Chromium binary (~130 MB). Required for JavaScript-heavy page extraction.
4. Configure API Keys
Edit .env and add at least one search provider key:
SEARCH_PROVIDER=tavily
TAVILY_API_KEY=your_key_hereGetting a free Tavily key (recommended):
Visit app.tavily.com
Sign up for a free account
Copy your API key ā paste into
.env
5. Run the Server
python server.pyThe server starts in STDIO mode (default), ready to connect with any MCP client.
MCP Tools
web_search
Search the web and return ranked snippets (no page visits).
Input:
{
"query": "Latest AI trends in healthcare",
"max_results": 10
}Output:
{
"query": "Latest AI trends in healthcare",
"total_results": 10,
"search_provider": "tavily",
"results": [
{
"title": "AI in Healthcare 2025",
"url": "https://example.com/ai-health",
"domain": "example.com",
"snippet": "Short summary of the article...",
"content": "Same as snippet for web_search",
"published_date": "2025-06-15",
"relevance_score": 0.92
}
],
"cached": false,
"execution_time_ms": 312.5
}webpage_content
Extract full readable content from a specific URL.
Input:
{
"url": "https://example.com/article",
"use_browser": false
}Set use_browser: true to force Playwright rendering for JavaScript-heavy pages.
search_and_extract
End-to-end: search ā visit pages ā extract content ā rank results.
Input:
{
"query": "Latest UK visa requirements 2025",
"max_results": 5,
"use_browser_fallback": true
}Returns full page content for each result including title, author, publish date, and extracted text.
Search Providers
Provider | Env Key | Free Tier | Notes |
Tavily ā |
| 1,000/month | Best snippets, recommended |
Brave |
| 2,000/month | Privacy-focused |
Bing |
| 1,000/month | Azure Cognitive Services |
SerpAPI |
| 100/month | Proxies Google |
Google CSE |
| 100/day | Custom Search Engine |
Switch provider by changing SEARCH_PROVIDER in .env.
Configuration Reference
Setting | Default | Description |
|
| Active search backend |
|
| Default result count |
|
| HTTP timeout (seconds) |
|
| Parallel page extractions |
|
| Cache time-to-live (seconds, 0 = disabled) |
|
| Max cache entries |
|
| Headless browser mode |
|
| Browser nav timeout (ms) |
|
| Max HTTP retry attempts |
|
| Logging verbosity |
|
|
|
Connecting with MCP Clients
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"web-search": {
"command": "python",
"args": ["C:/path/to/websearchMcp/server.py"],
"env": {
"TAVILY_API_KEY": "your_key_here"
}
}
}
}Custom MCP Client (Python)
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="python",
args=["server.py"],
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool(
"search_and_extract",
{"query": "Latest AI trends", "max_results": 3}
)
print(result)Architecture
User Query
ā
ā¼
FastMCP Server (server.py)
ā validates input (Pydantic)
ā¼
Tool Orchestrator (tools.py)
ā checks cache ā calls provider
ā¼
Search Provider (search.py)
ā Tavily / Brave / Bing / SerpAPI / Google
ā¼
Raw Search Results
ā
ā¼
Content Extractor (extractor.py)
ā HTTP + BS4 ā Playwright fallback
ā¼
Cleaned & Ranked Results
ā
ā¼
Structured JSON ResponseError Handling
All tools return structured error JSON on failure:
{
"error": "No API key configured for provider 'tavily'",
"error_type": "RuntimeError",
"tool": "web_search",
"query": "AI trends",
"timestamp": "2025-06-30T18:00:00Z"
}Performance Tips
Use
web_searchwhen you only need snippets (faster, uses less quota).Use
search_and_extractfor deep research requiring full article content.Increase
CONCURRENCY_LIMITfor faster parallel extraction (be mindful of rate limits).Increase
CACHE_TTLto reduce repeated API calls for the same queries.Set
PLAYWRIGHT_HEADLESS=true(default) in production.
Deploying to Render
Push the repo to GitHub (
.envis git-ignored ā API keys are safe)Go to render.com ā New ā Blueprint ā connect repo
Render detects
render.yamlautomaticallySet
TAVILY_API_KEYin Render dashboard ā Environment VariablesYour SSE endpoint:
https://your-app.onrender.com/sse
Deploying to Azure Container Apps
Prerequisites:
Azure CLI:
winget install Microsoft.AzureCLIAzure account with active subscription
One-command deploy:
# 1. Login to Azure
az login
# 2. Run the deployment script (reads TAVILY_API_KEY from .env automatically)
.\deploy-azure.ps1The script will:
Create a Resource Group + Azure Container Registry
Build and push the Docker image via ACR Tasks (builds in Azure cloud ā no local build needed)
Create a Container Apps Environment
Deploy the MCP server with your Tavily key stored as a secret (never in plain text)
Print your live SSE endpoint URL
Custom options:
.\deploy-azure.ps1 `
-ResourceGroup "my-rg" `
-Location "westeurope" `
-AppName "my-mcp-server" `
-Cpu "2.0" `
-Memory "4.0Gi"Add to your no-code platform after deploy:
Field | Value |
Transport |
|
URL |
|
Health check: https://<your-app>.<region>.azurecontainerapps.io/health
Update after code changes:
# Just re-run the deploy script ā it rebuilds and redeploys
.\deploy-azure.ps1License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Web search for AI agents ā one tool across 6 engines, routed to the cheapest + cached.
The best web search for your AI Agent
Web search, browser automation, scraping, crawling and CAPTCHA solving for AI agents.
Agent-native search engine with live web research optimized for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to perform query-driven web searches and fetch page content via Bing and DuckDuckGo engines, with automatic fallback and no API keys needed.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to perform web searches, extract webpage content, and conduct end-to-end search-and-extract operations using multiple search providers and content extraction methods.-
- FlicenseNot gradedqualityCmaintenanceA universal web search and content retrieval tool for AI agents, supporting multiple search providers and content extraction.-
- AlicenseNot gradedqualityCmaintenanceProvides multi-provider web search capabilities with fallback chains, semantic reranking, and content extraction for grounded agent retrieval.MIT