Skip to main content
Glama

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
NameRequiredDescriptionDefault
termYesSearch term to get suggestions for
countryNoTwo-letter country code (default: us)us

Implementation Reference

  • 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, }; } }
  • 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'], }, },
  • 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)); }
  • 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}`; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MiguelAlvRed/mobile-store-scraper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server