Skip to main content
Glama
CupOfOwls

Kroger MCP Server

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}")
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a read-only operation (implied by 'View'), has a specific data scope (local tracking only), and returns a dictionary with items and summary. However, it doesn't mention potential errors, performance, or data freshness, leaving some gaps.

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 highly concise and well-structured: a brief purpose statement, a critical note on limitations, and a clear returns section. Every sentence adds essential information without waste, and it's front-loaded with the core functionality.

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

Completeness4/5

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

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is largely complete: it explains what the tool does, its limitations, and return format. However, without an output schema, more detail on the dictionary structure (e.g., keys, data types) could enhance completeness, though the summary suffices for basic use.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, maintaining focus on the tool's purpose and output. A baseline of 4 is applied since no parameters exist, and the description adds value elsewhere without redundancy.

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

Purpose5/5

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

The description clearly states the specific action ('View') and resource ('current cart contents tracked locally'), distinguishing it from sibling tools like 'add_items_to_cart' or 'remove_from_cart'. It explicitly notes the limitation to items added via the MCP server, which further clarifies its scope.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool vs. alternatives: it states 'This tool can only see items that were added via this MCP server' and contrasts with the Kroger API's inability to query actual user cart contents. This clearly defines its use case and limitations compared to external systems.

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