suggest
Retrieves search suggestions and autocomplete results for app store queries, helping users refine their search terms before exploring app details.
Instructions
Get search suggestions/autocomplete for a search term
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | Yes | Search term to get suggestions for | |
| country | No | Two-letter country code (default: us) | us |
Implementation Reference
- src/server.js:480-515 (handler)The main handler function for the 'suggest' tool. It extracts parameters, builds the API URL using buildSuggestUrl, fetches JSON data, parses suggestions using parseSuggest, and returns formatted results or error.async function handleSuggest(args) { try { const { term, country = 'us' } = args; if (!term) { throw new Error('term is required'); } const url = buildSuggestUrl({ term, country }); const data = await fetchJSON(url); const suggestions = parseSuggest(data); return { content: [ { type: 'text', text: JSON.stringify({ term, suggestions, count: suggestions.length, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: error.message }, null, 2), }, ], isError: true, }; } }
- src/server.js:1161-1179 (schema)The input schema definition for the 'suggest' tool, provided in the listTools response.{ name: 'suggest', description: 'Get search suggestions/autocomplete for a search term', inputSchema: { type: 'object', properties: { term: { type: 'string', description: 'Search term to get suggestions for', }, country: { type: 'string', description: 'Two-letter country code (default: us)', default: 'us', }, }, required: ['term'], }, },
- src/server.js:1465-1466 (registration)The dispatch case in the CallToolRequestHandler switch statement that routes 'suggest' tool calls to the handleSuggest function.// Google Play tools case 'gp_app':
- Helper function that parses the raw JSON response from App Store suggest API into an array of suggestions sorted by priority.export function parseSuggest(data) { if (!data || !data.hints || !Array.isArray(data.hints)) { return []; } return data.hints.map(hint => ({ term: hint.term || null, priority: hint.priority || 0, })).sort((a, b) => (b.priority || 0) - (a.priority || 0)); }
- src/endpoints/appStore.js:180-185 (helper)Helper function that constructs the URL for the App Store search suggestions API endpoint.export function buildSuggestUrl(params) { const { term, country = 'us' } = params; // App Store uses a different endpoint for suggestions return `https://search.itunes.apple.com/WebObjects/MZSearchHints.woa/wa/hints?term=${encodeURIComponent(term)}&country=${country}`; }