search
Perform Google web searches with customizable parameters like location, language, date range, and result scraping options to find specific information.
Instructions
Perform Google web searches with customizable parameters.
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 | |
| scrapeResults | No | Whether to scrape results | |
| numResultsToScrape | No | Number of results to scrape | |
| scrapeOptions | No | Scraping options |
Implementation Reference
- src/index.ts:100-135 (handler)The handler function that executes the 'search' tool logic by making a POST request to the DumplingAI API's /api/v1/search endpoint with the provided parameters and returning the JSON response.async ({ query, country, location, language, dateRange, page, scrapeResults, numResultsToScrape, scrapeOptions, }) => { 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`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, country, location, language, dateRange, page, scrapeResults, numResultsToScrape, scrapeOptions, }), }); 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:70-99 (schema)Zod schema defining the input parameters for the 'search' tool, including query, optional filters like country, location, dateRange, and scraping options.{ 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"), scrapeResults: z.boolean().optional().describe("Whether to scrape results"), numResultsToScrape: z .number() .optional() .describe("Number of results to scrape"), scrapeOptions: z .object({ format: z.enum(["markdown", "html", "screenshot"]).optional(), cleaned: z.boolean().optional(), }) .optional() .describe("Scraping options"), },
- src/index.ts:67-136 (registration)The server.tool call that registers the 'search' tool with the MCP server, specifying its name, description, input schema, and handler function.server.tool( "search", "Perform Google web searches with customizable parameters.", { 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"), scrapeResults: z.boolean().optional().describe("Whether to scrape results"), numResultsToScrape: z .number() .optional() .describe("Number of results to scrape"), scrapeOptions: z .object({ format: z.enum(["markdown", "html", "screenshot"]).optional(), cleaned: z.boolean().optional(), }) .optional() .describe("Scraping options"), }, async ({ query, country, location, language, dateRange, page, scrapeResults, numResultsToScrape, scrapeOptions, }) => { 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`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, country, location, language, dateRange, page, scrapeResults, numResultsToScrape, scrapeOptions, }), }); 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) }] }; } );