Files
temporal-ai-agent/tools/food/add_to_cart.py
Steve Androulakis 5d55a9fe80 Model Context Protocol (MCP) support with new use case (#42)
* initial mcp

* food ordering with mcp

* prompt eng

* splitting out goals and updating docs

* a diff so I can get tests from codex

* a diff so I can get tests from codex

* oops, missing files

* tests, file formatting

* readme and setup updates

* setup.md link fixes

* readme change

* readme change

* readme change

* stripe food setup script

* single agent mode default

* prompt engineering for better multi agent performance

* performance should be greatly improved

* Update goals/finance.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update activities/tool_activities.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* co-pilot PR suggested this change, and now fixed it

* stronger wording around json format response

* formatting

* moved docs to dir

* moved image assets under docs

* cleanup env example, stripe guidance

* cleanup

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-09 16:39:57 -07:00

34 lines
1.2 KiB
Python

def add_to_cart(args: dict) -> dict:
"""
Simple stateless cart tool for demo purposes.
In production, this would use proper session storage or database.
"""
customer_email = args.get("customer_email")
item_name = args.get("item_name")
item_price = float(args.get("item_price", 0))
quantity = int(args.get("quantity", 1))
stripe_product_id = args.get("stripe_product_id")
# Basic validation
if not customer_email:
return {"error": "Customer email is required"}
if not item_name:
return {"error": "Item name is required"}
if item_price <= 0:
return {"error": "Item price must be greater than 0"}
if quantity <= 0:
return {"error": "Quantity must be greater than 0"}
# For demo purposes, just acknowledge the addition
# In a real system, this would store to session/database
return {
"status": "success",
"message": f"Added {quantity} x {item_name} (${item_price}) to cart for {customer_email}",
"item_added": {
"name": item_name,
"price": item_price,
"quantity": quantity,
"stripe_product_id": stripe_product_id,
},
}