websearch-custom-serve
README.md
# websearch-custom
A DuckDuckGo search provider for
[`web-search-plus-mcp`](https://pypi.org/project/web-search-plus-mcp/) 5.1.6, and the
`websearch-custom-serve` command that runs the server with that provider registered.
The provider has the id `ddg`. It needs no key and searches through
[`ddgs`](https://pypi.org/project/ddgs/) text search. Everything else — the MCP tools
`web_search` and `web_extract`, the keyed providers, routing, caching and cooldowns — is the
server's own.
## Install
The package is `websearch-custom-provider`. It pins `web-search-plus-mcp==5.1.6` and
`ddgs==9.16.1`. Install it from a tag of this repository:
```bash
uv tool install git+https://github.com/eoc-llm-tooling/websearch-custom@v0.1.1
```
or depend on it from a project, pinned to the tag:
```toml
[project]
dependencies = ["websearch-custom-provider==0.1.1"]
[tool.uv.sources]
websearch-custom-provider = { git = "https://github.com/eoc-llm-tooling/websearch-custom", tag = "v0.1.1" }
```
The repository carries a `uv.lock`; `uv export --frozen --no-dev` gives the locked
requirements of a deployment.
## Run
```bash
websearch-custom-serve # stdio MCP server, the server's default
websearch-custom-serve --help # the server's own options
```
`websearch-custom-serve` takes the same arguments and reads the same environment as the
server's `web-search-plus-mcp serve`. It speaks MCP over stdio and is meant to run behind a
client or a proxy that starts it.
| Variable | Value | Why |
|---|---|---|
| `DDG_ALLOW_PUBLIC` | `1` | the server enables a keyless provider only when its opt-in variable is set; `ddg` takes `DDG_ALLOW_PUBLIC` |
| `TAVILY_API_KEY`, `EXA_API_KEY`, `SERPER_API_KEY` | optional | the server's keyed providers, for `web_extract` and as further `web_search` providers |
| `WEB_SEARCH_PLUS_CONFIG` | path to a `config.json` | the server's configuration, including the routing order |
`ddg` first, then the keyed providers, is the routing file
```json
{"auto_routing": {"order": "custom", "provider_priority": ["ddg", "tavily", "exa", "serper"], "fallback_provider": "serper"}}
```
## Behaviour
| `ddgs` outcome | Provider result |
|---|---|
| results | one source per result with a URL: `url`, `title`, `snippet` |
| `DDGSException("No results found.")` | an empty result list; the server moves to the next provider |
| `TimeoutException`, `RatelimitException`, `ConnectionError`, `TimeoutError` | `ProviderRequestError`, `transient` set |
| any other exception | `ProviderRequestError`, `transient` unset |
Every failure raised to the server is also written to stderr as one line,
`ddg: ddgs <exception type>: <message>`; `No results found.` writes nothing. Searches use
`safesearch` `moderate`. The design is in [`ARCHITECTURE.md`](ARCHITECTURE.md).
## Development
```bash
uv sync
uv run poe gate # lint, format check, type check, offline tests, leak check
```
The tests run offline: `ddgs` is replaced by a double.
## License
MIT, see [`LICENSE`](LICENSE).