promotions_search_rules
Search cart price rules by query, website, or enabled status to locate specific promotions.
Instructions
Search cart price rules by query, website, or enabled status.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "promotions_search_rules"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Action parameters as a JSON object |
Implementation Reference
- src/actions/promotions.ts:129-160 (handler)Handler for the promotions.search_rules tool. Validates params via SearchRulesSchema, builds Magento search filter groups for name (LIKE query) and enabled status, then calls GET /V1/salesRules/search on the Magento REST API.
{ name: 'promotions.search_rules', description: 'Search cart price rules by query, website, or enabled status.', riskTier: RiskTier.Safe, requiresAuth: true, handler: async (params: Record<string, unknown>, context: ActionContext) => { const validated = SearchRulesSchema.parse(params); const client = context.getClient(); const filterGroups: Array<{ filters: Array<{ field: string; value: string; conditionType?: string }> }> = []; if (validated.query) { filterGroups.push({ filters: [{ field: 'name', value: `%${validated.query}%`, conditionType: 'like' }], }); } if (validated.enabled !== undefined) { filterGroups.push({ filters: [{ field: 'is_active', value: validated.enabled ? '1' : '0', conditionType: 'eq' }], }); } const searchParams = client.buildSearchParams({ filterGroups: filterGroups.length > 0 ? filterGroups : undefined, pageSize: validated.page_size, currentPage: validated.current_page, }); const result = await client.get('/V1/salesRules/search', searchParams); return result; }, }, - src/validation/schemas.ts:82-87 (schema)Zod schema for validating parameters of promotions.search_rules. Accepts optional query (string), website_code (string), enabled (boolean), plus PaginationSchema fields (page_size default 20, current_page default 1).
export const SearchRulesSchema = z.object({ query: z.string().optional(), website_code: z.string().optional(), enabled: z.boolean().optional(), ...PaginationSchema.shape, }); - src/index.ts:76-78 (registration)Registration: The tool 'promotions.search_rules' is registered as an MCP tool with the name converted to 'promotions_search_rules' (dots replaced with underscores). The action is one of the allActions array, created via createPromotionsActions().
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:51-61 (registration)Registration: createPromotionsActions() is called in index.ts to produce the array of action definitions, which includes promotions.search_rules among others.
const allActions: ActionDefinition[] = [ ...createAuthActions(sessionStore), ...createScopeActions(sessionStore), ...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), ];