get_agent_network
List network interfaces and their IP addresses from a specified Wazuh agent for security analysis.
Instructions
List network interfaces and their IP addresses on a Wazuh agent
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Agent identifier (e.g., '001') |
Implementation Reference
- src/tools/syscollector.ts:246-292 (registration)The tool "get_agent_network" is registered via server.tool() with an agent_id string parameter, description, and async handler.
server.tool( "get_agent_network", "List network interfaces and their IP addresses on a Wazuh agent", { agent_id: z .string() .describe("Agent identifier (e.g., '001')"), }, async ({ agent_id }) => { try { const response = await client.getAgentNetwork(agent_id); const data = response.data; const result = { agent_id, interfaces: data.affected_items.map((iface) => ({ name: iface.name, type: iface.type, state: iface.state, mac: iface.mac, mtu: iface.mtu, ipv4: iface.ipv4, ipv6: iface.ipv6, tx_packets: iface.tx_packets, rx_packets: iface.rx_packets, })), total: data.total_affected_items, }; 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, }; } } ); - src/tools/syscollector.ts:254-291 (handler)Handler function that calls client.getAgentNetwork(agent_id), maps the response to a clean interfaces list (name, type, state, mac, mtu, ipv4, ipv6, tx_packets, rx_packets), and returns the result as JSON text content.
async ({ agent_id }) => { try { const response = await client.getAgentNetwork(agent_id); const data = response.data; const result = { agent_id, interfaces: data.affected_items.map((iface) => ({ name: iface.name, type: iface.type, state: iface.state, mac: iface.mac, mtu: iface.mtu, ipv4: iface.ipv4, ipv6: iface.ipv6, tx_packets: iface.tx_packets, rx_packets: iface.rx_packets, })), total: data.total_affected_items, }; 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, }; } } - src/tools/syscollector.ts:249-253 (schema)Zod schema for the tool input: a required string agent_id with description.
{ agent_id: z .string() .describe("Agent identifier (e.g., '001')"), }, - src/client.ts:331-335 (helper)Client helper method that makes a GET request to /syscollector/{agentId}/netiface endpoint, returning paginated network interface data.
async getAgentNetwork( agentId: string ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhNetIface>>> { return this.get(`/syscollector/${agentId}/netiface`); }