Price History Link (Keepa)
price_history_linkBuilds a Keepa price history URL for any Amazon.in ASIN, providing offline access to historical price charts.
Instructions
Build a Keepa.com price-history URL for an amazon.in ASIN. No network call.
Keepa renders historical price charts in the browser using the format keepa.com/#!product/12-, where 12 is the amazon.in domain code. This tool is offline — just a deterministic URL builder.
Args:
asin_or_url (string): plain ASIN or amazon.in URL containing /dp/
Returns: JSON { "asin": string, "price_history_url": string }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asin_or_url | Yes | ASIN or amazon.in URL — Keepa link is built for the amazon.in domain |
Implementation Reference
- src/index.ts:331-350 (handler)The handler function for the price_history_link tool. Extracts ASIN from input, builds Keepa URL via keepaUrl(), and returns the result.
async (params) => { const asin = extractAsinFromUrl(params.asin_or_url.trim()); if (!asin) { return { content: [ { type: "text", text: "Error: Could not extract ASIN. Pass a 10-character ASIN or an amazon.in URL containing /dp/<ASIN>.", }, ], }; } const output = { asin, price_history_url: keepaUrl(asin) }; return { content: [{ type: "text", text: JSON.stringify(output, null, 2) }], structuredContent: output, }; } ); - src/index.ts:136-144 (schema)Zod schema for price_history_link input: requires a single 'asin_or_url' string (10-2048 chars).
const PriceHistoryInputSchema = z .object({ asin_or_url: z .string() .min(10) .max(2048) .describe("ASIN or amazon.in URL — Keepa link is built for the amazon.in domain"), }) .strict(); - src/index.ts:307-350 (registration)Registration of the 'price_history_link' tool on the MCP server with input schema and annotations.
server.registerTool( "price_history_link", { title: "Price History Link (Keepa)", description: `Build a Keepa.com price-history URL for an amazon.in ASIN. No network call. Keepa renders historical price charts in the browser using the format keepa.com/#!product/12-<ASIN>, where 12 is the amazon.in domain code. This tool is offline — just a deterministic URL builder. Args: - asin_or_url (string): plain ASIN or amazon.in URL containing /dp/<ASIN> Returns: JSON { "asin": string, "price_history_url": string }`, inputSchema: PriceHistoryInputSchema.shape, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async (params) => { const asin = extractAsinFromUrl(params.asin_or_url.trim()); if (!asin) { return { content: [ { type: "text", text: "Error: Could not extract ASIN. Pass a 10-character ASIN or an amazon.in URL containing /dp/<ASIN>.", }, ], }; } const output = { asin, price_history_url: keepaUrl(asin) }; return { content: [{ type: "text", text: JSON.stringify(output, null, 2) }], structuredContent: output, }; } ); - src/parse.ts:20-22 (helper)The keepaUrl() helper that builds the Keepa.com price-history URL using KEEPA_DOMAIN_CODE (12 for amazon.in).
export function keepaUrl(asin: string): string { return `https://keepa.com/#!product/${KEEPA_DOMAIN_CODE}-${asin}`; } - src/parse.ts:41-45 (helper)The extractAsinFromUrl() helper that extracts a 10-char ASIN from plain input or amazon.in URL.
export function extractAsinFromUrl(input: string): string | undefined { if (ASIN_REGEX.test(input)) return input; const match = input.match(ASIN_FROM_URL_REGEX); return match?.[1]?.toUpperCase(); }