clear_current_cart
Clears local cart tracking to reflect changes in the Kroger cart. Use when the cart has been updated on the app/website or when local tracking is out of sync. Does not modify the actual Kroger cart.
Instructions
Clear all items from the local cart tracking only.
IMPORTANT: This tool CANNOT remove items from the actual Kroger cart in the app/website.
It only clears our local tracking. The user must remove items from their actual cart
through the Kroger app or website themselves.
Use this tool only when:
1. The user has already cleared their Kroger cart through the app/website
2. You need to update the local tracking to reflect that change
3. Or when the local tracking is out of sync with the actual cart
Returns:
Dictionary confirming the local cart tracking was cleared
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the 'clear_current_cart' tool. It is decorated with @mcp.tool() which also serves as its registration in FastMCP. The function clears the locally tracked cart by loading the cart data, emptying the current_cart list, updating the timestamp, and saving the changes. It returns a success message with the number of items cleared or an error.@mcp.tool() async def clear_current_cart(ctx: Context = None) -> Dict[str, Any]: """ Clear all items from the local cart tracking only. IMPORTANT: This tool CANNOT remove items from the actual Kroger cart in the app/website. It only clears our local tracking. The user must remove items from their actual cart through the Kroger app or website themselves. Use this tool only when: 1. The user has already cleared their Kroger cart through the app/website 2. You need to update the local tracking to reflect that change 3. Or when the local tracking is out of sync with the actual cart Returns: Dictionary confirming the local cart tracking was cleared """ try: cart_data = _load_cart_data() items_count = len(cart_data.get("current_cart", [])) cart_data["current_cart"] = [] cart_data["last_updated"] = datetime.now().isoformat() _save_cart_data(cart_data) return { "success": True, "message": f"Cleared {items_count} items from local cart tracking", "items_cleared": items_count } except Exception as e: return { "success": False, "error": f"Failed to clear cart: {str(e)}" }