system_network_connections
Monitor active network connections and listening ports to identify open services and network activity across your infrastructure.
Instructions
Show active network connections and listening ports
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "system_network_connections"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | No | Filter by connection state (e.g., 'listening') |
Implementation Reference
- src/tools/system/network.ts:6-23 (handler)The main handler function for the `system_network_connections` tool. It attempts to retrieve network connections using the `ss` command, falling back to `netstat` if necessary.
export async function networkConnections(args: Record<string, unknown>): Promise<string> { const state = args.state as string | undefined; try { // Try ss first, fall back to netstat try { const ssArgs = ["-tuln"]; if (state) ssArgs.push("state", state); const { stdout } = await execFileAsync("ss", ssArgs, { timeout: 10000 }); return `Network connections:\n\n${stdout.trim()}`; } catch { const { stdout } = await execFileAsync("netstat", ["-tuln"], { timeout: 10000 }); return `Network connections:\n\n${stdout.trim()}`; } } catch (error: any) { throw new Error(`Failed to get network connections: ${error.message}`); } } - src/tools/system/index.ts:30-38 (schema)Tool definition and schema for `system_network_connections`.
name: "system_network_connections", description: "Show active network connections and listening ports", inputSchema: { type: "object" as const, properties: { state: { type: "string", description: "Filter by connection state (e.g., 'listening')" }, }, }, }, - src/tools/system/index.ts:62-62 (registration)Registration of the `system_network_connections` tool handler within the central tool dispatcher.
case "system_network_connections": return networkConnections(a);