update_product_status
Update a product's status to published, archived, or disabled to control its availability in your store.
Instructions
Update a product status. PUT /products/{productId}/status. Required: status. Valid values: published, archived, disabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID (required) | |
| status | Yes | Status (required): published, archived, or disabled |
Implementation Reference
- Handler function that parses args via Zod schema, then calls productService.updateProductStatus(client, productId, status).
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } const { productId, status } = parsed.data; return handleToolCall(() => productService.updateProductStatus(client, productId, status)); } - Zod schema validating productId (string, min 1) and status (enum: published, archived, disabled).
const statusEnum = ["published", "archived", "disabled"] as const; const schema = z.object({ productId: z.string().min(1, "productId is required"), status: z.enum(statusEnum, { errorMap: () => ({ message: `status must be one of: ${statusEnum.join(", ")}` }), }), }); - Tool definition (name: update_product_status, description, inputSchema) used for MCP tool registration.
const definition = { name: "update_product_status", description: "Update a product status. PUT /products/{productId}/status. Required: status. Valid values: published, archived, disabled.", inputSchema: { type: "object" as const, properties: { productId: { type: "string", description: "Product ID (required)" }, status: { type: "string", description: "Status (required): published, archived, or disabled", }, }, required: ["productId", "status"], }, }; - src/tools/products/updateProductStatus.ts:42-45 (registration)Export of updateProductStatusTool as a Tool object combining definition and handler.
export const updateProductStatusTool: Tool = { definition, handler, }; - src/tools/products/index.ts:12-12 (registration)Import of updateProductStatusTool from its module.
import { updateProductStatusTool } from "./updateProductStatus.js"; - src/tools/products/index.ts:23-23 (registration)updateProductStatusTool included in the registerProductTools() array that returns all product tools.
updateProductStatusTool, - Service function that calls PUT /products/{productId}/status with the new status value.
export async function updateProductStatus( client: Client, productId: string, status: ProductStatus ): Promise<unknown> { return client.put<unknown>(`/products/${productId}/status`, { status }); } - ProductStatus type alias (published | archived | disabled) used by the service.
/** Product status (ProductValidator::validateStatus – published, archived, disabled) */ export type ProductStatus = "published" | "archived" | "disabled";