get-autocomplete
Generate Google autocomplete suggestions for a search query, refining results based on location, country, and language parameters to enhance search accuracy and relevance.
Instructions
Retrieve Google autocomplete suggestions for a query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country | No | Country code (e.g., 'us') | |
| language | No | Language code (e.g., 'en') | |
| location | No | Location name | |
| query | Yes | Search query |
Implementation Reference
- src/index.ts:148-162 (handler)The handler function that executes the tool logic: authenticates with DUMPLING_API_KEY, POSTs parameters to external API at NWS_API_BASE/api/v1/get-autocomplete, parses response, and formats as MCP content block.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:142-147 (schema)Input schema using Zod: query (string), optional location, country, language with descriptions.{ 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)server.tool() registration call defining the tool name 'get-autocomplete', description, input schema, and handler function.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) }] }; } );