Skip to main content
Glama
kishimoto-banana

Shopify Python MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault
product_idYes商品ID

Implementation Reference

  • 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,
                ),
            )
        ]
  • 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"],
        },
    ),
  • 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"],
    },
  • 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 {})
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kishimoto-banana/shopify-py-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server