API: providers/brave
better-web-search-mcp / providers/brave
providers/brave#
Classes#
BraveProvider#
Defined in: src/providers/brave.ts:71
Brave Search provider (primary).
Requires BRAVE_API_KEY in the environment. When the key is missing, or
the API returns an auth/rate-limit error, it returns an empty array and
logs a warning rather than throwing.
Implements#
Constructors#
Constructor#
new BraveProvider():
BraveProvider
Returns#
Properties#
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
name | readonly | "brave" | "brave" | Stable provider identifier (e.g. “brave”, “tavily”, “duckduckgo”). | src/providers/brave.ts:72 |
Methods#
search()#
search(
query,opts):Promise<SearchResult[]>
Defined in: src/providers/brave.ts:74
Run a search and return normalized results.
Implementations MUST NOT throw on provider errors (missing key, HTTP 401/429, timeout). They return an empty array and log a warning instead, so one failing provider never breaks the aggregate search.
Parameters#
| Parameter | Type |
|---|---|
query | string |
opts | SearchOptions |
Returns#
Promise<SearchResult[]>
Implementation of#
Functions#
freshnessFromRecencyDays()#
freshnessFromRecencyDays(
days):string|undefined
Defined in: src/providers/brave.ts:15
Map a number of days to a Brave freshness filter value.
Brave accepts “pd” (past day), “pw” (past week), “pm” (past month), “py” (past year), or an explicit “YYYY-MM-DDtoYYYY-MM-DD” range. We map common day counts to the coarse tokens and fall back to a date range for anything else.
Parameters#
| Parameter | Type |
|---|---|
days | number |
Returns#
string | undefined