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.0.tar.gz (9.6 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.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcpcn_web_search_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 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.0.tar.gz
Algorithm Hash digest
SHA256 759c4d3d78e64b3b8d8ba74bd09f8e08cb6f8cebd756631ca244bae59d26f8fc
MD5 551666dd93fb5b819639d06cc8ccf405
BLAKE2b-256 261b0f5e530a7e5c9521c273527c8e37fa6ae94cafae573de458f28161cc89ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcpcn_web_search_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 280b94e37fbe1f8a433a8f8658a63aab2b753ee1217c89d3c78b886ae1611b04
MD5 f86eaa7af0f9d6be2a13438870309ed2
BLAKE2b-256 ac641dbed9754c1c6ef64404379fbe447c62d6e5b1671dd1fcf235f720ead3cc

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