Skip to main content
Glama
alxspiker

Windows Command Line MCP Server

get_network_info

Retrieve detailed network configuration such as IP addresses, adapters, and DNS settings via the Windows Command Line MCP Server. Optionally filter results by a specific interface for targeted insights.

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 constructs and executes a platform-specific command to retrieve network adapter information, IP addresses, gateways, and DNS settings.
    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}`, }, ], }; } }
  • Input schema defining the optional networkInterface parameter using Zod for validation.
    { networkInterface: z.string().optional().describe("Optional interface name to filter results"), },
  • index.ts:190-253 (registration)
    Registration of the get_network_info tool using server.tool, including name, description, input schema, and handler.
    // Register the get_network_info tool 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}`, }, ], }; } } );

Other Tools

Related 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