brave_news_search
Search for news articles on recent events, trending topics, or specific stories using Brave Search API. Retrieve up to 20 results with titles, URLs, and descriptions per request.
Instructions
Searches for news articles using the Brave Search API. Use this for recent events, trending topics, or specific news stories. Returns a list of articles with titles, URLs, and descriptions. Maximum 20 results per request.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | The number of results to return, minimum 1, maximum 20 | |
| query | Yes | The term to search the internet for news articles, trending topics, or recent events |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"count": {
"default": 10,
"description": "The number of results to return, minimum 1, maximum 20",
"maximum": 20,
"minimum": 1,
"type": "number"
},
"query": {
"description": "The term to search the internet for news articles, trending topics, or recent events",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/tools/BraveNewsSearchTool.ts:38-59 (handler)The executeCore method implements the core logic of the brave_news_search tool, performing the news search using BraveSearch API, handling no results, and formatting the output as text with title, URL, age, and description for each result.public async executeCore(input: z.infer<typeof newsSearchInputSchema>) { const { query, count, freshness } = input; const newsResult = await this.braveSearch.newsSearch(query, { count, ...(freshness ? { freshness } : {}), }); if (!newsResult.results || newsResult.results.length === 0) { this.braveMcpServer.log(`No news results found for "${query}"`); const text = `No news results found for "${query}"`; return { content: [{ type: 'text' as const, text }] }; } const text = newsResult.results .map(result => `Title: ${result.title}\n` + `URL: ${result.url}\n` + `Age: ${result.age}\n` + `Description: ${result.description}\n`, ) .join('\n\n'); return { content: [{ type: 'text' as const, text }] }; }
- Zod input schema for brave_news_search tool defining parameters: query (string), count (number 1-20, default 10), freshness (enum or date range string).const newsSearchInputSchema = z.object({ query: z.string().describe('The term to search the internet for news articles, trending topics, or recent events'), count: z.number().min(1).max(20).default(10).optional().describe('The number of results to return, minimum 1, maximum 20'), freshness: z.union([ z.enum(['pd', 'pw', 'pm', 'py']), z.string().regex(/^\d{4}-\d{2}-\d{2}to\d{4}-\d{2}-\d{2}$/, 'Date range must be in format YYYY-MM-DDtoYYYY-MM-DD') ]) .optional() .describe( `Filters search results by when they were discovered. The following values are supported: - pd: Discovered within the last 24 hours. - pw: Discovered within the last 7 Days. - pm: Discovered within the last 31 Days. - py: Discovered within the last 365 Days. - YYYY-MM-DDtoYYYY-MM-DD: Custom date range (e.g., 2022-04-01to2022-07-30)`, ), });
- src/server.ts:64-69 (registration)Registers the brave_news_search tool instance with the MCP server by calling server.tool() with name, description, input schema, and bound execute method.this.server.tool( this.newsSearchTool.name, this.newsSearchTool.description, this.newsSearchTool.inputSchema.shape, this.newsSearchTool.execute.bind(this.newsSearchTool), );