Skip to main content
Glama

get_agent

Retrieves detailed information about a specific Wazuh agent using its unique identifier. Checks agent status, version, and configuration details.

Instructions

Get detailed information about a specific Wazuh agent by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesAgent identifier (e.g., '001')

Implementation Reference

  • The main handler function for the 'get_agent' tool. Calls client.getAgent() and formats the agent data into a structured JSON response. Handles errors and empty results.
    server.tool(
      "get_agent",
      "Get detailed information about a specific Wazuh agent by ID",
      {
        agent_id: z
          .string()
          .describe("Agent identifier (e.g., '001')"),
      },
      async ({ agent_id }) => {
        try {
          const response = await client.getAgent(agent_id);
          const agents = response.data.affected_items;
    
          if (agents.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ error: `Agent '${agent_id}' not found` }),
                },
              ],
              isError: true,
            };
          }
    
          const agent = agents[0];
          const result = {
            id: agent.id,
            name: agent.name,
            ip: agent.ip,
            status: agent.status,
            group: agent.group,
            os_name: agent.os?.name,
            os_version: agent.os?.version,
            os_platform: agent.os?.platform,
            version: agent.version,
            manager: agent.manager,
            node_name: agent.node_name,
            date_add: agent.dateAdd,
            last_keepalive: agent.lastKeepAlive,
            register_ip: agent.registerIP,
          };
    
          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_agent' tool. Accepts a single required parameter: agent_id (string) described as 'Agent identifier (e.g., '001')'.
    server.tool(
      "get_agent",
      "Get detailed information about a specific Wazuh agent by ID",
      {
        agent_id: z
          .string()
          .describe("Agent identifier (e.g., '001')"),
      },
  • Registration of all agent-related tools including 'get_agent', called from src/index.ts line 39 via registerAgentTools(server, client).
    export function registerAgentTools(
      server: McpServer,
      client: WazuhClient
    ): void {
      server.tool(
        "list_agents",
        "List all Wazuh agents with optional status filtering",
        {
          status: z
            .enum(["active", "disconnected", "never_connected", "pending"])
            .optional()
            .describe(
              "Filter by agent status: active, disconnected, never_connected, or pending"
            ),
          limit: z
            .number()
            .int()
            .min(1)
            .max(100)
            .default(10)
            .describe("Maximum number of agents 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., '-name', '+id')"),
        },
        async ({ status, limit, offset, sort }) => {
          try {
            const params: Record<string, string | number> = { limit, offset };
            if (status) params.status = status;
            if (sort) params.sort = sort;
    
            const response = await client.getAgents(params);
            const data = response.data;
    
            const result = {
              agents: data.affected_items.map((agent) => ({
                id: agent.id,
                name: agent.name,
                ip: agent.ip,
                status: agent.status,
                group: agent.group,
                os_name: agent.os?.name,
                os_version: agent.os?.version,
                os_platform: agent.os?.platform,
                version: agent.version,
                manager: agent.manager,
                node_name: agent.node_name,
                date_add: agent.dateAdd,
                last_keepalive: agent.lastKeepAlive,
              })),
              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,
            };
          }
        }
      );
    
      server.tool(
        "get_agent",
        "Get detailed information about a specific Wazuh agent by ID",
        {
          agent_id: z
            .string()
            .describe("Agent identifier (e.g., '001')"),
        },
        async ({ agent_id }) => {
          try {
            const response = await client.getAgent(agent_id);
            const agents = response.data.affected_items;
    
            if (agents.length === 0) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: JSON.stringify({ error: `Agent '${agent_id}' not found` }),
                  },
                ],
                isError: true,
              };
            }
    
            const agent = agents[0];
            const result = {
              id: agent.id,
              name: agent.name,
              ip: agent.ip,
              status: agent.status,
              group: agent.group,
              os_name: agent.os?.name,
              os_version: agent.os?.version,
              os_platform: agent.os?.platform,
              version: agent.version,
              manager: agent.manager,
              node_name: agent.node_name,
              date_add: agent.dateAdd,
              last_keepalive: agent.lastKeepAlive,
              register_ip: agent.registerIP,
            };
    
            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,
            };
          }
        }
      );
    
      server.tool(
        "get_agent_stats",
        "Get system statistics (CPU, memory, disk) for a specific Wazuh agent",
        {
          agent_id: z
            .string()
            .describe("Agent identifier (e.g., '001')"),
        },
        async ({ agent_id }) => {
          try {
            // Verify agent exists
            const agentResponse = await client.getAgent(agent_id);
            const agents = agentResponse.data.affected_items;
    
            if (agents.length === 0) {
              return {
                content: [
                  {
                    type: "text" as const,
                    text: JSON.stringify({ error: `Agent '${agent_id}' not found` }),
                  },
                ],
                isError: true,
              };
            }
    
            const agent = agents[0];
            const statsResponse = await client.getAgentStats(agent_id);
            const stats = statsResponse.data.affected_items[0] ?? {};
    
            const result = {
              agent_id: agent.id,
              agent_name: agent.name,
              cpu: stats.cpu,
              memory: stats.memory,
              disk: stats.disk,
            };
    
            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,
            };
          }
        }
      );
    }
  • Client helper method getAgent() that makes the actual HTTP GET request to the Wazuh API endpoint /agents with agents_list parameter.
    async getAgent(
      agentId: string
    ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhAgent>>> {
      return this.get(`/agents`, { agents_list: agentId });
    }
  • TypeScript interface WazuhAgent defining the shape of the agent data returned by the API and formatted in the handler.
    export interface WazuhAgent {
      id: string;
      name: string;
      ip: string;
      status: string;
      group?: string[];
      os?: {
        name?: string;
        version?: string;
        platform?: string;
        arch?: string;
        codename?: string;
      };
      version?: string;
      manager?: string;
      node_name?: string;
      dateAdd?: string;
      lastKeepAlive?: string;
      registerIP?: string;
      status_code?: number;
    }
Behavior3/5

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

Without annotations, the description implies a read-only retrieval but does not disclose authentication needs, rate limits, or what 'detailed information' includes. It is adequate but not explicit about behavioral traits beyond the basic 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?

Single sentence, no fluff. Efficiently conveys the core purpose without unnecessary words.

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

Completeness3/5

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

Given the simple nature (one parameter, no output schema), the description is minimally viable. However, it lacks details on return format or typical fields, which would help the agent anticipate the response.

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 clear parameter description. The description reinforces the parameter's role but adds no new semantic value beyond the schema. Baseline score of 3 applies.

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?

Description explicitly states 'Get detailed information about a specific Wazuh agent by ID', clearly identifying the verb, resource, and scope. It distinguishes from sibling tools like list_agents (listing all) and get_agent_* subtools (specific aspects).

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 versus alternatives (e.g., list_agents, get_agent_packages, etc.). The description does not mention exclusions or preferred scenarios.

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