Skip to main content
Glama

view_current_cart

View items in your local Kroger shopping cart that were added through this MCP server. Note: Cannot access actual user cart contents via Kroger API.

Instructions

View the current cart contents tracked locally. Note: This tool can only see items that were added via this MCP server. The Kroger API does not provide permission to query the actual user cart contents. Returns: Dictionary containing current cart items and summary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'view_current_cart' tool. It loads locally tracked cart data from JSON file, computes summary statistics (total items, quantities, split by pickup/delivery), and returns the cart contents and summary. Note that it only tracks items added via this MCP server, not the actual Kroger cart.
    @mcp.tool() async def view_current_cart(ctx: Context = None) -> Dict[str, Any]: """ View the current cart contents tracked locally. Note: This tool can only see items that were added via this MCP server. The Kroger API does not provide permission to query the actual user cart contents. Returns: Dictionary containing current cart items and summary """ try: cart_data = _load_cart_data() current_cart = cart_data.get("current_cart", []) # Calculate summary total_quantity = sum(item.get("quantity", 0) for item in current_cart) pickup_items = [item for item in current_cart if item.get("modality") == "PICKUP"] delivery_items = [item for item in current_cart if item.get("modality") == "DELIVERY"] return { "success": True, "current_cart": current_cart, "summary": { "total_items": len(current_cart), "total_quantity": total_quantity, "pickup_items": len(pickup_items), "delivery_items": len(delivery_items), "last_updated": cart_data.get("last_updated") } } except Exception as e: return { "success": False, "error": f"Failed to view cart: {str(e)}" }
  • Tool module registrations in the main server setup, including cart_tools.register_tools(mcp) which registers the view_current_cart tool among others.
    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)
  • Helper function to load the local cart data from 'kroger_cart.json' file, used by view_current_cart to retrieve current cart contents.
    def _load_cart_data() -> Dict[str, Any]: """Load cart data from file""" try: if os.path.exists(CART_FILE): with open(CART_FILE, 'r') as f: return json.load(f) except Exception: pass return {"current_cart": [], "last_updated": None, "preferred_location_id": None}
  • Helper function to persist cart data to JSON file, though not directly called by view_current_cart (used by other cart tools).
    """Save cart data to file""" try: with open(CART_FILE, 'w') as f: json.dump(cart_data, f, indent=2) except Exception as e: print(f"Warning: Could not save cart data: {e}")

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