Skip to main content
Glama

Get Amazon.in Product Detail

get_product
Read-onlyIdempotent

Retrieve detailed Amazon.in product information including price, MRP, discount, rating, reviews, and availability. Provide an ASIN or product URL to get structured data.

Instructions

Fetch a single amazon.in product's details by ASIN or URL.

Scrapes the product page and returns price, MRP, discount %, rating, review count, availability, bullets, brand, seller, delivery info, and a Keepa price-history URL.

Args:

  • asin_or_url (string): plain 10-char ASIN (e.g., "B0BDHWDR12") or any amazon.in product URL containing /dp/

Returns: JSON with schema: { "asin": string, "title": string, "url": string, "image": string, "price_inr": number, "price_display": string, "mrp_inr": number, "discount_percent": number, "rating": number, "review_count": number, "in_stock": boolean, "availability": string, "bullets": string[], "brand": string, "seller": string, "delivery": string, "price_history_url": string }

Error handling:

  • "Could not extract ASIN" → input was not a valid ASIN or amazon.in URL

  • "Bot-check page" → retry after a delay

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
asin_or_urlYesAmazon.in ASIN (10 chars) or any product URL containing /dp/<ASIN>

Implementation Reference

  • The async handler function for the 'get_product' tool. It extracts an ASIN from input (via extractAsinFromUrl), fetches the product page HTML (via fetchHtml), parses it into a ProductDetail object (via parseProduct), and returns the result as JSON.
    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 (e.g., B0BDHWDR12) or an amazon.in URL containing /dp/<ASIN>.",
            },
          ],
        };
      }
      try {
        const url = `${AMAZON_BASE}/dp/${asin}`;
        const html = await fetchHtml(url);
        const product = parseProduct(html, asin);
        const text = JSON.stringify(product, null, 2);
        return {
          content: [{ type: "text", text: truncate(text, product) }],
          structuredContent: product as unknown as Record<string, unknown>,
        };
      } catch (err) {
        return { content: [{ type: "text", text: friendlyError(err) }] };
      }
    }
  • Zod schema defining the input for get_product: a single string field 'asin_or_url' (10-2048 chars) that accepts either a plain ASIN or an amazon.in URL containing /dp/<ASIN>.
    const GetProductInputSchema = z
      .object({
        asin_or_url: z
          .string()
          .min(10)
          .max(2048)
          .describe("Amazon.in ASIN (10 chars) or any product URL containing /dp/<ASIN>"),
      })
      .strict();
  • src/index.ts:234-303 (registration)
    Registration of the 'get_product' tool with the MCP server, including title, description, input schema (GetProductInputSchema.shape), annotations, and the handler callback.
    server.registerTool(
      "get_product",
      {
        title: "Get Amazon.in Product Detail",
        description: `Fetch a single amazon.in product's details by ASIN or URL.
    
    Scrapes the product page and returns price, MRP, discount %, rating, review count, availability, bullets, brand, seller, delivery info, and a Keepa price-history URL.
    
    Args:
      - asin_or_url (string): plain 10-char ASIN (e.g., "B0BDHWDR12") or any amazon.in product URL containing /dp/<ASIN>
    
    Returns: JSON with schema:
      {
        "asin": string,
        "title": string,
        "url": string,
        "image": string,
        "price_inr": number,
        "price_display": string,
        "mrp_inr": number,
        "discount_percent": number,
        "rating": number,
        "review_count": number,
        "in_stock": boolean,
        "availability": string,
        "bullets": string[],
        "brand": string,
        "seller": string,
        "delivery": string,
        "price_history_url": string
      }
    
    Error handling:
      - "Could not extract ASIN" → input was not a valid ASIN or amazon.in URL
      - "Bot-check page" → retry after a delay`,
        inputSchema: GetProductInputSchema.shape,
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true,
        },
      },
      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 (e.g., B0BDHWDR12) or an amazon.in URL containing /dp/<ASIN>.",
              },
            ],
          };
        }
        try {
          const url = `${AMAZON_BASE}/dp/${asin}`;
          const html = await fetchHtml(url);
          const product = parseProduct(html, asin);
          const text = JSON.stringify(product, null, 2);
          return {
            content: [{ type: "text", text: truncate(text, product) }],
            structuredContent: product as unknown as Record<string, unknown>,
          };
        } catch (err) {
          return { content: [{ type: "text", text: friendlyError(err) }] };
        }
      }
    );
  • The parseProduct() function that parses the product HTML into a ProductDetail object, extracting title, prices, MRP, discount, rating, review count, availability, feature bullets, brand, seller, and delivery info.
    export function parseProduct(html: string, asin: string): ProductDetail {
      const $: CheerioAPI = cheerio.load(html);
    
      const title =
        firstText($("#productTitle")) ||
        firstText($("h1#title span")) ||
        "Unknown product";
    
      const prices = extractProductPrices($);
      const ratings = extractProductRating($);
      const stock = extractAvailability($, typeof prices.priceInr === "number");
      const sellerInfo = extractSellerInfo($);
    
      const detail: ProductDetail = {
        asin,
        title,
        url: withAffiliateTag(`${AMAZON_BASE}/dp/${asin}`),
        in_stock: stock.inStock,
        bullets: extractBullets($),
        price_history_url: keepaUrl(asin),
      };
    
      const image = extractProductImage($);
      if (image) detail.image = image;
      if (prices.priceText) detail.price_display = prices.priceText;
      if (typeof prices.priceInr === "number") detail.price_inr = prices.priceInr;
      if (typeof prices.mrpInr === "number") detail.mrp_inr = prices.mrpInr;
      if (typeof prices.discountPercent === "number") detail.discount_percent = prices.discountPercent;
      if (typeof ratings.rating === "number") detail.rating = ratings.rating;
      if (typeof ratings.reviewCount === "number") detail.review_count = ratings.reviewCount;
      if (stock.availability) detail.availability = stock.availability;
      if (sellerInfo.brand) detail.brand = sellerInfo.brand;
      if (sellerInfo.seller) detail.seller = sellerInfo.seller;
      if (sellerInfo.delivery) detail.delivery = sellerInfo.delivery;
    
      return detail;
    }
  • The extractAsinFromUrl() helper that validates and extracts an ASIN from either a raw 10-character ASIN string or an amazon.in URL containing /dp/<ASIN>.
    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();
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, openWorldHint. The description adds behavioral details: it scrapes the page, returns specific fields, and mentions error handling for bot checks and invalid inputs. This adds value beyond annotations without contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is fairly long but well-structured: a one-line summary, then parameter details, return schema, and error handling. It is front-loaded with purpose but could trim the full return schema if an output schema existed. Overall, it is organized and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description fully compensates by listing all return fields, parameter details, and error handling. For a tool with one parameter and moderate complexity, this is comprehensively complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds useful context: it explains the parameter can be a plain 10-char ASIN or any amazon.in URL containing '/dp/<ASIN>', with examples. This enhances understanding beyond the schema's minimal description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Fetch a single amazon.in product's details by ASIN or URL.' It names the verb 'fetch', the resource 'product details', and the input method. This distinguishes it from siblings like 'search_amazon_in' (which searches) and 'price_history_link' (which fetches a link).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context: when you need detailed product info for a specific ASIN or URL. It does not explicitly state when not to use or compare with siblings, but it includes error handling hints that guide usage. The context is clear, but lacks explicit exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/justadityaraj/amazon-in-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server