walmart_product
Retrieve parsed product details from Walmart by providing a product ID. Optionally enable JavaScript rendering, set delivery ZIP code, or specify store ID for local inventory.
Instructions
Scrape Walmart Product page with automatic parsing
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | Walmart product ID (e.g., "15296401808") | |
| jsRender | No | Should the request be opened in a headless browser, false by default | |
| deliveryZip | No | ZIP code for delivery location | |
| storeId | No | Walmart store ID for local inventory |
Implementation Reference
- The anonymous async function inside registerTool() that executes the tool logic: builds params with target WALMART_PRODUCT, calls sapiClient.scrape(), applies transformResponse, and returns formatted content.
async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.WALMART_PRODUCT, parse: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); const { data: text } = this.transformResponse({ data }); return { content: [ { type: 'text', text, }, ], }; } - src/tools/walmart-product/walmart-product-tool.ts:31-67 (registration)The register() method of WalmartProductTool which calls server.registerTool with name 'walmart_product', inputSchema, and the handler function. This registers the tool on the MCP server.
register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'walmart_product', { description: 'Scrape Walmart Product page with automatic parsing', inputSchema: { product_id: z.string().describe('Walmart product ID (e.g., "15296401808")'), jsRender: zodJsRender, deliveryZip: zodDeliveryZip, storeId: zodStoreId, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.WALMART_PRODUCT, parse: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); const { data: text } = this.transformResponse({ data }); return { content: [ { type: 'text', text, }, ], }; } ); - Input schema definition for walmart_product: product_id (required string), jsRender, deliveryZip (optional), storeId (optional).
{ description: 'Scrape Walmart Product page with automatic parsing', inputSchema: { product_id: z.string().describe('Walmart product ID (e.g., "15296401808")'), jsRender: zodJsRender, deliveryZip: zodDeliveryZip, storeId: zodStoreId, }, - transformResponse method that strips high-char-count fields ('specifications', 'breadcrumbs') from the scraped data using removeKeyFromNestedObject, then stringifies the result.
transformResponse = ({ data }: { data: object }) => { for (const fieldToRemove of WalmartProductTool.FIELDS_WITH_HIGH_CHAR_COUNT) { data = removeKeyFromNestedObject({ obj: data, keyToRemove: fieldToRemove }); } return { data: JSON.stringify(data) }; }; - src/server/sapi-base-server.ts:80-80 (registration)Instantiation of WalmartProductTool in the allTools array on ScraperAPIBaseServer - adds the tool to the list of available tools for registration.
new WalmartProductTool(),