websearch
by Jinddddd
websearch_tool
Web search tool with two interfaces sharing one core. Serper primary, DuckDuckGo fallback (on error or empty results).
Install
uv pip install -e . # or: pip install -e .
export SERPER_API_KEY=<your-key>HTTP API
uvicorn websearch.http_api:app --port 8000
curl "http://127.0.0.1:8000/search?q=anthropic+claude&num=5"Endpoint | Params | Response |
|
|
|
| — |
|
source is serper or ddg. Each result has title, url, snippet.
MCP Server
python -m websearch.mcp_server # stdio transportExposes one tool: web_search(query: str, num: int = 10).
MCP client config:
{
"mcpServers": {
"websearch": {
"command": "python",
"args": ["-m", "websearch.mcp_server"],
"env": { "SERPER_API_KEY": "<your-key>" }
}
}
}Library
from websearch import search
resp = search("anthropic claude", num=5) # reads SERPER_API_KEY from env