Skip to main content
Glama

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNoFilter by connection state (e.g., 'listening')

Implementation Reference

  • 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}`);
      }
    }
  • 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')" },
        },
      },
    },
  • Registration of the `system_network_connections` tool handler within the central tool dispatcher.
    case "system_network_connections": return networkConnections(a);

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/batu-sonmez/infraclaude'

If you have feedback or need assistance with the MCP directory API, please join our Discord server