Skip to main content
Glama

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNoAction parameters as a JSON object

Implementation Reference

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

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

The description provides no details on how the search behaves (e.g., pagination, sorting, exact vs fuzzy matching) and there are no annotations to fill the gap. Given the tool's input is a free-form object, behavior is essentially undocumented.

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

Conciseness4/5

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

The description is a single, front-loaded sentence that conveys the core purpose and main filters. It is concise, but could be improved by including one more sentence about result format or limitations.

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?

The description lacks essential details expected for a search tool: pagination, response structure, and behavior when no filters are given. The loose input schema and missing output schema leave the agent without enough information to use the tool correctly.

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?

The input schema defines only a single 'params' object without properties, so the description adds value by listing possible keys (query, website, enabled status). However, without schema definitions for those keys, the meaning is still vague and not actionable.

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

Purpose4/5

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

The description clearly states the tool searches for cart price rules, and specifies filter criteria (query, website, enabled status), differentiating it from siblings like promotions_get_rule and promotions_commit_cart_price_rule_create. However, the loose input schema undermines clarity because the claimed filters are not defined as formal parameters.

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

Usage Guidelines3/5

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

The description implies usage for searching cart price rules, which is appropriate given sibling tools for other entities. But it does not explicitly state when to use this tool over alternatives or mention any preconditions (e.g., required permissions).

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