gp_search
Search Google Play Store apps using keywords, country codes, and language filters to retrieve app listings and data.
Instructions
[Google Play] Search for apps
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | Yes | Search term | |
| country | No | Two-letter country code (default: us) | us |
| lang | No | Language code (default: en) | en |
| num | No | Number of results (default: 250) |
Implementation Reference
- src/server.js:571-607 (handler)The main handler function for the 'gp_search' tool. It extracts parameters from args, validates the search term, builds the Google Play search URL using buildGPSearchUrl, fetches the HTML content, parses it using parseGPSearch, and returns the structured results as JSON or an error.async function handleGPSearch(args) { try { const { term, country = 'us', lang = 'en', num = 250, } = args; if (!term) { throw new Error('term is required'); } const url = buildGPSearchUrl({ term, country, lang, num }); const html = await fetchText(url); const result = parseGPSearch(html); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: error.message }, null, 2), }, ], isError: true, }; } }
- src/server.js:1205-1233 (schema)The input schema definition for the 'gp_search' tool, specifying parameters like term (required), country, lang, and num with descriptions and defaults.{ name: 'gp_search', description: '[Google Play] Search for apps', inputSchema: { type: 'object', properties: { term: { type: 'string', description: 'Search term', }, country: { type: 'string', description: 'Two-letter country code (default: us)', default: 'us', }, lang: { type: 'string', description: 'Language code (default: en)', default: 'en', }, num: { type: 'number', description: 'Number of results (default: 250)', default: 250, }, }, required: ['term'], }, },
- src/server.js:1468-1469 (registration)The switch case in the CallToolRequestSchema handler that routes calls to the 'gp_search' tool to the handleGPSearch function.case 'gp_search': return await handleGPSearch(args);
- src/endpoints/googlePlay.js:14-31 (helper)The buildSearchUrl function (imported as buildGPSearchUrl) that constructs the Google Play search URL based on term, country, lang, and other parameters.export function buildSearchUrl(params) { const { term, country = 'us', lang = 'en', num = 250, fullDetail = false, } = params; const queryParams = new URLSearchParams({ q: term, c: 'apps', gl: country, hl: lang, }); return `${GOOGLE_PLAY_BASE}/store/search?${queryParams.toString()}`; }
- The parseSearchResults function (imported as parseGPSearch) that wraps parseSearch to return structured results with results array and count for Google Play search HTML.export function parseSearchResults(html) { const apps = parseSearch(html); return { results: apps, count: apps.length, }; }