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.3
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.3 is now available on PyPI!
PyPI Package Page: https://pypi.org/project/search-engine-tool-mcp/0.4.3/
# Using pip
pip install search-engine-tool-mcp==0.4.3
# Or using uv (recommended)
uv pip install search-engine-tool-mcp==0.4.3
# Or using uvx (no installation required)
uvx --from search-engine-tool-mcp==0.4.3 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 TALORDATA_API_KEY exists โ uses TalorData (SERP API provider)
- If TalorData fails or returns empty results โ falls back to Tavily or You.com
- Otherwise, 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
- Otherwise, if YDC_API_KEY or YOU_API_KEY exists โ uses You.com
- Otherwise, if TAVILY_API_KEY exists โ uses Tavily
- 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_KEYis available - Otherwise returns error
- Falls back to Tavily if
- If provider="tavily" โ requires
TAVILY_API_KEY - Note: TalorData does NOT support web_extract
Quick Configuration
- Copy the example configuration file:
cp .env.example .env
- Edit the
.envfile 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"
Run SearXNG Locally
SEARXNG_BASE_URL is not an API key. It is the URL of a SearXNG instance that you run. This MCP server uses SearXNG's JSON search endpoint, so json must be enabled in settings.yml.
- Create the configuration directory and
searxng/settings.yml:
mkdir -p searxng
# searxng/settings.yml
use_default_settings: true
search:
formats:
- html
- json
server:
# Replace this even for local use: openssl rand -hex 32
secret_key: "replace-with-a-random-secret"
limiter: false
image_proxy: true
- Start a SearXNG container bound only to localhost:
docker run -d \
--name searxng \
--restart unless-stopped \
-p 127.0.0.1:8080:8080 \
-v "$(pwd)/searxng:/etc/searxng:rw" \
docker.io/searxng/searxng:latest
- Verify the JSON endpoint:
curl "http://127.0.0.1:8080/search?q=hello&format=json"
After it returns JSON containing results, configure:
SEARXNG_BASE_URL="http://127.0.0.1:8080"
Use docker stop searxng and docker start searxng to stop and restart it. For production or public deployment, add a reverse proxy, HTTPS, access controls, and a random secret_key; see the official SearXNG container documentation.
MCP Client Configuration
Credentials must be passed to the MCP server process as environment variables. All values below are placeholders. Keep only the providers you use, and never commit real credentials to Git.
Trae (JSON)
Add or import the following configuration in Trae's MCP settings:
{
"mcpServers": {
"search-engine-tool": {
"command": "uvx",
"args": [
"--from",
"search-engine-tool-mcp==0.4.3",
"search-engine-tool-mcp"
],
"env": {
"TALORDATA_API_KEY": "your-talordata-api-key",
"TALORDATA_BASE_URL": "https://serpapi.talordata.net/serp/v1/request",
"SEARXNG_BASE_URL": "http://127.0.0.1:8080",
"YDC_API_KEY": "your-you-api-key",
"TAVILY_API_KEY": "tvly-your-tavily-api-key"
}
}
}
}
Restart or refresh the MCP server after saving. If Trae and SearXNG run on different hosts or container networks, 127.0.0.1 refers to the environment running Trae/the MCP process; replace it with a SearXNG URL reachable from that environment.
Codex (TOML)
Codex CLI and the Codex IDE extension share config.toml. Add this to the user configuration at ~/.codex/config.toml, or to .codex/config.toml in a trusted project:
[mcp_servers.search-engine-tool]
command = "uvx"
args = [
"--from",
"search-engine-tool-mcp==0.4.3",
"search-engine-tool-mcp",
]
startup_timeout_sec = 30
tool_timeout_sec = 60
[mcp_servers.search-engine-tool.env]
TALORDATA_API_KEY = "your-talordata-api-key"
TALORDATA_BASE_URL = "https://serpapi.talordata.net/serp/v1/request"
SEARXNG_BASE_URL = "http://127.0.0.1:8080"
YDC_API_KEY = "your-you-api-key"
TAVILY_API_KEY = "tvly-your-tavily-api-key"
Restart Codex, then run codex mcp list or use /mcp in a Codex session to verify the connection. See the official Codex MCP documentation for configuration options.
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)
- โ ๏ธ Limitations:
tavily(enhanced provider): Tavily API extraction, requiresTAVILY_API_KEY.- โ Better for complex/dynamic pages
- โ Can handle more challenging sites
auto(default): Tries local first, falls back to Tavily ifTAVILY_API_KEYis available and local fails.
Response:
{
"url": "https://example.com",
"content": "Extracted content...",
"provider": "local"
}
Provider Selection Logic
provider="searxng": Always use SearXNG (requiresSEARXNG_BASE_URL)- โ ๏ธ Limitations:
- Requires self-hosted SearXNG instance
- Timeout: 15 seconds
- If returns empty results โ throws error
- โ ๏ธ Limitations:
provider="you": Always use You.com (requiresYDC_API_KEY)provider="tavily": Always use Tavily (requiresTAVILY_API_KEY)provider="auto"** (default):- Initial selection order: TalorData โ SearXNG โ You.com โ Tavily
- On failure or empty results, switches through the configured fallback chain for the current provider
- If no provider is configured โ throws an 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_answerparameter) - โ 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
- Visit TalorData Dashboard
- Sign up for a free account
- Navigate to API Playground to get your API token
- 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
- Using Docker (recommended):
docker run -d --name searxng -p 8080:8080 searxng/searxng:latest
- 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
enginesparameter - โ ๏ธ 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file search_engine_tool_mcp-0.4.3.tar.gz.
File metadata
- Download URL: search_engine_tool_mcp-0.4.3.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e91e5058f91941141de45b59c07501080b201c1ebb6b710f89ed970917d3a80d
|
|
| MD5 |
40d533af1755e30cb181a07cfa6a2608
|
|
| BLAKE2b-256 |
b21e7d367203155422ed9e7503f7520f10e3f3e6de784c14d572d66d00d6caa5
|
File details
Details for the file search_engine_tool_mcp-0.4.3-py3-none-any.whl.
File metadata
- Download URL: search_engine_tool_mcp-0.4.3-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59de8e5a39adbda570f3325a7bae14cd7d9d87e6c127911e2c2d0f9d67ee1219
|
|
| MD5 |
b3f82dcb12ec473dd407a6d0231fe5ba
|
|
| BLAKE2b-256 |
dfd2ba4d68576169c2b4ad803f4c429d3a7d261d81e36bacdb6fe9757a315cbc
|