Skip to main content
Glama

price_history_with_url

Retrieve price history data for a product by providing its URL. Track pricing trends over time.

Instructions

Product Price History With URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesProduct URL

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'price_history_with_url' tool. It takes a product URL, calls the PriceHistoryService.history_with_url() method, and returns a PriceHistoryToolResponse with description and graph link.
    async def price_history_with_url(
        ctx: Context,
        url: Annotated[str, Field(description="Product URL")],
    ) -> str:
        """Product Price History With URL"""
    
        logger.info("price history with url, url: %s", url)
    
        setting = get_setting(ctx)
        service = PriceHistoryService(setting)
        ret = await service.history_with_url(url=url, days="180")
        if ret is None:
            return "No price history found"
    
        return PriceHistoryToolResponse(
            price_history_description=ret.description,
            price_history_graph=f"![Price History Graph]({ret.graph_link})",
        ).slim_dump()
  • Input schema for the tool: requires a 'url' parameter (string) annotated with Pydantic Field description.
        ctx: Context,
        url: Annotated[str, Field(description="Product URL")],
    ) -> str:
        """Product Price History With URL"""
  • Response schema (PriceHistoryToolResponse) used by price_history_with_url to format output with price_history_description and price_history_graph.
    class PriceHistoryToolResponse(BaseToolResponse):
        price_history_description: PriceHistoryAPIRet
        price_history_graph: str
        display_rules: str = """
    Field explanation:
    'price_history_description': includes detailed price history info.
    'price_history_graph': includes a markdown image link used for visualizing price history.
    
    Here are a list of rules you must follow:
    Rule 1: Both 'price_history_description' and the link provided at 'price_history_graph' field must be included in the output.
    Rule 2: Product url must be included, it can be found in 'price_history_description'
        """
  • The tool is registered with the MCP server via server.add_tool(price_history_with_url) in create_server().
    server.add_tool(price_history_with_url)
  • The core service method history_with_url() that expands the URL, resolves nindex and product ID, fetches price history from the BigGo API, optionally tries an alternative nindex for Shopee products, and returns a PriceHistoryRet with description and graph link.
    async def history_with_url(self, url: str, days: DAYS) -> PriceHistoryRet | None:
        real_url = await expand_url(url)
    
        if (nindex := await get_nindex_from_url(real_url)) is None:
            logger.warning("nindex not found, url: %s", real_url)
            return
    
        if (pid := await get_pid_from_url(nindex=nindex, url=real_url)) is None:
            logger.warning(
                "product id not found, nindex: %s, url: %s", nindex, real_url
            )
            return
    
        history_id = self._get_history_id(nindex=nindex, pid=pid)
        resp = await self._get_price_history(history_id=history_id, days=int(days))
    
        if resp is None and nindex in ["tw_mall_shopeemall", "tw_bid_shopee"]:
            nindex = (
                "tw_mall_shopeemall"
                if nindex == "tw_bid_shopee"
                else "tw_mall_shopeemall"
            )
            history_id = self._get_history_id(nindex=nindex, pid=pid)
            resp = await self._get_price_history(
                history_id=history_id,
                days=int(days),
            )
    
        if resp is not None:
            graph_link = self.graph_link(history_id)
    
            # replace urls with short urls
            if self._setting.short_url_endpoint is not None:
                all_urls = resp.get_all_urls()
                all_urls.add(graph_link)
                url_map = await generate_short_url(
                    list(all_urls), self._setting.short_url_endpoint
                )
                resp.replace_urls(url_map)
                graph_link = url_map.get(graph_link, graph_link)
    
            return PriceHistoryRet(description=resp, graph_link=graph_link)
        else:
            return None
Behavior1/5

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

With no annotations, the description must disclose behavioral traits. It does not mention whether the operation is read-only, safe, or destructive, nor does it describe any side effects, authentication needs, or rate limits. The agent gets zero behavioral insight.

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

Conciseness2/5

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

The description is extremely short (5 words) but under-specified, not concise. It lacks structure and fails to provide essential information, making it inadequate for clear communication.

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

Completeness1/5

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

Despite the tool's simplicity (1 parameter, output schema present), the description is severely incomplete. It does not explain the tool's purpose, behavior, or return value, leaving significant gaps for an agent to infer.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's 'Product URL' for the 'url' parameter. It does not specify format, constraints, or examples, but the schema already covers the parameter adequately.

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

Purpose2/5

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

The description 'Product Price History With URL' is a noun phrase that merely echoes the tool name without specifying a verb or action. It does not clearly state what the tool does (e.g., retrieve, update, display), leaving the agent uncertain about its function.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus the sibling 'product_search'. There is no mention of contexts, alternatives, or when not to use it, making it hard for an agent to choose correctly.

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/Funmula-Corp/BigGo-MCP-Server'

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