get_location_details
Retrieve detailed information about a specific Kroger store location by providing its unique identifier.
Instructions
Get detailed information about a specific Kroger store location.
Args:
location_id: The unique identifier for the store location
Returns:
Dictionary containing detailed location information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location_id | Yes |
Implementation Reference
- The async handler function that implements the core logic of the get_location_details tool. It retrieves detailed store information from the Kroger API, formats departments and address, and handles errors.@mcp.tool() async def get_location_details( location_id: str, ctx: Context = None ) -> Dict[str, Any]: """ Get detailed information about a specific Kroger store location. Args: location_id: The unique identifier for the store location Returns: Dictionary containing detailed location information """ if ctx: await ctx.info(f"Getting details for location {location_id}") client = get_client_credentials_client() try: location_details = client.location.get_location(location_id) if not location_details or "data" not in location_details: return { "success": False, "message": f"Location {location_id} not found" } loc = location_details["data"] # Format department information departments = [] for dept in loc.get("departments", []): dept_info = { "department_id": dept.get("departmentId"), "name": dept.get("name"), "phone": dept.get("phone") } # Add department hours if "hours" in dept and "monday" in dept["hours"]: monday = dept["hours"]["monday"] if monday.get("open24", False): dept_info["hours_monday"] = "Open 24 hours" elif "open" in monday and "close" in monday: dept_info["hours_monday"] = f"{monday['open']} - {monday['close']}" departments.append(dept_info) # Format the response address = loc.get("address", {}) result = { "success": True, "location_id": loc.get("locationId"), "name": loc.get("name"), "chain": loc.get("chain"), "phone": loc.get("phone"), "address": { "street": address.get("addressLine1", ""), "street2": address.get("addressLine2", ""), "city": address.get("city", ""), "state": address.get("state", ""), "zip_code": address.get("zipCode", "") }, "coordinates": loc.get("geolocation", {}), "departments": departments, "department_count": len(departments) } return result except Exception as e: if ctx: await ctx.error(f"Error getting location details: {str(e)}") return { "success": False, "error": str(e) }
- src/kroger_mcp/server.py:72-72 (registration)The registration call that adds the location_tools (including get_location_details) to the MCP server instance.location_tools.register_tools(mcp)