tiktok_shop_product
Retrieve product data from TikTok Shop using a product ID. Supports headless rendering, device emulation, and country-specific requests.
Instructions
Scrape TikTok Shop Product page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | TikTok Shop product ID (e.g., "1731541214379741272") | |
| jsRender | No | Should the request be opened in a headless browser, false by default | |
| deviceType | No | Device type to emulate for the request | |
| country | No | Country code for the request (e.g., US, GB, DE) |
Implementation Reference
- The handler function (lines 31-48) that executes the tool logic: it takes scraping params, sets the target to TIKTOK_SHOP_PRODUCT, calls sapiClient.scrape(), and returns the data as text content.
async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.TIKTOK_SHOP_PRODUCT, markdown: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } ); }; - Input schema definition for the tool, accepting product_id (string), jsRender, deviceType, and country.
inputSchema: { product_id: z.string().describe('TikTok Shop product ID (e.g., "1731541214379741272")'), jsRender: zodJsRender, deviceType: zodDeviceType, country: zodCountry, }, - Registration of the tool named 'tiktok_shop_product' on the MCP server via server.registerTool().
register = ({ server, sapiClient, auth }: ToolRegistrationArgs) => { server.registerTool( 'tiktok_shop_product', { description: 'Scrape TikTok Shop Product page', inputSchema: { product_id: z.string().describe('TikTok Shop product ID (e.g., "1731541214379741272")'), jsRender: zodJsRender, deviceType: zodDeviceType, country: zodCountry, }, annotations: { readOnlyHint: true, openWorldHint: true, }, }, async (scrapingParams: ScrapingMCPParams, extra: ProgressExtra) => { const params = { ...scrapingParams, target: SCRAPER_API_TARGETS.TIKTOK_SHOP_PRODUCT, markdown: true, } satisfies ScraperAPIParams; const { data } = await sapiClient.scrape<object>({ auth, scrapingParams: params, extra }); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } ); - src/server/sapi-base-server.ts:85-85 (registration)Tool instantiation (new TiktokShopProductTool()) in the allTools static array, which is later iterated over to register all tools.
new TiktokShopProductTool(), - src/constants.ts:31-31 (helper)Constant definition SCRAPER_API_TARGETS.TIKTOK_SHOP_PRODUCT = 'tiktok_shop_product' used to set the API target.
TIKTOK_SHOP_PRODUCT = 'tiktok_shop_product',