promotions_get_rule
Retrieve detailed information about a specific cart price rule, including conditions, actions, and labels.
Instructions
Get details of a specific cart price rule.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Action parameters as a JSON object |
Implementation Reference
- src/actions/promotions.ts:168-173 (handler)The handler function for the 'promotions.get_rule' tool. Validates params with GetRuleSchema, then makes a GET request to Magento's /V1/salesRules/{rule_id} API to retrieve cart price rule details.
handler: async (params: Record<string, unknown>, context: ActionContext) => { const validated = GetRuleSchema.parse(params); const client = context.getClient(); const result = await client.get(`/V1/salesRules/${validated.rule_id}`); return result; }, - src/validation/schemas.ts:89-91 (schema)Zod validation schema for the tool. Requires a single integer 'rule_id' parameter.
export const GetRuleSchema = z.object({ rule_id: z.number().int(), }); - src/index.ts:78-78 (registration)Registration loop in index.ts: the action's name ('promotions.get_rule') is converted to 'promotions_get_rule' (dots replaced with underscores) and registered as an MCP tool via mcpServer.tool().
const toolName = action.name.replace(/\./g, '_'); - src/actions/promotions.ts:162-174 (registration)The ActionDefinition object for 'promotions.get_rule' as part of the createPromotionsActions() array. Defines name, description, risk tier, auth requirement, and handler.
// ── Get Rule ────────────────────────────────────────────────────────── { name: 'promotions.get_rule', description: 'Get details of a specific cart price rule.', riskTier: RiskTier.Safe, requiresAuth: true, handler: async (params: Record<string, unknown>, context: ActionContext) => { const validated = GetRuleSchema.parse(params); const client = context.getClient(); const result = await client.get(`/V1/salesRules/${validated.rule_id}`); return result; }, },