Skip to content
1 min read · 173 words

Function: createSearxngSearchTool()

ts
function createSearxngSearchTool(config: SearxngToolConfig): Tool;

Defined in: batteries/tools/searxng/index.ts:209

Create a configured SearXNG search Tool.

Parameters

ParameterTypeDescription
configSearxngToolConfigThe instance URL, optional custom headers, output-format policy, artifact type, and input/output middleware pipelines. See SearxngToolConfig.

Returns

Tool

A Tool ready to register in a ToolRegistry.

Remarks

The handler always requests format=json. Note that SearXNG ships with JSON output disabled by default (it is abused by bots); an instance that has not enabled search.formats: [json] in its settings.yml answers with HTTP 403, which the tool returns as a graceful Error: string naming the setting.

WARNING

Do not trust the number_of_results field for a result count — SearXNG frequently reports 0 in JSON output even when results is non-empty. This is a long-standing upstream quirk, not a tool defect (see searxng#2987 and searxng#2457). The tool passes the field through verbatim; use results.length as the authoritative count.

Throws

E_INVALID_SEARXNG_CONFIG when instanceUrl is missing or unparseable.