Skip to main content
Glama

list_rules

Retrieve Wazuh detection rules with optional filtering by severity level and group. Supports pagination and sorting to manage rule listings.

Instructions

List all Wazuh rules with optional level and group filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
levelNoFilter by rule severity level
groupNoFilter by rule group name
limitNoMaximum number of rules to return (1-100)
offsetNoPagination offset
sortNoSort field with direction prefix (e.g., '-level')

Implementation Reference

  • The async handler function that executes the 'list_rules' tool logic — builds query params (level, group, limit, offset, sort), calls client.getRules(), maps results to a clean JSON response, and handles errors.
    async ({ level, group, limit, offset, sort }) => {
      try {
        const params: Record<string, string | number> = { limit, offset };
        if (level !== undefined) params.level = level;
        if (group) params.group = group;
        if (sort) params.sort = sort;
    
        const response = await client.getRules(params);
        const data = response.data;
    
        const result = {
          rules: data.affected_items.map((rule) => ({
            id: rule.id,
            description: rule.description,
            level: rule.level,
            groups: rule.groups,
            pci_dss: rule.pci_dss,
            gdpr: rule.gdpr,
            gpg13: rule.gpg13,
            hipaa: rule.hipaa,
            nist_800_53: rule.nist_800_53,
            tsc: rule.tsc,
            mitre: rule.mitre,
            details: rule.details,
          })),
          total: data.total_affected_items,
          limit,
          offset,
        };
    
        return {
          content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                error: error instanceof Error ? error.message : String(error),
              }),
            },
          ],
          isError: true,
        };
      }
    }
  • Registration of the 'list_rules' tool on the McpServer via server.tool() with name 'list_rules', description, Zod schema for inputs, and the handler callback.
    server.tool(
      "list_rules",
      "List all Wazuh rules with optional level and group filtering",
      {
        level: z
          .number()
          .int()
          .min(0)
          .optional()
          .describe("Filter by rule severity level"),
        group: z
          .string()
          .optional()
          .describe("Filter by rule group name"),
        limit: z
          .number()
          .int()
          .min(1)
          .max(100)
          .default(10)
          .describe("Maximum number of rules to return (1-100)"),
        offset: z
          .number()
          .int()
          .min(0)
          .default(0)
          .describe("Pagination offset"),
        sort: z
          .string()
          .optional()
          .describe("Sort field with direction prefix (e.g., '-level')"),
      },
      async ({ level, group, limit, offset, sort }) => {
        try {
          const params: Record<string, string | number> = { limit, offset };
          if (level !== undefined) params.level = level;
          if (group) params.group = group;
          if (sort) params.sort = sort;
    
          const response = await client.getRules(params);
          const data = response.data;
    
          const result = {
            rules: data.affected_items.map((rule) => ({
              id: rule.id,
              description: rule.description,
              level: rule.level,
              groups: rule.groups,
              pci_dss: rule.pci_dss,
              gdpr: rule.gdpr,
              gpg13: rule.gpg13,
              hipaa: rule.hipaa,
              nist_800_53: rule.nist_800_53,
              tsc: rule.tsc,
              mitre: rule.mitre,
              details: rule.details,
            })),
            total: data.total_affected_items,
            limit,
            offset,
          };
    
          return {
            content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({
                  error: error instanceof Error ? error.message : String(error),
                }),
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Zod input schema for the 'list_rules' tool: optional level (int >=0), optional group (string), limit (1-100, default 10), offset (int >=0, default 0), optional sort (string).
    {
      level: z
        .number()
        .int()
        .min(0)
        .optional()
        .describe("Filter by rule severity level"),
      group: z
        .string()
        .optional()
        .describe("Filter by rule group name"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(10)
        .describe("Maximum number of rules to return (1-100)"),
      offset: z
        .number()
        .int()
        .min(0)
        .default(0)
        .describe("Pagination offset"),
      sort: z
        .string()
        .optional()
        .describe("Sort field with direction prefix (e.g., '-level')"),
    },
  • src/index.ts:41-41 (registration)
    Top-level registration call: registerRuleTools(server, client) invoked in main() to wire up the 'list_rules' tool.
    registerRuleTools(server, client);
  • Client helper method getRules() that performs the actual GET /rules API call to Wazuh with query params.
    async getRules(
      params: Record<string, string | number> = {}
    ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhRule>>> {
      return this.get("/rules", params);
    }
Behavior2/5

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

No annotations provided, so description must fully convey behavior. It states basic listing and filtering but omits pagination semantics, performance implications, auth requirements, and other operational details.

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?

Single sentence front-loads verb and resource. Efficient with no wasted words.

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?

No output schema, no annotations, and 5 params. Description lacks details on return values, pagination, sorting behavior, and error handling. Insufficient for robust agent usage.

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% with all params described. The description highlights only 'level and group filtering', adding minimal value beyond schema. Baseline 3 is appropriate.

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 verb 'list' and resource 'Wazuh rules', with optional filters. It is specific and distinct from sibling tools like get_rule (single rule) and search_rules (likely more complex search). However, it does not explicitly contrast with siblings.

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 on when to use this tool vs alternatives like search_rules or get_rule. Missing when-not or context for choosing this tool.

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/solomonneas/wazuh-mcp'

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