Skip to main content
Glama

list_agents

Retrieve a paginated list of Wazuh agents, filtered by status such as active or disconnected, to manage agent inventory.

Instructions

List all Wazuh agents with optional status filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoFilter by agent status: active, disconnected, never_connected, or pending
limitNoMaximum number of agents to return (1-100)
offsetNoPagination offset
sortNoSort field with direction prefix (e.g., '-name', '+id')

Implementation Reference

  • The registerAgentTools function registers the 'list_agents' tool on the MCP server via server.tool().
    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,
            };
          }
        }
      );
  • The async handler that executes the 'list_agents' tool logic. It calls client.getAgents() with status/limit/offset/sort params and returns a formatted JSON response with agent details (id, name, ip, status, group, os, version, manager, node, dates).
      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,
          };
        }
      }
    );
  • Zod input schema for the 'list_agents' tool: optional status filter (active/disconnected/never_connected/pending), limit (1-100, default 10), offset (default 0), and optional sort field.
    {
      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')"),
    },
  • The client.getAgents() method called by the handler. It makes a GET request to the '/agents' Wazuh API endpoint with the provided parameters.
    async getAgents(
      params: Record<string, string | number> = {}
    ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhAgent>>> {
      return this.get("/agents", params);
    }
  • The WazuhAgent type definition used for the API response data structure that the handler maps into its JSON output.
    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;
    }
Behavior2/5

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

With no annotations, the description carries the full burden, but it only mentions listing with status filtering. It does not disclose authentication needs, rate limits, or response format, leaving significant behavioral traits unspecified.

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 action efficiently, but it sacrifices completeness for brevity.

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 no output schema, the description should explain the response structure and pagination details. It fails to do so, leaving the agent with incomplete information for effective 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%, so the description adds little beyond the schema. The mention of 'optional status filtering' is redundant but not harmful.

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 it lists Wazuh agents with optional status filtering, effectively distinguishing from sibling tools like 'get_agent' which retrieves a single agent.

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 provided on when to use this tool versus alternatives such as 'get_agent' for individual agent details or 'get_agent_*' for specific attributes.

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