delete_product
Remove a product from your Shopify store by specifying its unique product ID using this tool, simplifying store inventory management.
Instructions
商品を削除する
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | 商品ID |
Input Schema (JSON Schema)
{
"properties": {
"product_id": {
"description": "商品ID",
"type": "number"
}
},
"required": [
"product_id"
],
"type": "object"
}
Implementation Reference
- src/shopify_py_mcp/server.py:699-727 (handler)The main handler function for the delete_product tool. It validates the product_id argument, retrieves the product using Shopify's Product.find(), stores the title, deletes the product with product.destroy(), and returns a success JSON message including the deleted product's title.async def handle_delete_product(arguments: dict) -> list[types.TextContent]: """商品を削除する""" # 必須パラメータのチェック product_id = arguments.get("product_id") if not product_id: raise ValueError("product_id is required") # 商品の取得 product = shopify.Product.find(product_id) # 商品名を保存 product_title = product.title # 商品の削除 product.destroy() return [ types.TextContent( type="text", text=json.dumps( { "success": True, "message": f"商品「{product_title}」が削除されました", }, indent=2, ensure_ascii=False, ), ) ]
- src/shopify_py_mcp/server.py:366-376 (registration)Registers the delete_product tool within the server's list_tools() handler, specifying the tool name, description in Japanese ('商品を削除する' meaning 'Delete product'), and input schema requiring a numeric product_id.types.Tool( name="delete_product", description="商品を削除する", inputSchema={ "type": "object", "properties": { "product_id": {"type": "number", "description": "商品ID"} }, "required": ["product_id"], }, ),
- src/shopify_py_mcp/server.py:369-375 (schema)Defines the input schema for the delete_product tool: an object with a required 'product_id' property of type number, described as '商品ID' (Product ID).inputSchema={ "type": "object", "properties": { "product_id": {"type": "number", "description": "商品ID"} }, "required": ["product_id"], },
- src/shopify_py_mcp/server.py:398-399 (helper)In the server's call_tool() handler, dispatches execution to the handle_delete_product function when the tool name matches 'delete_product', passing the arguments.elif name == "delete_product": return await handle_delete_product(arguments or {})