Skip to main content
Glama

get_agent_ports

List open network ports on a Wazuh agent to verify connectivity and identify potential security risks.

Instructions

List open network ports on a Wazuh agent

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesAgent identifier (e.g., '001')
limitNoMaximum number of ports to return (1-500)
offsetNoPagination offset

Implementation Reference

  • The tool registration and handler logic for 'get_agent_ports'. Defines the tool with name, description, schema (agent_id, limit, offset), and handler function that calls client.getAgentPorts() and maps the response to a formatted result.
    server.tool(
      "get_agent_ports",
      "List open network ports on a Wazuh agent",
      {
        agent_id: z
          .string()
          .describe("Agent identifier (e.g., '001')"),
        limit: z
          .number()
          .int()
          .min(1)
          .max(500)
          .default(25)
          .describe("Maximum number of ports to return (1-500)"),
        offset: z
          .number()
          .int()
          .min(0)
          .default(0)
          .describe("Pagination offset"),
      },
      async ({ agent_id, limit, offset }) => {
        try {
          const response = await client.getAgentPorts(agent_id, { limit, offset });
          const data = response.data;
    
          const result = {
            agent_id,
            ports: data.affected_items.map((port) => ({
              protocol: port.protocol,
              local_ip: port.local_ip,
              local_port: port.local_port,
              remote_ip: port.remote_ip,
              remote_port: port.remote_port,
              state: port.state,
              pid: port.pid,
              process: port.process,
            })),
            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,
          };
        }
      }
    );
  • Input schema for 'get_agent_ports' using Zod validation: agent_id (string), limit (int 1-500, default 25), offset (int 0+, default 0).
    {
      agent_id: z
        .string()
        .describe("Agent identifier (e.g., '001')"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(500)
        .default(25)
        .describe("Maximum number of ports to return (1-500)"),
      offset: z
        .number()
        .int()
        .min(0)
        .default(0)
        .describe("Pagination offset"),
    },
  • Client method getAgentPorts() that makes the HTTP GET request to /syscollector/{agentId}/ports.
    async getAgentPorts(
      agentId: string,
      params: Record<string, string | number> = {}
    ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhPort>>> {
      return this.get(`/syscollector/${agentId}/ports`, params);
    }
  • The WazuhPort interface describing the structure of port data returned from the API.
    export interface WazuhPort {
      protocol?: string;
      local_ip?: string;
      local_port?: number;
      remote_ip?: string;
      remote_port?: number;
      tx_queue?: number;
      rx_queue?: number;
      state?: string;
      pid?: number;
      process?: string;
      inode?: number;
    }
  • src/index.ts:12-16 (registration)
    Import statement for registerSyscollectorTools in the main entry point.
    import { registerSyscollectorTools } from "./tools/syscollector.js";
    import { registerRootcheckTools } from "./tools/rootcheck.js";
    import { registerSyscheckTools } from "./tools/syscheck.js";
    import { registerManagerTools } from "./tools/manager.js";
    import { registerGroupTools } from "./tools/groups.js";
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only states 'list' (suggesting read-only) but lacks details on result format, pagination behavior, or any constraints beyond the schema. More behavioral context is needed.

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, concise sentence that efficiently conveys the tool's purpose. It is appropriately front-loaded and has no wasted 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 lack of annotations and output schema, the description is adequate for a simple list tool but omits behavioral details like pagination or result format. It covers the basics but could be more complete.

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?

Input schema has 100% description coverage for all three parameters. The description adds no extra meaning beyond the schema, so baseline 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?

The description clearly states the tool lists open network ports on a Wazuh agent, using a specific verb and resource. It differentiates from siblings like get_agent_network (likely lists interfaces) and get_agent (agent info).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the purpose is clear, there is no explicit guidance on when to use this tool versus alternatives. Usage is implied, but no when-not or context is provided.

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