Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
paramsNoAction parameters as a JSON object

Implementation Reference

  • 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 };
      },
    },
  • 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),
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It only states 'update', which implies mutation, but does not disclose side effects, authorization needs, or validation behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one concise sentence with no wasted words. It is front-loaded with the action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with a free-form input schema and no output schema, the description is too minimal. It lacks details on return values, parameter constraints, or when the tool should be used in a workflow.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% but the sole parameter 'params' is a free-form object. The description adds no meaning beyond the schema's 'Action parameters as a JSON object' – it doesn't specify expected keys or structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'update' and the resource 'existing cart price rule', which is specific and distinguishes this tool from siblings like create, enable, disable, and search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use this tool versus alternatives (e.g., promotions_prepare_cart_price_rule_create or promotions_enable_rule), nor any context about prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/thomastx05/magento-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server