Skip to main content
Glama

get_rule

Retrieve detailed information about a specific Wazuh detection rule using its rule ID.

Instructions

Get detailed information about a specific Wazuh rule by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYesRule identifier (e.g., 5710)

Implementation Reference

  • Registration of the 'get_rule' tool on the MCP server via server.tool(), with name 'get_rule', description 'Get detailed information about a specific Wazuh rule by ID', and zod schema for the rule_id parameter.
    server.tool(
      "get_rule",
      "Get detailed information about a specific Wazuh rule by ID",
      {
        rule_id: z
          .number()
          .int()
          .describe("Rule identifier (e.g., 5710)"),
      },
      async ({ rule_id }) => {
        try {
          const response = await client.getRule(rule_id);
          const rules = response.data.affected_items;
    
          if (rules.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ error: `Rule '${rule_id}' not found` }),
                },
              ],
              isError: true,
            };
          }
    
          const rule = rules[0];
          const result = {
            id: rule.id,
            description: rule.description,
            level: rule.level,
            groups: rule.groups,
            filename: rule.filename,
            relative_dirname: rule.relative_dirname,
            status: rule.status,
            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,
          };
    
          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,
          };
        }
      }
    );
  • Handler function for 'get_rule': calls client.getRule(rule_id), extracts the first affected_item, maps fields (id, description, level, groups, filename, relative_dirname, status, compliance mappings, mitre, details), and returns JSON response. Returns error if rule not found or on exception.
    async ({ rule_id }) => {
      try {
        const response = await client.getRule(rule_id);
        const rules = response.data.affected_items;
    
        if (rules.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({ error: `Rule '${rule_id}' not found` }),
              },
            ],
            isError: true,
          };
        }
    
        const rule = rules[0];
        const result = {
          id: rule.id,
          description: rule.description,
          level: rule.level,
          groups: rule.groups,
          filename: rule.filename,
          relative_dirname: rule.relative_dirname,
          status: rule.status,
          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,
        };
    
        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 schema for the 'get_rule' tool input: 'rule_id' is a required integer (e.g., 5710).
    {
      rule_id: z
        .number()
        .int()
        .describe("Rule identifier (e.g., 5710)"),
    },
  • Client helper method getRule(): sends an HTTP GET request to the Wazuh API /rules endpoint with rule_ids query parameter.
    async getRule(
      ruleId: number
    ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhRule>>> {
      return this.get("/rules", { rule_ids: ruleId });
    }
  • TypeScript interface for WazuhRule, defining the shape of rule data returned by the API and used by the handler.
    export interface WazuhRule {
      id: number;
      description: string;
      level: number;
      groups?: string[];
      pci_dss?: string[];
      gdpr?: string[];
      gpg13?: string[];
      hipaa?: string[];
      nist_800_53?: string[];
      tsc?: string[];
      mitre?: {
        id?: string[];
        tactic?: string[];
        technique?: string[];
      };
      details?: Record<string, unknown>;
      filename?: string;
      relative_dirname?: string;
      status?: string;
    }
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only says 'Get detailed information' without mentioning response format, error handling, or that it's a read-only operation.

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 a single concise sentence that immediately conveys the tool's purpose 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?

Given the lack of output schema and annotations, the description is incomplete. It does not explain return values or potential errors, leaving the agent without crucial context for a retrieval tool.

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 description coverage is 100% with a clear parameter description. The description adds 'by ID' but does not provide additional meaning beyond the schema.

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 uses a specific verb 'Get' and resource 'a specific Wazuh rule by ID', clearly indicating its function. It distinguishes from siblings like 'search_rules' which is for searching multiple rules.

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?

The description does not provide any guidance on when to use this tool versus alternatives like 'search_rules' or other 'get_' tools. It implicitly suggests retrieving a single rule by ID but lacks explicit usage context.

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