Skip to main content
Glama
MiguelAlvRed

Store Scraper MCP

by MiguelAlvRed

gp_categories

Retrieve available app categories from Google Play Store to organize and filter app discovery.

Instructions

[Google Play] Get list of available categories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for 'gp_categories' tool. Fetches the Google Play apps page using buildCategoriesUrl, parses categories with parseCategories, and returns JSON with categories list and count.
    async function handleGPCategories(args) {
      try {
        const url = buildCategoriesUrl();
        const html = await fetchText(url);
        const categories = parseCategories(html);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                categories,
                count: categories.length,
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({ error: error.message }, null, 2),
            },
          ],
          isError: true,
        };
      }
    }
  • Tool schema definition in the list of tools, specifying name, description, and empty input schema (no parameters required).
      name: 'gp_categories',
      description: '[Google Play] Get list of available categories',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Dispatch registration in the CallToolRequestSchema switch statement that maps 'gp_categories' tool calls to the handleGPCategories handler.
    case 'gp_categories':
      return await handleGPCategories(args);
  • Helper function that parses HTML from Google Play to extract category IDs using regex on links and scripts, with fallback to a hardcoded list of common categories.
    export function parseCategories(html) {
      if (!html || typeof html !== 'string') {
        return [];
      }
    
      const categories = [];
    
      try {
        // Google Play categories are in navigation/dropdown menus
        // Look for category links
        const categoryLinkMatches = html.matchAll(/<a[^>]*href=["'][^"']*\/store\/apps\/category\/([^/"']+)["'][^>]*>/gi);
        
        for (const match of categoryLinkMatches) {
          const category = match[1];
          if (category && !categories.includes(category)) {
            categories.push(category);
          }
        }
    
        // Also try extracting from script tags with category data
        const scriptMatches = html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/gi);
        
        for (const match of scriptMatches) {
          const scriptContent = match[1];
          
          if (scriptContent.includes('category') || scriptContent.includes('CATEGORY')) {
            try {
              // Try to find category arrays
              const categoryArrayMatch = scriptContent.match(/categories["']?\s*:\s*\[([\s\S]*?)\]/i);
              if (categoryArrayMatch) {
                const categoryData = categoryArrayMatch[1];
                const categoryMatches = categoryData.matchAll(/"([^"]+)"/g);
                
                for (const catMatch of categoryMatches) {
                  const category = catMatch[1];
                  if (category && !categories.includes(category)) {
                    categories.push(category);
                  }
                }
              }
            } catch (e) {
              // Continue
            }
          }
        }
    
        // If no categories found, return common ones
        if (categories.length === 0) {
          return [
            'APPLICATION',
            'GAME',
            'ART_AND_DESIGN',
            'AUTO_AND_VEHICLES',
            'BEAUTY',
            'BOOKS_AND_REFERENCE',
            'BUSINESS',
            'COMICS',
            'COMMUNICATION',
            'DATING',
            'EDUCATION',
            'ENTERTAINMENT',
            'EVENTS',
            'FINANCE',
            'FOOD_AND_DRINK',
            'HEALTH_AND_FITNESS',
            'HOUSE_AND_HOME',
            'LIBRARIES_AND_DEMO',
            'LIFESTYLE',
            'MAPS_AND_NAVIGATION',
            'MEDICAL',
            'MUSIC_AND_AUDIO',
            'NEWS_AND_MAGAZINES',
            'PARENTING',
            'PERSONALIZATION',
            'PHOTOGRAPHY',
            'PRODUCTIVITY',
            'SHOPPING',
            'SOCIAL',
            'SPORTS',
            'TOOLS',
            'TRAVEL_AND_LOCAL',
            'VIDEO_PLAYERS',
            'WEATHER',
          ];
        }
    
        return categories.sort();
      } catch (error) {
        console.error('Error parsing Google Play categories:', error);
        return [];
      }
    }
  • Helper function that builds the URL for the Google Play apps store page to scrape categories from.
    export function buildCategoriesUrl() {
      return `${GOOGLE_PLAY_BASE}/store/apps`;
    }

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