Skip to main content

Multi-source web search MCP server with automatic failover

Project description

Web Search MCP Server

A multi-source web search MCP server with automatic failover support.

Features

  • Multiple Search Providers: SerpAPI, DuckDuckGo Lite, Google News RSS, Wikipedia, Exa MCP
  • Automatic Failover: If one provider fails, automatically tries the next
  • Language Detection: Automatically adjusts search parameters for CJK (Chinese/Japanese/Korean) queries
  • Flexible Output: Text (human-readable) or JSON (structured) formats
  • Webpage Fetching: Extract readable content from URLs

Installation

# From source
pip install -e .

# Or with uv
uv pip install -e .

Configuration

Environment Variables

Variable Description Required
WEB_SEARCH_SOURCES Comma-separated provider priority (e.g., serpapi,ddg_lite,wikipedia) No
WEB_SEARCH_PROVIDER Single provider override No
SERPAPI_API_KEY API key for SerpAPI For SerpAPI
EXA_API_KEY API key for Exa For Exa
EXA_MCP_URL Exa MCP endpoint (default: https://mcp.exa.ai/mcp) No

Available Sources

Source Description API Key Required
serpapi Multi-engine search (Google, Bing, Baidu, etc.) Yes (SERPAPI_API_KEY)
serpapi_google SerpAPI with Google engine Yes
serpapi_bing SerpAPI with Bing engine Yes
serpapi_baidu SerpAPI with Baidu engine Yes
ddg_lite DuckDuckGo Lite (free) No
google_news_rss Google News RSS feed No
wikipedia Wikipedia OpenSearch No
exa_mcp Exa AI-powered search Yes (EXA_API_KEY)

Default Priority

  • If SERPAPI_API_KEY is set: serpapi → ddg_lite → google_news_rss
  • If EXA_API_KEY is set: exa_mcp → ddg_lite → google_news_rss → wikipedia
  • Otherwise: ddg_lite → google_news_rss → wikipedia

Usage

Running the Server

# Direct execution
web-search-mcp

# Or via Python
python -m web_search_mcp.server

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "web-search": {
      "command": "web-search-mcp",
      "env": {
        "SERPAPI_API_KEY": "your-serpapi-key",
        "WEB_SEARCH_SOURCES": "serpapi,ddg_lite,wikipedia"
      }
    }
  }
}

Or with uv:

{
  "mcpServers": {
    "web-search": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/web-search-mcp",
        "run",
        "web-search-mcp"
      ],
      "env": {
        "WEB_SEARCH_SOURCES": "ddg_lite,google_news_rss,wikipedia"
      }
    }
  }
}

Tools

web_search

Search the internet using multiple providers with automatic failover.

Parameters:

Name Type Default Description
query string required The search query
max_results int 10 Maximum results (1-20)
format string "text" Output format: "text" or "json"
sources string "" Comma-separated source list
engine string "" SerpAPI engine (google, bing, baidu, etc.)

Example:

# Text format (default)
web_search(query="Python tutorials", max_results=5)

# JSON format
web_search(query="latest AI news", format="json")

# Specific sources
web_search(query="machine learning", sources="wikipedia,ddg_lite")

# Baidu search via SerpAPI
web_search(query="人工智能", sources="serpapi", engine="baidu")

fetch_webpage

Fetch and extract readable content from a URL.

Parameters:

Name Type Default Description
url string required The URL to fetch
max_length int 8000 Maximum content length

Example:

fetch_webpage(url="https://example.com/article")

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    MCP Server (FastMCP)                      │
├─────────────────────────────────────────────────────────────┤
│  web_search()                    fetch_webpage()             │
│      │                                 │                     │
│      ▼                                 ▼                     │
│  MultiSourceSearcher              requests + BeautifulSoup   │
│      │                                                       │
│      ├──► SerpAPIProvider (paid, multi-engine)              │
│      ├──► ExaMCPProvider (paid, AI-powered)                 │
│      ├──► DuckDuckGoLiteProvider (free)                     │
│      ├──► GoogleNewsRSSProvider (free, news-focused)        │
│      └──► WikipediaProvider (free, encyclopedia)            │
└─────────────────────────────────────────────────────────────┘

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check .

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpcn_web_search_mcp-0.1.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpcn_web_search_mcp-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mcpcn_web_search_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: mcpcn_web_search_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mcpcn_web_search_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e08e5411013ce075be0f78bb021ab27f534a7362ca86f4b6683859f447a7706c
MD5 8d5c0c591edf759c37e8c602fcfe5aa4
BLAKE2b-256 68f5641e1230226b5201bf09a2e57100a5e9cf39bdff13093867804ee450bb62

See more details on using hashes here.

File details

Details for the file mcpcn_web_search_mcp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mcpcn_web_search_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed7baab5eda0820226d9ccca8c9a96451016003c788cb9b3c2bdc9da98130320
MD5 745a6e0d50e50cc37b0f0acad48de776
BLAKE2b-256 5ae9df7624e760f1f8d459b34ee4de4fe93f2e2a12a2fec87a0d229a3ad69da8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page