update_product_stock
Update product stock status to in_stock, out_of_stock, or preorder. Quickly manage inventory changes using product ID.
Instructions
Update a product's stock status.
Use this to quickly mark products as out of stock when inventory runs out, or to flip back to in_stock after restocking. For variant-level stock counts, see v0.6.0 roadmap.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | UUID from list_org_products results | |
| stock_status | Yes | in_stock | out_of_stock | preorder | |
| org_id | No | Optional — override the org bound to the API key |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/yaparai/tools/enterprise.py:169-194 (handler)Main handler function for the update_product_stock tool. Accepts product_id, stock_status (Literal["in_stock","out_of_stock","preorder"]), and optional org_id. Validates stock_status, then delegates to the client method enterprise_update_product_stock.
async def update_product_stock( product_id: str, stock_status: Literal["in_stock", "out_of_stock", "preorder"], org_id: str | None = None, ) -> dict: """ Update a product's stock status. Use this to quickly mark products as out of stock when inventory runs out, or to flip back to in_stock after restocking. For variant-level stock counts, see v0.6.0 roadmap. Args: product_id: UUID from list_org_products results stock_status: in_stock | out_of_stock | preorder org_id: Optional — override the org bound to the API key Returns: Updated product record. """ if stock_status not in ("in_stock", "out_of_stock", "preorder"): raise ValueError("stock_status must be in_stock | out_of_stock | preorder") client = YaparAIClient() return await client.enterprise_update_product_stock( product_id, stock_status, org_id=org_id ) - Input schema is defined via the function signature: product_id (str), stock_status (Literal["in_stock","out_of_stock","preorder"]), org_id (str | None). The return type is dict.
async def update_product_stock( product_id: str, stock_status: Literal["in_stock", "out_of_stock", "preorder"], org_id: str | None = None, - src/yaparai/server.py:182-182 (registration)Registration of update_product_stock as an MCP tool via mcp.tool(update_product_stock).
mcp.tool(update_product_stock) - src/yaparai/server.py:100-100 (registration)Import of update_product_stock from yaparai.tools.enterprise into server.py where it is registered.
update_product_stock, - src/yaparai/client.py:374-383 (helper)Client helper method enterprise_update_product_stock that makes the actual PATCH HTTP request to /v1/public/enterprise/products/{product_id}/stock with the stock_status payload.
async def enterprise_update_product_stock( self, product_id: str, stock_status: str, org_id: str | None = None ) -> dict: headers = {"X-Organization-Id": org_id} if org_id else {} return await self._request( "PATCH", f"/v1/public/enterprise/products/{product_id}/stock", json={"stock_status": stock_status}, headers=headers, )