Skip to main content

A Python MCP Server for web search and extraction with Jina and Tavily providers

Project description

Search Engine Tool MCP

A Python MCP (Model Context Protocol) Server for web search and extraction with multiple providers.

Version

Current version: 0.4.2

Features

  • ๐Ÿ” Web Search: Search the web using You.com or Tavily APIs
  • ๐Ÿ“„ Content Extraction: Extract clean content from any URL (free local extraction or Tavily API)
  • ๐Ÿ”„ Auto Provider Selection: Automatically chooses the best available provider
  • ๐Ÿ”‘ Optional API Keys: Works without API keys using local extraction (Tavily requires API key for enhanced extraction)
  • ๐Ÿš€ MCP Compatible: Full support for Model Context Protocol

Installation

From PyPI (Recommended)

โœ… Latest version 0.4.2 is now available on PyPI!

PyPI Package Page: https://pypi.org/project/search-engine-tool-mcp/0.4.2/

# Using pip
pip install search-engine-tool-mcp==0.4.2

# Or using uv (recommended)
uv pip install search-engine-tool-mcp==0.4.2

# Or using uvx (no installation required)
uvx --from search-engine-tool-mcp==0.4.2 search-engine-tool-mcp

From Source

git clone https://github.com/YiHarvest/search-engine-tool.git
cd search-engine-tool

# Using uv (recommended)
uv sync

# Or using pip
pip install -e .

Configuration

Environment Variables

  • SEARXNG_BASE_URL (recommended): Your SearXNG instance URL. Example: http://127.0.0.1:8080
  • TALORDATA_API_KEY (recommended): Your TalorData SERP API key for web search. Get it at https://dashboard.talordata.com. Note: TalorData only supports web_search, not web_extract.
  • YDC_API_KEY (recommended): Your You.com API key. Get it at https://you.com/platform.
  • TAVILY_API_KEY (optional): Your Tavily API key for advanced features and fallback extraction.

Auto Provider Selection Logic:

For web_search:

  • If SEARXNG_BASE_URL exists โ†’ uses SearXNG (free, self-hosted)
    • If SearXNG fails or returns empty results โ†’ falls back to TalorData, Tavily, or You.com
  • If TALORDATA_API_KEY exists โ†’ uses TalorData (SERP API provider)
    • If TalorData fails or returns empty results โ†’ falls back to Tavily or You.com
  • If TAVILY_API_KEY exists โ†’ uses Tavily
  • If YDC_API_KEY or YOU_API_KEY exists โ†’ uses You.com
  • If none configured โ†’ throws error

For web_extract:

  • Default provider is local (free, no API key required)
  • If provider="auto" and local extraction fails:
    • Falls back to Tavily if TAVILY_API_KEY is available
    • Otherwise returns error
  • If provider="tavily" โ†’ requires TAVILY_API_KEY
  • Note: TalorData does NOT support web_extract

Quick Configuration

  1. Copy the example configuration file:
cp .env.example .env
  1. Edit the .env file and fill in your API keys:
YDC_API_KEY="your-ydc-api-key-here"
TAVILY_API_KEY="your-tavily-api-key-here"
SEARXNG_BASE_URL="http://127.0.0.1:8080"
TALORDATA_API_KEY="your-talordata-api-key-here"

Or Set Environment Variables Manually

# Set SearXNG base URL (recommended for free self-hosted search)
export SEARXNG_BASE_URL="http://127.0.0.1:8080"

# Set TalorData API key (recommended for SERP API search)
export TALORDATA_API_KEY="your-talordata-api-key"

# Set You.com API key (alternative)
export YDC_API_KEY="ydc-sk-your-api-key"

# Or set Tavily API key (alternative)
export TAVILY_API_KEY="tvly-your-api-key"

MCP Client Configuration

Add to your MCP client configuration (e.g., Claude Desktop, Cursor, or other MCP-compatible clients):

{
  "mcpServers": {
    "search-engine-tool": {
      "command": "uvx",
      "args": [
        "--from",
        "search-engine-tool-mcp==0.4.2",
        "search-engine-tool-mcp"
      ],
      "env": {
        "TALORDATA_API_KEY": "your-talordata-api-key",
        "TALORDATA_BASE_URL": "https://serpapi.talordata.net/serp/v1/request",
        "TALORDATA_TRIAL_EXPIRES_AT": "2026-07-15T06:05:25+08:00",
        "SEARXNG_BASE_URL": "http://127.0.0.1:8080"
      }
    }
  }
}

Usage

Available Tools

The MCP server exposes two tools:

1. web_search

Search the web for information.

Parameters:

Parameter Type Required Default Description
query string โœ… - Search query string
provider string โŒ "auto" Provider to use: "auto", "searxng", "talordata", "you", or "tavily"
max_results integer โŒ 5 Maximum number of results (1-20)
search_depth string โŒ "basic" Search depth: "basic" or "advanced" (Tavily only)
include_answer boolean โŒ false Include AI-generated answer (Tavily and TalorData only)

Response:

{
  "query": "search query",
  "provider": "jina",
  "count": 5,
  "results": [
    {
      "href": "https://example.com",
      "title": "Result Title",
      "abstract": "Result snippet..."
    }
  ]
}

2. web_extract

Extract content from a specific URL.

Parameters:

Parameter Type Required Default Description
url string โœ… - URL to extract content from
provider string โŒ "auto" Provider to use: "auto", "local", or "tavily"

Provider Options:

  • local (default free provider): Free local extraction, no API key required. Uses trafilatura + BeautifulSoup for content extraction.
    • โš ๏ธ Limitations:
      • Does not execute JavaScript
      • Cannot bypass login walls, paywalls, or CAPTCHA
      • Dynamic/spa-style pages may have incomplete extraction
      • Timeout: 20 seconds (default)
  • tavily (enhanced provider): Tavily API extraction, requires TAVILY_API_KEY.
    • โœ… Better for complex/dynamic pages
    • โœ… Can handle more challenging sites
  • auto (default): Tries local first, falls back to Tavily if TAVILY_API_KEY is available and local fails.

Response:

{
  "url": "https://example.com",
  "content": "Extracted content...",
  "provider": "local"
}

Provider Selection Logic

  • provider="searxng": Always use SearXNG (requires SEARXNG_BASE_URL)
    • โš ๏ธ Limitations:
      • Requires self-hosted SearXNG instance
      • Timeout: 15 seconds
      • If returns empty results โ†’ throws error
  • provider="you": Always use You.com (requires YDC_API_KEY)
  • provider="tavily": Always use Tavily (requires TAVILY_API_KEY)
  • provider="auto"** (default):
    • If SEARXNG_BASE_URL environment variable is set โ†’ use SearXNG
      • If SearXNG fails or returns empty results โ†’ fallback to TalorData, Tavily, or You.com
    • If TALORDATA_API_KEY exists โ†’ use TalorData
      • If TalorData fails or returns empty results โ†’ fallback to Tavily or You.com
    • If TAVILY_API_KEY exists โ†’ use Tavily
    • If YDC_API_KEY or YOU_API_KEY exists โ†’ use You.com
    • Otherwise โ†’ throws error

TalorData SERP API

TalorData is a SERP (Search Engine Results Page) API provider that offers structured search results from Google, Bing, and other search engines. Important: TalorData is ONLY for web_search, NOT for web_extract.

Features

  • โœ… High quality: Top-ranked SERP API provider
  • โœ… Multi-engine support: Google, Bing, DuckDuckGo, and more
  • โœ… Structured output: Clean JSON format with detailed metadata
  • โœ… AI Overview: Supports AI-generated answers (include_answer parameter)
  • โœ… Optional fields: Returns position, source, display_link for advanced analysis
  • โœ… Fast response: Average response time under 1 second
  • โœ… Pay for success: Only charges for successful requests
  • โš ๏ธ API key required: Requires TALORDATA_API_KEY
  • โš ๏ธ Web search only: Does NOT support web_extract

Get API Key

  1. Visit TalorData Dashboard
  2. Sign up for a free account
  3. Navigate to API Playground to get your API token
  4. Set the environment variable:
export TALORDATA_API_KEY="your-api-key-here"

Usage Example

# Web search with TalorData
results = await web_search(
    query="OpenAI",
    provider="talordata",
    max_results=10,
    include_answer=True  # Get AI-generated overview
)

# Response includes:
# - href: URL of the result
# - title: Title of the result
# - abstract: Description or snippet
# - position: Position in search results (optional)
# - source: Source name (optional)
# - display_link: Displayed link (optional)
# - answer: AI-generated overview (if include_answer=True)

SearXNG Setup

SearXNG is a free, self-hosted metasearch engine that aggregates results from multiple search engines.

Installation

  1. Using Docker (recommended):
docker run -d --name searxng -p 8080:8080 searxng/searxng:latest
  1. Manual installation: Follow the SearXNG documentation

Configuration

After setting up SearXNG, set the environment variable:

export SEARXNG_BASE_URL="http://127.0.0.1:8080"

Features

  • โœ… Free: No API key required
  • โœ… Privacy-focused: No tracking
  • โœ… Multiple engines: Aggregates results from Google, Bing, DuckDuckGo, etc.
  • โœ… Customizable: Choose specific engines with engines parameter
  • โš ๏ธ Self-hosted: Requires running your own instance
  • โš ๏ธ Timeout: 15-second limit to prevent MCP hanging

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/YiHarvest/search-engine-tool.git
cd search-engine-tool

# Using uv (recommended)
uv sync --all-extras

# Or using pip
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Run Tests

# Using uv
uv run pytest

# Or using pytest directly
pytest

Build Package

# Using uv (recommended)
uv build

# Or using build directly
python -m build

Check Package

# Using uv
uv run twine check dist/*

# Or using twine directly
twine check dist/*

API Reference

Jina Provider

  • Search API: https://api.jina.ai/search
  • Reader API: https://r.jina.ai/{url}
  • Requirements: No API key needed
  • Rate Limits: Subject to Jina's public API limits

Tavily Provider

  • Search API: https://api.tavily.com/search
  • Extract API: https://api.tavily.com/extract
  • Requirements: API key required (TAVILY_API_KEY)
  • Features: Advanced search depth, AI-generated answers

Project Structure

search-engine-tool/
โ”œโ”€โ”€ src/search_engine_tool_mcp/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ server.py          # MCP server implementation
โ”‚   โ”œโ”€โ”€ search.py          # Web search functionality
โ”‚   โ”œโ”€โ”€ extract.py         # Content extraction
โ”‚   โ”œโ”€โ”€ schemas.py         # Pydantic data models
โ”‚   โ””โ”€โ”€ providers/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ you.py         # You.com provider (search)
โ”‚       โ”œโ”€โ”€ tavily.py      # Tavily provider (search + extract)
โ”‚       โ””โ”€โ”€ local_extract.py  # Local extraction provider (free)
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_search.py
โ”‚   โ””โ”€โ”€ test_providers.py
โ”‚   โ””โ”€โ”€ test_extract.py
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and feature requests, please use the GitHub Issues page.

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

search_engine_tool_mcp-0.4.2.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

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

search_engine_tool_mcp-0.4.2-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file search_engine_tool_mcp-0.4.2.tar.gz.

File metadata

  • Download URL: search_engine_tool_mcp-0.4.2.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for search_engine_tool_mcp-0.4.2.tar.gz
Algorithm Hash digest
SHA256 9b3b6b34ae5cf3a14193cd106d33c65cba835e6abe68e330ababb4bf19b109b3
MD5 74ebac08e24d5b4b7966e9d5ed8e3c60
BLAKE2b-256 107f5ee80494dfdaa6fd722f538f3f2e81294cbdb4ad4594137631618528daa9

See more details on using hashes here.

File details

Details for the file search_engine_tool_mcp-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for search_engine_tool_mcp-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac2d45c994ab095a41c5fd62055e67390a4a9049a0146952b51a5464e5e73d11
MD5 22fddab5848fd6a925adc4233cde1b98
BLAKE2b-256 ad45bd2864648d507e1934556144b2d19e48936243952f30ec944f9a118d1338

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