view_order_history
View previously placed grocery orders from the Kroger MCP Server to track purchases and reference past transactions.
Instructions
View the history of placed orders.
Note: This tool can only see orders that were explicitly marked as placed via this MCP server.
The Kroger API does not provide permission to query the actual order history from Kroger's systems.
Args:
limit: Number of recent orders to show (1-50)
Returns:
Dictionary containing order history
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- The main handler function for the 'view_order_history' tool. Loads order history from local JSON file, sorts recent orders first, limits results, computes summary stats, and returns structured data. Includes input validation for limit (1-50). Uses helper functions like _load_order_history.@mcp.tool() async def view_order_history( limit: int = 10, ctx: Context = None ) -> Dict[str, Any]: """ View the history of placed orders. Note: This tool can only see orders that were explicitly marked as placed via this MCP server. The Kroger API does not provide permission to query the actual order history from Kroger's systems. Args: limit: Number of recent orders to show (1-50) Returns: Dictionary containing order history """ try: # Ensure limit is within bounds limit = max(1, min(50, limit)) order_history = _load_order_history() # Sort by placed_at date (most recent first) and limit sorted_orders = sorted(order_history, key=lambda x: x.get("placed_at", ""), reverse=True) limited_orders = sorted_orders[:limit] # Calculate summary stats total_orders = len(order_history) total_items_all_time = sum(order.get("item_count", 0) for order in order_history) total_quantity_all_time = sum(order.get("total_quantity", 0) for order in order_history) return { "success": True, "orders": limited_orders, "showing": len(limited_orders), "summary": { "total_orders": total_orders, "total_items_all_time": total_items_all_time, "total_quantity_all_time": total_quantity_all_time } } except Exception as e: return { "success": False, "error": f"Failed to view order history: {str(e)}" }
- src/kroger_mcp/server.py:72-78 (registration)Registration block in the main server file where cart_tools.register_tools(mcp) is called (line 74), which in turn defines and registers the view_order_history tool via @mcp.tool() decorator.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)