Skip to main content
Glama
kishimoto-banana

Shopify Python MCP Server

get_product

Retrieve detailed product information from Shopify stores using the product ID to streamline inventory management and e-commerce operations.

Instructions

商品の詳細情報を取得する

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idYes商品ID

Implementation Reference

  • The main handler function that executes the 'get_product' tool: fetches product by ID using Shopify API, extracts and formats details including variants, options, and images, then returns JSON as TextContent.
    async def handle_get_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)
    
        # 商品情報を整形
        result = {
            "id": product.id,
            "title": product.title,
            "body_html": product.body_html,
            "vendor": product.vendor,
            "product_type": product.product_type,
            "created_at": product.created_at,
            "updated_at": product.updated_at,
            "status": product.status,
            "tags": product.tags,
            "variants": [],
            "options": [],
            "images": [],
        }
    
        # バリエーション情報
        for variant in product.variants:
            result["variants"].append(
                {
                    "id": variant.id,
                    "title": variant.title,
                    "price": variant.price,
                    "sku": variant.sku,
                    "inventory_quantity": variant.inventory_quantity,
                    "option1": variant.option1,
                    "option2": variant.option2,
                    "option3": variant.option3,
                }
            )
    
        # オプション情報
        for option in product.options:
            result["options"].append(
                {"id": option.id, "name": option.name, "values": option.values}
            )
    
        # 画像情報
        for image in product.images:
            result["images"].append({"id": image.id, "src": image.src, "alt": image.alt})
    
        return [
            types.TextContent(
                type="text",
                text=json.dumps(result, indent=2, ensure_ascii=False),
            )
        ]
  • Registers the 'get_product' tool in the MCP server's list_tools() callback, specifying name, description, and input schema.
    types.Tool(
        name="get_product",
        description="商品の詳細情報を取得する",
        inputSchema={
            "type": "object",
            "properties": {
                "product_id": {"type": "number", "description": "商品ID"}
            },
            "required": ["product_id"],
        },
    ),
  • Input JSON Schema for the 'get_product' tool: requires a 'product_id' number parameter.
    inputSchema={
        "type": "object",
        "properties": {
            "product_id": {"type": "number", "description": "商品ID"}
        },
        "required": ["product_id"],
    },

Tool Definition Quality

Score is being calculated. Check back soon.

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