brave_search
Perform web searches through the Brave Search API to retrieve structured results including titles, URLs, and descriptions while maintaining privacy with no tracking.
Instructions
Web search via Brave Search API. Returns structured results with titles, URLs, descriptions, and snippets. Privacy-focused, no tracking.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | Search query | |
| count | No | Number of results (default 10, max 20) | |
| country | No | Country code for localized results (e.g., KR, JP, US) | |
| search_lang | No | Language code (e.g., ko, ja, en) | |
| freshness | No | Freshness filter: pd=past day, pw=past week, pm=past month, py=past year |
Implementation Reference
- src/tools/brave.ts:4-18 (registration)The tool 'brave_search' is defined in the tools registry within src/tools/brave.ts. It is dynamically registered in src/index.ts using this configuration.
export const braveTools: ToolDef[] = [ { name: "brave_search", description: "Web search via Brave Search API. Returns structured results with titles, URLs, descriptions, and snippets. Privacy-focused, no tracking.", inputSchema: z.object({ q: z.string().describe("Search query"), count: z.number().optional().describe("Number of results (default 10, max 20)"), country: z.string().optional().describe("Country code for localized results (e.g., KR, JP, US)"), search_lang: z.string().optional().describe("Language code (e.g., ko, ja, en)"), freshness: z.enum(["pd", "pw", "pm", "py"]).optional() .describe("Freshness filter: pd=past day, pw=past week, pm=past month, py=past year"), }), endpoint: "/v1/brave/search", }, ]; - src/index.ts:15-39 (handler)The handler for 'brave_search' is dynamically constructed in src/index.ts. It executes a network request to the gateway using the tool's defined endpoint '/v1/brave/search'.
for (const tool of allTools) { server.tool( tool.name, tool.description, tool.inputSchema.shape, async (params) => { const method = tool.method || "POST"; const result = await gatewayRequest(method, tool.endpoint, params as Record<string, unknown>); if (result.error) { return { content: [{ type: "text" as const, text: `Error (${result.status}): ${result.error}` }], isError: true, }; } const text = typeof result.data === "string" ? result.data : JSON.stringify(result.data, null, 2); return { content: [{ type: "text" as const, text }], }; }, );