get-autocomplete
Retrieve Google autocomplete suggestions for search queries to understand user intent and popular search trends.
Instructions
Retrieve Google autocomplete suggestions for a query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| location | No | Location name | |
| country | No | Country code (e.g., 'us') | |
| language | No | Language code (e.g., 'en') |
Implementation Reference
- src/index.ts:148-163 (handler)Handler function that proxies the request to Dumpling AI's get-autocomplete API endpoint, requiring DUMPLING_API_KEY environment variable, and returns the JSON response as MCP content.async ({ query, location, country, language }) => { 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/get-autocomplete`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, location, country, language }), }); 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:143-147 (schema)Input schema using Zod validation for the tool parameters.query: z.string().describe("Search query"), location: z.string().optional().describe("Location name"), country: z.string().optional().describe("Country code (e.g., 'us')"), language: z.string().optional().describe("Language code (e.g., 'en')"), },
- src/index.ts:139-164 (registration)Full registration of the 'get-autocomplete' MCP tool using McpServer.tool method, including name, description, input schema, and handler implementation.server.tool( "get-autocomplete", "Retrieve Google autocomplete suggestions for a query.", { query: z.string().describe("Search query"), location: z.string().optional().describe("Location name"), country: z.string().optional().describe("Country code (e.g., 'us')"), language: z.string().optional().describe("Language code (e.g., 'en')"), }, async ({ query, location, country, language }) => { 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/get-autocomplete`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ query, location, country, language }), }); 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) }] }; } );