Skip to main content
Glama
MiguelAlvRed

Store Scraper MCP

by MiguelAlvRed

gp_suggest

Retrieves Google Play Store search suggestions and autocomplete results for specified terms, countries, and languages.

Instructions

[Google Play] Get search suggestions/autocomplete

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
termYesSearch term to get suggestions for
countryNoTwo-letter country code (default: us)us
langNoLanguage code (default: en)en

Implementation Reference

  • The main handler function that implements the gp_suggest tool. It validates input, builds the Google Play suggest API URL, fetches and parses the response, then formats and returns the suggestions.
    async function handleGPSuggest(args) {
      try {
        const { term, country = 'us', lang = 'en' } = args;
    
        if (!term) {
          throw new Error('term is required');
        }
    
        const url = buildGPSuggestUrl({ term, country, lang });
        const data = await fetchJSON(url);
        const suggestions = parseGPSuggest(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,
        };
      }
    }
  • Tool registration in the ListTools handler, defining name, description, and input schema for gp_suggest.
    {
      name: 'gp_suggest',
      description: '[Google Play] Get search suggestions/autocomplete',
      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',
          },
          lang: {
            type: 'string',
            description: 'Language code (default: en)',
            default: 'en',
          },
        },
        required: ['term'],
      },
    },
  • Input schema definition for the gp_suggest tool, specifying parameters and validation rules.
    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',
        },
        lang: {
          type: 'string',
          description: 'Language code (default: en)',
          default: 'en',
        },
      },
      required: ['term'],
    },
  • Helper function to parse the JSON response from Google Play suggest API into an array of suggestion objects with term and priority.
    export function parseSuggest(data) {
      if (!data) {
        return [];
      }
    
      const suggestions = [];
    
      try {
        let jsonData;
        
        if (typeof data === 'string') {
          jsonData = JSON.parse(data);
        } else {
          jsonData = data;
        }
    
        // Google Play suggest API returns suggestions in various formats
        if (Array.isArray(jsonData)) {
          jsonData.forEach(item => {
            if (typeof item === 'string') {
              suggestions.push({ term: item });
            } else if (item.suggestion || item.term || item.q) {
              suggestions.push({
                term: item.suggestion || item.term || item.q,
                priority: item.priority || 0,
              });
            }
          });
        } else if (jsonData.suggestions || jsonData.data) {
          const suggestList = jsonData.suggestions || jsonData.data || [];
          suggestList.forEach(item => {
            suggestions.push({
              term: item.suggestion || item.term || item.q || item,
              priority: item.priority || 0,
            });
          });
        } else if (jsonData.q) {
          // Single suggestion
          suggestions.push({
            term: jsonData.q,
            priority: jsonData.priority || 0,
          });
        }
    
        return suggestions.sort((a, b) => (b.priority || 0) - (a.priority || 0));
      } catch (error) {
        console.error('Error parsing Google Play suggestions:', error);
        return [];
      }
    }
  • Helper function that constructs the Google Play suggest API URL based on term, country, and lang parameters.
    export function buildSuggestUrl(params) {
      const { term, country = 'us', lang = 'en' } = params;
      
      if (!term) {
        throw new Error('term is required');
      }
    
      // Google Play uses a different endpoint for suggestions
      return `https://market.android.com/suggest/SuggRequest?json=1&c=3&query=${encodeURIComponent(term)}&gl=${country}&hl=${lang}`;
    }

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