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
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | 商品ID |
Implementation Reference
- src/shopify_py_mcp/server.py:442-496 (handler)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), ) ]
- src/shopify_py_mcp/server.py:170-180 (registration)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"], }, ),
- src/shopify_py_mcp/server.py:173-179 (schema)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"], },