Skip to main content
Glama

get_alert

Retrieve a specific security alert by its unique identifier to investigate and respond to incidents.

Instructions

Retrieve a single security alert by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alert_idYesAlert identifier

Implementation Reference

  • Registration of the 'get_alert' tool via server.tool(), defining its name, description, schema, and handler
    server.tool(
      "get_alert",
      "Retrieve a single security alert by its ID",
      {
        alert_id: z
          .string()
          .describe("Alert identifier"),
      },
      async ({ alert_id }) => {
        if (!indexerClient) {
          return {
            content: [{ type: "text" as const, text: JSON.stringify({ error: NO_INDEXER_MSG }) }],
            isError: true,
          };
        }
    
        try {
          const alert = await indexerClient.getAlert(alert_id);
    
          if (!alert) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ error: `Alert '${alert_id}' not found` }),
                },
              ],
              isError: true,
            };
          }
    
          const result = {
            id: alert.id,
            timestamp: alert.timestamp,
            rule_id: alert.rule?.id,
            rule_level: alert.rule?.level,
            rule_description: alert.rule?.description,
            rule_groups: alert.rule?.groups,
            agent_id: alert.agent?.id,
            agent_name: alert.agent?.name,
            location: alert.location,
            decoder: alert.decoder?.name,
            full_log: alert.full_log,
            mitre: alert.rule?.mitre,
            data: alert.data,
          };
    
          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 that validates indexerClient exists, calls indexerClient.getAlert(alert_id), checks for null result, and returns formatted alert data
      async ({ alert_id }) => {
        if (!indexerClient) {
          return {
            content: [{ type: "text" as const, text: JSON.stringify({ error: NO_INDEXER_MSG }) }],
            isError: true,
          };
        }
    
        try {
          const alert = await indexerClient.getAlert(alert_id);
    
          if (!alert) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ error: `Alert '${alert_id}' not found` }),
                },
              ],
              isError: true,
            };
          }
    
          const result = {
            id: alert.id,
            timestamp: alert.timestamp,
            rule_id: alert.rule?.id,
            rule_level: alert.rule?.level,
            rule_description: alert.rule?.description,
            rule_groups: alert.rule?.groups,
            agent_id: alert.agent?.id,
            agent_name: alert.agent?.name,
            location: alert.location,
            decoder: alert.decoder?.name,
            full_log: alert.full_log,
            mitre: alert.rule?.mitre,
            data: alert.data,
          };
    
          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,
          };
        }
      }
    );
  • Input schema for get_alert: requires a single string parameter 'alert_id'
    {
      alert_id: z
        .string()
        .describe("Alert identifier"),
    },
  • Indexer client helper that queries OpenSearch by alert ID and maps the result to a WazuhAlert object
    async getAlert(id: string): Promise<WazuhAlert | null> {
      const body = {
        query: { ids: { values: [id] } },
        size: 1,
      };
    
      const result = await this.post<OpenSearchResponse>("/wazuh-alerts-*/_search", body);
      if (result.hits.hits.length === 0) return null;
      return this.mapHitToAlert(result.hits.hits[0]);
    }
  • src/index.ts:40-49 (registration)
    Registration call where registerAlertTools is invoked during server setup with server, client, and indexerClient
    registerAlertTools(server, client, indexerClient);
    registerRuleTools(server, client);
    registerDecoderTools(server, client);
    registerVersionTools(server, client);
    registerScaTools(server, client);
    registerSyscollectorTools(server, client);
    registerRootcheckTools(server, client);
    registerSyscheckTools(server, client);
    registerManagerTools(server, client);
    registerGroupTools(server, client);
Behavior3/5

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

With no annotations, the description carries full burden. It correctly implies a read-only retrieval but lacks details on error cases (e.g., invalid or missing ID), authentication needs, or any behavioral constraints. The description is minimally adequate.

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 front-loads the core functionality. Every word is necessary and there is no fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple tool (one required parameter, no output schema) and the presence of sibling tools like 'get_alerts', the description provides enough context to understand the tool's role. However, it could be improved by explicitly contrasting with 'get_alerts' to complete the picture.

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% and describes the parameter 'alert_id' with a clear description. The description adds only the phrase 'by its ID', which is redundant with the schema. No additional semantic value beyond what the schema provides.

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 clearly states the verb 'Retrieve' and the resource 'single security alert by its ID', which is specific and distinguishes it from the sibling tool 'get_alerts' that returns multiple alerts.

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 is provided on when to use this tool versus alternatives like 'get_alerts' (for multiple) or 'search_alerts' (for filtered queries). The context implies a simple lookup by ID, but explicit selection criteria are missing.

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