When I send a request to the Shopify Storefront MCP endpoint, the cart does not get updated.
Please use the code below with my dummy store to reproduce the issue.
Additionally, the checkout URL isn’t working because the total cart quantity remains 0.
The request returns a 200 status code, but the cart remains empty afterward.
import requests
import json
# Basic setup for Storefront MCP server requests
store_domain = "shopchatmcp.myshopify.com" # 🔸 Replace with your store domain
mcp_endpoint = f"https://{store_domain}/api/mcp"
# Prepare the JSON-RPC payload for updating cart
payload = {
"jsonrpc": "2.0",
"method": "tools/call",
"id": 1,
"params": {
"name": "update_cart",
"arguments": {
# "cart_id": "gid://shopify/Cart/abc123def456", # existing cart ID (optional)
"lines": [
{
# "line_item_id": "gid://shopify/CartLine/line2", # optional if adding new item
"merchandise_id": "gid://shopify/ProductVariant/47284154400920",
"quantity": 2
}
]
}
}
}
# Set headers
headers = {
"Content-Type": "application/json"
}
# Send POST request to MCP endpoint
response = requests.post(mcp_endpoint, headers=headers, data=json.dumps(payload))
# Handle response
if response.status_code == 200:
data = response.json()
print("✅ Cart update successful!")
print(json.dumps(data, indent=4, ensure_ascii=False))
# Optional: save response to file
with open("update_cart_response.json", "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
print("💾 Response saved to 'update_cart_response.json'")
else:
print(f"❌ Request failed with status {response.status_code}")
print(response.text)
It will return the output as follows
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"instructions\":\"Ask if the customer has found everything they need. If they're ready to check out:\\n\\n1. First help them complete their cart with any additional items they might need\\n2. If the cart contains shipping-eligible items, prompt them to select a shipping option from those available\\n3. Ask if they'd like to add any special instructions or notes to their order (optional)\\n4. Check if they have any discount codes or gift cards they'd like to apply (only if they mention them)\\n5. Assist them in navigating to checkout by providing a markdown link to the checkout URL\\n\\nRemember that buyer information helps calculate accurate shipping rates but isn't required to proceed.\\n\",\"cart\":{\"id\":\"gid://shopify/Cart/hWN3kutElY3rNehlASj3qhYi?key=c280213459e43799f899432baca1ecdf\",\"created_at\":\"2025-10-05T07:20:29.321Z\",\"updated_at\":\"2025-10-05T07:20:29.321Z\",\"lines\":[],\"delivery\":{},\"discounts\":{},\"gift_cards\":[],\"cost\":{\"total_amount\":{\"amount\":\"0.0\",\"currency\":\"INR\"},\"subtotal_amount\":{\"amount\":\"0.0\",\"currency\":\"INR\"}},\"total_quantity\":0,\"checkout_url\":\"https://shopchatmcp.myshopify.com/cart/c/hWN3kutElY3rNehlASj3qhYi?key=c280213459e43799f899432baca1ecdf\"},\"errors\":[]}"
}
],
"isError": false
}
}
Also the total quantity in the cart is 0.