promotions_update_rule
Update existing cart price rules to modify discount conditions, actions, or labels. Adjust promotional rules without recreating them.
Instructions
Update an existing cart price rule.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Action parameters as a JSON object |
Implementation Reference
- src/actions/promotions.ts:176-192 (handler)The handler function for the 'promotions.update_rule' tool. Validates input via UpdateRuleSchema, requires confirmation via guardrails, and sends a PUT request to the Magento salesRules API with the patch data.
// ── Update Rule ─────────────────────────────────────────────────────── { name: 'promotions.update_rule', description: 'Update an existing cart price rule.', riskTier: RiskTier.Risk, requiresAuth: true, handler: async (params: Record<string, unknown>, context: ActionContext) => { const validated = UpdateRuleSchema.parse(params); guardrails.requireConfirmation(RiskTier.Risk, params); const client = context.getClient(); const result = await client.put(`/V1/salesRules/${validated.rule_id}`, { rule: { rule_id: validated.rule_id, ...validated.patch }, }); return { message: 'Rule updated successfully', rule: result }; }, }, - src/validation/schemas.ts:93-98 (schema)The Zod schema 'UpdateRuleSchema' that validates the input parameters for promotions.update_rule: rule_id (number), patch (record of unknown), confirm (literal true), and reason (string min 1).
export const UpdateRuleSchema = z.object({ rule_id: z.number().int(), patch: z.record(z.unknown()), confirm: z.literal(true), reason: z.string().min(1), }); - src/index.ts:76-79 (registration)Registration of all action definitions as MCP tools. Tool names have dots replaced with underscores, so 'promotions.update_rule' becomes 'promotions_update_rule'.
for (const action of allActions) { // Convert dots to underscores for MCP tool names (e.g. "auth.login" -> "auth_login") const toolName = action.name.replace(/\./g, '_'); - src/index.ts:54-61 (registration)The createPromotionsActions function is called to produce the array of promotion action definitions, which includes 'promotions.update_rule'.
...createPromotionsActions(planStore, guardrails, config), ...createCatalogActions(planStore, guardrails, idempotencyLedger, config), ...createPricingActions(planStore, guardrails, idempotencyLedger, config), ...createCmsActions(planStore, guardrails, config), ...createSeoActions(planStore, guardrails, config), ...createDiagnosticsActions(), ...createCacheActions(guardrails, config), ];