search-news
Search for news articles across multiple sources using customizable filters like location, language, and time range to find relevant information.
Instructions
Search for news articles across multiple sources.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| country | No | Country code (e.g., 'us') | |
| location | No | Location name | |
| language | No | Language code (e.g., 'en') | |
| dateRange | No | Time range filter | |
| page | No | Page number |
Implementation Reference
- src/index.ts:236-280 (registration)Complete registration of the 'search-news' MCP tool, including name, description, input schema, and execution handler.server.tool( "search-news", "Search for news articles across multiple sources.", { query: z.string().describe("Search query"), country: z.string().optional().describe("Country code (e.g., 'us')"), location: z.string().optional().describe("Location name"), language: z.string().optional().describe("Language code (e.g., 'en')"), dateRange: z .enum([ "anyTime", "pastHour", "pastDay", "pastWeek", "pastMonth", "pastYear", ]) .optional() .describe("Time range filter"), page: z.number().optional().describe("Page number"), }, async ({ query, country, location, language, dateRange, page }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/search-news`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, country, location, language, dateRange, page, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/index.ts:257-279 (handler)The handler function for 'search-news' tool that makes a POST request to the Dumpling AI API endpoint /api/v1/search-news with the provided parameters and returns the JSON response as text content.async ({ query, country, location, language, dateRange, page }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/search-news`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, country, location, language, dateRange, page, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/index.ts:239-256 (schema)Zod schema defining the input parameters for the 'search-news' tool: query (required string), optional country, location, language, dateRange (enum), and page (number).{ query: z.string().describe("Search query"), country: z.string().optional().describe("Country code (e.g., 'us')"), location: z.string().optional().describe("Location name"), language: z.string().optional().describe("Language code (e.g., 'en')"), dateRange: z .enum([ "anyTime", "pastHour", "pastDay", "pastWeek", "pastMonth", "pastYear", ]) .optional() .describe("Time range filter"), page: z.number().optional().describe("Page number"), },