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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcpcn_web_search_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 11.4 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.1.tar.gz
Algorithm Hash digest
SHA256 dc094912b18993c46ac3302103508fe0cc17457a858dd4e2e1f8ecf29faf635c
MD5 74fae9685539ef21af3b88528547b3c7
BLAKE2b-256 b656e91a1a37026684f4c95339a35f504b09c6161edf7622a47f53c403a4a03b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcpcn_web_search_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b05ef39eadba0c82be255a4f6ad2ba6221de4af5335a43526d2d24c404d2217f
MD5 8a637c440a25e52a96990cb4423f3eee
BLAKE2b-256 1ebe56896e695d1d4deaa871303593bafb936cb378f6ef02fbc582f0a38f9b95

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