Skip to main content
Glama
CupOfOwls

Kroger MCP Server

get_product_details

Retrieve detailed product information including pricing and availability from Kroger stores using product and location identifiers.

Instructions

    Get detailed information about a specific product.
    
    Args:
        product_id: The unique product identifier
        location_id: Store location ID for pricing/availability (uses preferred if not provided)
    
    Returns:
        Dictionary containing detailed product information
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idYes
location_idNo

Implementation Reference

  • The handler function that implements the get_product_details tool. It fetches product details from the Kroger API, formats pricing, aisle locations, images, and other information.
    @mcp.tool()
    async def get_product_details(
        product_id: str,
        location_id: Optional[str] = None,
        ctx: Context = None
    ) -> Dict[str, Any]:
        """
        Get detailed information about a specific product.
        
        Args:
            product_id: The unique product identifier
            location_id: Store location ID for pricing/availability (uses preferred if not provided)
        
        Returns:
            Dictionary containing detailed product information
        """
        # Use preferred location if none provided
        if not location_id:
            location_id = get_preferred_location_id()
            if not location_id:
                return {
                    "success": False,
                    "error": "No location_id provided and no preferred location set. Use set_preferred_location first."
                }
        
        if ctx:
            await ctx.info(f"Getting details for product {product_id} at location {location_id}")
        
        client = get_client_credentials_client()
        
        try:
            product_details = client.product.get_product(
                product_id=product_id,
                location_id=location_id
            )
            
            if not product_details or "data" not in product_details:
                return {
                    "success": False,
                    "message": f"Product {product_id} not found"
                }
            
            product = product_details["data"]
            
            # Format the detailed product information
            result = {
                "success": True,
                "product_id": product.get("productId"),
                "upc": product.get("upc"),
                "description": product.get("description"),
                "brand": product.get("brand"),
                "categories": product.get("categories", []),
                "country_origin": product.get("countryOrigin"),
                "temperature": product.get("temperature", {}),
                "location_id": location_id
            }
            
            # Add detailed item information
            if "items" in product and product["items"]:
                item = product["items"][0]
                result["item_details"] = {
                    "size": item.get("size"),
                    "sold_by": item.get("soldBy"),
                    "inventory": item.get("inventory", {}),
                    "fulfillment": item.get("fulfillment", {})
                }
                
                # Add detailed pricing
                if "price" in item:
                    price = item["price"]
                    result["pricing"] = {
                        "regular_price": price.get("regular"),
                        "sale_price": price.get("promo"),
                        "regular_per_unit": price.get("regularPerUnitEstimate"),
                        "formatted_regular": format_currency(price.get("regular")),
                        "formatted_sale": format_currency(price.get("promo")),
                        "on_sale": price.get("promo") is not None and price.get("promo") < price.get("regular", float('inf')),
                        "savings": price.get("regular", 0) - price.get("promo", price.get("regular", 0)) if price.get("promo") else 0
                    }
            
            # Add aisle locations
            if "aisleLocations" in product:
                result["aisle_locations"] = [
                    {
                        "description": aisle.get("description"),
                        "aisle_number": aisle.get("number"),
                        "side": aisle.get("side"),
                        "shelf_number": aisle.get("shelfNumber")
                    }
                    for aisle in product["aisleLocations"]
                ]
            
            # Add images
            if "images" in product and product["images"]:
                result["images"] = [
                    {
                        "perspective": img.get("perspective"),
                        "sizes": [
                            {
                                "size": size.get("size"),
                                "url": size.get("url")
                            }
                            for size in img.get("sizes", [])
                        ]
                    }
                    for img in product["images"]
                ]
            
            return result
            
        except Exception as e:
            if ctx:
                await ctx.error(f"Error getting product details: {str(e)}")
            return {
                "success": False,
                "error": str(e)
            }
  • Registration of all tool modules, including product_tools.register_tools(mcp) which registers the get_product_details tool.
    # Register all tools from the modules
    location_tools.register_tools(mcp)
    product_tools.register_tools(mcp)
    cart_tools.register_tools(mcp)
    info_tools.register_tools(mcp)
    profile_tools.register_tools(mcp)
    utility_tools.register_tools(mcp)
    auth_tools.register_tools(mcp)
  • The register_tools function in product_tools.py that defines and registers the get_product_details tool along with other product tools.
    def register_tools(mcp):
        """Register product-related tools with the FastMCP server"""
        
        @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions that location_id uses a 'preferred' default if not provided, which adds some context, but fails to describe authentication requirements, rate limits, error conditions, or what 'detailed information' specifically includes. For a read operation with zero annotation coverage, this is insufficient.

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

Conciseness5/5

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

The description is well-structured with clear sections for Args and Returns. Every sentence adds value: the purpose statement, two parameter explanations, and return format. No wasted words or redundancy.

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

Completeness3/5

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

Given no annotations and no output schema, the description provides basic parameter semantics and return format but lacks details about authentication, error handling, or what specific fields the 'dictionary' contains. For a product details tool with 2 parameters, this is minimally adequate but leaves significant gaps.

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?

The description provides meaningful explanations for both parameters: product_id as 'unique product identifier' and location_id with its default behavior. With 0% schema description coverage, this fully compensates by adding semantic context that the bare schema lacks, though it doesn't specify format constraints like string patterns.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'detailed information about a specific product', making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_product_images' or 'search_products_by_id', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'search_products_by_id' or 'get_product_images'. It mentions a default behavior for location_id but doesn't explain when this tool is preferred over other product-related tools.

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/CupOfOwls/kroger-mcp'

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