While creating Cart using update_cart from shopify MCP its giving the checkout url empty

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.

@eytan-shopify sir any update on this ?

Hey @Vedant_Dere,

I’ve dug into this and found the issue. The Storefront MCP documentation is missing some parameter names that the MCP server expects. You followed the docs correctly based on what is there, but the tool you need isn’t in the docs.

The example in our documentation shows using a lines array with merchandise_id, but the actual MCP server uses add_items with product_variant_id. You can verify this yourself by calling the tools/list method on your store’s MCP endpoint to see the actual schema.

{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": 1
}

Here’s the corrected request structure:

payload = {
    "jsonrpc": "2.0",
    "method": "tools/call",
    "id": 1,
    "params": {
        "name": "update_cart",
        "arguments": {
            "add_items": [  # Changed from "lines"
                {
                    "product_variant_id": "gid://shopify/ProductVariant/47284154400920",  # Changed from "merchandise_id"
                    "quantity": 2
                }
            ]
        }
    }
}

The key changes are replacing lines with add_items and merchandise_id with product_variant_id. The server was silently ignoring your lines parameter because it didn’t recognize it, which is why you were getting empty carts with a 200 status.

I’m noting this documentation gap so we can get it fixed. Thanks for the detailed reproduction code, it helped track this down quickly.

@KyleG-Shopify Thanks a lot for the solution — it’s working perfectly! Really appreciate your help once again.

1 Like

Glad it’s working! :slight_smile: