# plugin_websearch — SCORPIOX BOT multi-provider web search connector A clean-room, zero-dependency **pure C99** `plugin_` for SCORPIOX BOT that gives an agent one `web_search` tool across six backends, and gives you a page to pick the backend, store keys and try a real search. ```sh make # -> ./plugin_websearch make test # the offline suite (no network, no credentials) make e2e # Playwright at 1440/1024/390, dark + light make e2e --shots /tmp/shots # ...without overwriting the committed docs/*.png ``` Every `src/*.h`, `vendor/*.h` and `vendor/bearssl/*.h` is a rebuild prerequisite: a one-line edit to a header (a version bump, a provider id, a buffer size) forces a rebuild, because `make` reporting "Nothing to be done" while the previous binary stays in place is a success message about a stale artifact. | | | |---|---| | Slug / binary | `websearch` / `plugin_websearch` (`--meta` name `websearch`, desc `Web search MCP`) | | Kind | `mcp: true`, `daemon: false`, `menus: false`, category `network` | | `verified` | `mock` — see [Verification tier](#verification-tier) | | Dist targets | `linux-x86_64`, `linux-x86_64-musl`, `linux-arm64-musl`, `macos-arm64`, `macos-x86_64`, `windows-x86_64` | | Runtime deps | none — no libcurl, no OpenSSL, no system CA file, no `curl` binary | | Source | `https://plugingit.scorpiox.net/scorpiox-bot-plugin-websearch.git` | | Artifacts | `https://dist.scorpiox.net/bot-plugins/websearch/` | ## Backends | id | Auth | Endpoint | Notes | |---|---|---|---| | `duckduckgo` | **none** | `POST {base}/html/` | the HTML result page is parsed; a GET gets DuckDuckGo's bot challenge, so the request is a form POST. **Measured: DuckDuckGo rate-limits an IP after a handful of queries** (HTTP `202` + `anomaly-modal`) and then keeps answering `202` for a while — the plugin reports that as a challenge with the alternatives named, never as "no results" | | `searxng` | none | `GET {base}/search?format=json` | your own instance; needs `search.formats: [json]` in its `settings.yml` | | `brave` | `X-Subscription-Token` | `GET {base}/res/v1/web/search` | supports `country`, `language`, `freshness` | | `tavily` | `Authorization: Bearer` | `POST {base}/search` | optional `include_answer` / `search_depth: advanced` | | `exa` | `x-api-key` | `POST {base}/search` | `contents.highlights[0]` becomes the snippet | | `perplexity` | `Authorization: Bearer` | `POST {base}/search` | the Search API (ranked sources), not chat completions | Every backend is normalised to the same result object, so the agent never learns a vendor's field names: ```json {"title":"…","url":"https://…","snippet":"…","published":"2026-11-14","site":"example.com"} ``` `provider` is an argument on the tool *and* a saved default. With no key configured the tool says exactly which variable to set, instead of returning "no results". **On the keyless default:** DuckDuckGo is the only backend that needs nothing, and it is also the only one that will rate-limit you — after a few queries from one IP it serves its bot-detection page (`202`) and keeps doing so for a while. That is measured behaviour on this fleet, not a maybe: `tests/run.sh` covers it by asserting the challenge page becomes an error naming the alternatives, and the fix for a node that searches a lot is a keyed provider or your own SearXNG instance. ## MCP tools Served over stdio JSON-RPC 2.0 from `plugin_websearch --mcp`, which is what the single `sx-connector-mcp` router drives — so registering it costs **no** `clang` MCP slot and no prompt tokens until a tool is actually called. ### `web_search` | argument | type | | |---|---|---| | `query` | string, **required** | the search query | | `provider` | enum | `duckduckgo` \| `searxng` \| `brave` \| `tavily` \| `exa` \| `perplexity` — omit for the configured default | | `count` | integer 1–20 | how many results (default 5) | | `country` | string | two-letter code, Brave only (`NZ`, `US`, `ALL`) | | `language` | string | ISO 639-1 (`en`, `de`, `fr`) | | `freshness` | enum | `day` \| `week` \| `month` \| `year`, Brave only | Returns `structuredContent` with `ok`, `query`, `provider`, `count`, `took_ms`, `results[]`, and `answer`/`citations` when a backend produces them. A failure is an `isError` result whose text carries the provider's own message and its HTTP status. ### `web_search_providers` No arguments. Reports every backend with `needs_key`, `needs_base`, `has_key` and `ready`, plus which one is the default. **Never returns a key** — only whether one is present. ```sh printf '%s\n' \ '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"web_search","arguments":{"query":"rust async","provider":"brave","count":3}}}' \ | ./plugin_websearch --mcp ``` ## Configuration Resolution order, lowest priority first — the environment always wins: 1. compiled defaults (`https://api.search.brave.com`, …) 2. `/config.json`, written by the page, **mode 0600** 3. the environment The connector directory is deliberately outside the plugin's own directory, so a plugin update can never take your keys with it: ``` $SWEBSEARCH_CONFIG_DIR (tests) /workspace/.scorpiox/connectors/plugin_websearch (BotCloud: survives a rebuild) ~/.scorpiox/connectors/plugin_websearch (POSIX) %LOCALAPPDATA%\scorpiox\connectors\plugin_websearch (Windows) ``` | env | | |---|---| | `BRAVE_API_KEY` / `TAVILY_API_KEY` / `EXA_API_KEY` / `PERPLEXITY_API_KEY` | the keys (also accepted: `WEBSEARCH__KEY`) | | `WEBSEARCH_PROVIDER` | default backend id | | `WEBSEARCH_COUNT` | default result count (1–20) | | `WEBSEARCH_REGION` | DuckDuckGo `kl` (e.g. `nz-en`) | | `WEBSEARCH_SAFE` | `strict` \| `moderate` \| `off` | | `WEBSEARCH_LANGUAGE` | ISO 639-1 | | `WEBSEARCH_SEARXNG_BASE` (or `SEARXNG_URL`) | your instance | | `WEBSEARCH_SEARXNG_CATEGORIES` | e.g. `general`, `news` | | `WEBSEARCH_{DDG,BRAVE,TAVILY,EXA,PPLX}_BASE` | override one provider's base URL | | `WEBSEARCH_TAVILY_ANSWER` / `WEBSEARCH_TAVILY_ADVANCED` | `1` / `0` | | `WEBSEARCH_MOCK_BASE` | point every provider at one loopback mock (tests only) | ## The page `GET /plugin_websearch` — bot theme tokens, dark and light, `?embed=1`, `&theme=`, the `sx-theme` postMessage handoff, zero `