Skip to main content
Glama

product_search

Search for products across e-commerce platforms using natural language queries to find items, compare prices, and access detailed specifications.

Instructions

Product Search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function 'product_search' that executes the tool logic by calling ProductSearchService and returning a formatted JSON response.
    async def product_search(
        ctx: Context,
        query: Annotated[
            str,
            Field(
                description="""Search query""",
                examples=["iphone", "護唇膏"],
            ),
        ],
    ) -> str:
        """Product Search"""
        logger.info("product search, query: %s", query)
    
        setting = get_setting(ctx)
        service = ProductSearchService(setting)
        ret = await service.search(query)
    
        return ProductSearchToolResponse(product_search_result=ret).slim_dump()
  • Registration of the 'product_search' tool handler on the BigGoMCPServer instance.
    # Product Search
    server.add_tool(product_search)
  • Output schema for the product_search tool: ProductSearchToolResponse Pydantic model wrapping the API result with additional fields.
    class ProductSearchToolResponse(BaseToolResponse):
        product_search_result: ProductSearchAPIRet
        reason: str | None = None
        display_rules: str | None = None
    
        @model_validator(mode="after")
        def post_init(self) -> Self:
            if len(self.product_search_result.list) == 0:
                self.reason = """
    No results found. Possible reasons:
    1. This search is much more complex than a simple product search.
    2. The user is asking things related to product specifications.
    
    If the problems might be related to the points listed above,
    please use the 'spec_search' tool and try again.
                """
                return self
    
            # add display rules if result is not empty
            else:
                self.display_rules = """
    As a product researcher, you need to find the most relavent product and present them in utmost detail.
    Without following the rules listed bellow, the output will become useless, you must follow the rules before responding to the user.
    All rules must be followed strictly.
    
    Here are a list of rules you must follow:
    Rule 1: Product image must be included when available, url is located in each object inside 'specs.images' field.
    Rule 2: If no avaliable image exist, ignore the image field completely, don't even write anything image related for that single product.
    Rule 3: Product urls must be included so that the user can by the product with a simple click if possible.
    Rule 4: Display more then one relavent product if possible, having multiple choices is a good thing.
                """
    
            return self
  • Core data schema: ProductSearchAPIRet Pydantic model defining the structure of the BigGo product search API response.
    class ProductSearchAPIRet(BaseModel):
        # result: bool
        # total: int
        # total_page: int
        # pure_total: int
        # ec_count: int
        # mall_count: int
        # bid_count: int
        # size: int
        # took: int
        # is_shop: bool
        # is_suggest_query: bool
        # is_ypa: bool
        # is_adsense: bool
        # q_suggest: str
        # arr_suggest: List[str]
        # offline_count: int
        # spam_count: int
        # promo: List
        # filter: Dict[str, Any]
        # top_ad_count: int
        # group: Any
        # recommend_group: List
        list: List[ListItem] = Field(default_factory=list)
        # biggo_c: List[BiggoCItem]
        low_price: float = 0
        high_price: float = 0
  • Helper service class ProductSearchService that handles the HTTP request to BigGo API, validates response, generates links, and optionally shortens URLs.
    class ProductSearchService:
        def __init__(self, setting: BigGoMCPSetting):
            self._setting = setting
    
        async def search(self, query: str) -> ProductSearchAPIRet:
            url = f"https://api.biggo.com/api/v1/spa/search/{query}/product"
    
            headers = {
                "Content-Type": "application/json",
                "site": self._setting.domain.value,
                "region": self._setting.region.value.lower(),
            }
            logger.debug("product search, url: %s, headers: %s", url, headers)
    
            async with ClientSession() as session:
                async with session.get(url, headers=headers) as resp:
                    if resp.status >= 400:
                        err_msg = f"product search api error: {await resp.text()}"
                        logger.error(err_msg)
                        raise ValueError(err_msg)
    
                    data = ProductSearchAPIRet.model_validate(await resp.json())
    
            data.generate_r_link(self._setting.domain)
    
            if self._setting.short_url_endpoint is not None:
                all_urls = data.get_all_urls()
                url_map = await generate_short_url(
                    list(all_urls), self._setting.short_url_endpoint
                )
                data.replace_urls(url_map)
    
            return data
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Product Search' reveals nothing about the tool's behavior—such as whether it's read-only, requires authentication, has rate limits, or what it returns. This is inadequate for a tool with no annotation support.

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?

While concise with only two words, the description is under-specified and fails to provide necessary information. Conciseness should not come at the cost of clarity; this lacks structure and front-loading of key details, making it inefficient for agent understanding.

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

Completeness2/5

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

Given the lack of annotations and a minimal description, the tool is incomplete for effective use. Although an output schema exists (which reduces the need to explain return values), the description does not cover purpose, usage, or behavior, leaving significant gaps in context.

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?

The description adds no parameter semantics beyond what the input schema provides. However, schema description coverage is 100%, documenting the single 'query' parameter adequately. With no parameters mentioned in the description, the baseline score of 3 is appropriate as the schema handles the heavy lifting.

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 Search' is a tautology that restates the tool name without adding meaningful context. It lacks a specific verb or resource details, failing to clarify what the tool actually does beyond the obvious implication from the name. No differentiation from sibling tools is provided.

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

Usage Guidelines1/5

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

The description provides no guidance on when to use this tool versus alternatives. There is no mention of context, prerequisites, or comparison with the sibling tool 'price_history_with_url', leaving the agent with no usage instructions.

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