Skip to main content
Glama
alxspiker

Windows Command Line MCP Server

get_network_info

Retrieve network configuration details like IP addresses, adapters, and DNS settings. Filter results by specific interface to diagnose connectivity issues.

Instructions

Retrieve network configuration information including IP addresses, adapters, and DNS settings. Can be filtered to a specific interface.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkInterfaceNoOptional interface name to filter results

Implementation Reference

  • Handler function that executes platform-specific commands (PowerShell on Windows, ip on Unix) to retrieve network adapter information, IP addresses, MAC, DNS, etc., optionally filtered by interface.
    async ({ networkInterface }) => {
      try {
        let cmd;
        
        if (isWindows) {
          cmd = "powershell.exe -Command \"";
          
          if (networkInterface) {
            cmd += "$adapters = Get-NetAdapter | Where-Object { $_.Name -like '*" + networkInterface + "*' }; ";
          } else {
            cmd += "$adapters = Get-NetAdapter; ";
          }
          
          cmd += "foreach($adapter in $adapters) { " +
                "Write-Output ('======== ' + $adapter.Name + ' (' + $adapter.Status + ') ========'); " +
                "Write-Output ('Interface Description: ' + $adapter.InterfaceDescription); " +
                "Write-Output ('MAC Address: ' + $adapter.MacAddress); " +
                "Write-Output ('Link Speed: ' + $adapter.LinkSpeed); " +
                "$ipconfig = Get-NetIPConfiguration -InterfaceIndex $adapter.ifIndex; " +
                "Write-Output ('IP Address: ' + ($ipconfig.IPv4Address.IPAddress -join ', ')); " +
                "Write-Output ('Subnet: ' + ($ipconfig.IPv4Address.PrefixLength -join ', ')); " +
                "Write-Output ('Gateway: ' + ($ipconfig.IPv4DefaultGateway.NextHop -join ', ')); " +
                "Write-Output ('DNS Servers: ' + ($ipconfig.DNSServer.ServerAddresses -join ', ')); " +
                "Write-Output ''; " +
                "}\"";
        } else {
          // Fallback for Unix systems
          if (networkInterface) {
            cmd = `ip addr show ${networkInterface}`;
          } else {
            cmd = "ip addr";
          }
        }
        
        const stdout = executeCommand(cmd);
        
        return {
          content: [
            {
              type: "text",
              text: stdout.toString(),
            },
          ],
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error retrieving network info: ${error}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the tool: optional networkInterface string.
    {
      networkInterface: z.string().optional().describe("Optional interface name to filter results"),
    },
  • index.ts:191-253 (registration)
    Registration of the 'get_network_info' tool using server.tool(), including name, description, input schema, and handler function.
    server.tool(
      "get_network_info",
      "Retrieve network configuration information including IP addresses, adapters, and DNS settings. Can be filtered to a specific interface.",
      {
        networkInterface: z.string().optional().describe("Optional interface name to filter results"),
      },
      async ({ networkInterface }) => {
        try {
          let cmd;
          
          if (isWindows) {
            cmd = "powershell.exe -Command \"";
            
            if (networkInterface) {
              cmd += "$adapters = Get-NetAdapter | Where-Object { $_.Name -like '*" + networkInterface + "*' }; ";
            } else {
              cmd += "$adapters = Get-NetAdapter; ";
            }
            
            cmd += "foreach($adapter in $adapters) { " +
                  "Write-Output ('======== ' + $adapter.Name + ' (' + $adapter.Status + ') ========'); " +
                  "Write-Output ('Interface Description: ' + $adapter.InterfaceDescription); " +
                  "Write-Output ('MAC Address: ' + $adapter.MacAddress); " +
                  "Write-Output ('Link Speed: ' + $adapter.LinkSpeed); " +
                  "$ipconfig = Get-NetIPConfiguration -InterfaceIndex $adapter.ifIndex; " +
                  "Write-Output ('IP Address: ' + ($ipconfig.IPv4Address.IPAddress -join ', ')); " +
                  "Write-Output ('Subnet: ' + ($ipconfig.IPv4Address.PrefixLength -join ', ')); " +
                  "Write-Output ('Gateway: ' + ($ipconfig.IPv4DefaultGateway.NextHop -join ', ')); " +
                  "Write-Output ('DNS Servers: ' + ($ipconfig.DNSServer.ServerAddresses -join ', ')); " +
                  "Write-Output ''; " +
                  "}\"";
          } else {
            // Fallback for Unix systems
            if (networkInterface) {
              cmd = `ip addr show ${networkInterface}`;
            } else {
              cmd = "ip addr";
            }
          }
          
          const stdout = executeCommand(cmd);
          
          return {
            content: [
              {
                type: "text",
                text: stdout.toString(),
              },
            ],
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error retrieving network info: ${error}`,
              },
            ],
          };
        }
      }
    );
  • Helper function used by the handler to execute shell commands cross-platform, with Windows priority and fallbacks.
    function executeCommand(command: string, options: any = {}) {
      if (isWindows) {
        return execSync(command, options);
      } else {
        // Log warning for non-Windows environments
        console.error(`Warning: Running in a non-Windows environment (${platform()}). Windows commands may not work.`);
        
        // For testing purposes on non-Windows platforms
        try {
          // For Linux/MacOS, we'll strip cmd.exe and powershell.exe references
          let modifiedCmd = command;
          
          // Replace cmd.exe /c with empty string
          modifiedCmd = modifiedCmd.replace(/cmd\.exe\s+\/c\s+/i, '');
          
          // Replace powershell.exe -Command with empty string or a compatible command
          modifiedCmd = modifiedCmd.replace(/powershell\.exe\s+-Command\s+("|')/i, '');
          
          // Remove trailing quotes if we removed powershell -Command
          if (modifiedCmd !== command) {
            modifiedCmd = modifiedCmd.replace(/("|')$/, '');
          }
          
          console.error(`Attempting to execute modified command: ${modifiedCmd}`);
          return execSync(modifiedCmd, options);
        } catch (error) {
          console.error(`Error executing modified command: ${error}`);
          return Buffer.from(`This tool requires a Windows environment. Current platform: ${platform()}`);
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it states what information is retrieved, it doesn't describe important behavioral aspects like whether this requires administrative privileges, what format the information is returned in, whether it's a read-only operation, or any rate limits or constraints. The description is insufficient for a tool that presumably accesses system-level network configuration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences that each serve clear purposes: the first establishes the core functionality, and the second adds the filtering capability. There's no wasted language or redundancy, making it appropriately sized and front-loaded with essential information.

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 that there are no annotations and no output schema, the description is incomplete for a tool that retrieves system network configuration. It doesn't explain what format the information is returned in, what permissions are required, whether it's safe to use, or what specific data structures to expect. For a system-level information retrieval tool, this leaves significant gaps in understanding.

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 description coverage is 100%, so the schema already fully documents the single optional parameter. The description adds marginal value by mentioning the filtering capability ('Can be filtered to a specific interface'), which aligns with the schema's description of 'Optional interface name to filter results.' No additional parameter semantics beyond what the schema provides are included.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('retrieve') and resources ('network configuration information'), and lists concrete examples of what information is retrieved (IP addresses, adapters, DNS settings). It distinguishes itself from siblings like get_system_info by focusing specifically on network configuration rather than general system information.

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?

The description implies usage context by mentioning filtering capability ('Can be filtered to a specific interface'), but doesn't explicitly state when to use this tool versus alternatives like get_system_info or other sibling tools. No guidance is provided about when NOT to use this tool or what specific scenarios warrant its use.

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/alxspiker/Windows-Command-Line-MCP-Server'

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