amazon_pricing
Scrape Amazon product pricing by ASIN and automatically parse results. Supports multiple domains, device types, geolocation, and pagination.
Instructions
Scrape Amazon Product pricing information with automatic parsing
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Amazon product ASIN (e.g., "B09H74FXNW") | |
| jsRender | No | Should the request be opened in a headless browser, false by default | |
| domain | No | Amazon domain (e.g., amazon.com, amazon.co.uk) | |
| deviceType | No | Device type to emulate for the request | |
| pageFrom | No | Starting page number for pagination | |
| geo | No | Amazon geo location (e.g., 10001 for US ZIP code) |
Implementation Reference
- The async handler function that executes the Amazon pricing scrape. It builds params with target 'amazon_pricing', calls sapiClient.scrape(), transforms the response (removing 'seller_link' fields), and returns the result as text content.
async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.AMAZON_PRICING, 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 for the amazon_pricing tool: requires query (ASIN string), optional jsRender, domain, deviceType, pageFrom, and geo fields.
description: 'Scrape Amazon Product pricing information with automatic parsing', inputSchema: { query: z.string().describe('Amazon product ASIN (e.g., "B09H74FXNW")'), jsRender: zodJsRender, domain: zodDomain, deviceType: zodDeviceType, pageFrom: zodPageFrom, geo: zodGeo, }, - src/tools/amazon-pricing/amazon-pricing-tool.ts:36-75 (registration)Registration call to server.registerTool('amazon_pricing', ...) with the description, inputSchema, annotations, and handler callback.
register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'amazon_pricing', { description: 'Scrape Amazon Product pricing information with automatic parsing', inputSchema: { query: z.string().describe('Amazon product ASIN (e.g., "B09H74FXNW")'), jsRender: zodJsRender, domain: zodDomain, deviceType: zodDeviceType, pageFrom: zodPageFrom, geo: zodGeo, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.AMAZON_PRICING, 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/server/sapi-base-server.ts:113-117 (registration)registerAllTools() iterates all tools in allTools (including AmazonPricingTool) and calls tool.register().
registerAllTools() { for (const tool of ScraperAPIBaseServer.allTools) { tool.register({ server: this.server, sapiClient: this.sapiClient, auth: this.auth }); } } - transformResponse helper that removes seller_link fields (high character count) from the scraped data using removeKeyFromNestedObject utility.
transformResponse = ({ data }: { data: object }) => { for (const fieldToRemove of AmazonPricingTool.FIELDS_WITH_HIGH_CHAR_COUNT) { data = removeKeyFromNestedObject({ obj: data, keyToRemove: fieldToRemove }); } return { data: JSON.stringify(data) }; };