get_network_info
Retrieve network configuration details including IP addresses, connection status, and adapter information from Windows systems for troubleshooting and monitoring purposes.
Instructions
获取网络信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/powershell.js:185-215 (handler)The main handler function that executes a PowerShell command to retrieve IPv4 network interface information, excluding loopback interfaces, and parses the JSON output.async getNetworkInfo() { try { const command = ` Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceAlias -notlike '*Loopback*' } | ForEach-Object { @{ Interface = $_.InterfaceAlias IPAddress = $_.IPAddress PrefixLength = $_.PrefixLength } } | ConvertTo-Json `; const { stdout } = await execAsync(`powershell -Command "${command.replace(/"/g, '\\"')}"`, { shell: 'powershell.exe' }); let interfaces = []; try { interfaces = JSON.parse(stdout); if (!Array.isArray(interfaces)) { interfaces = [interfaces]; } } catch { interfaces = []; } return { success: true, interfaces }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/powershell.js:52-59 (schema)Tool definition including name, description, and empty input schema (no parameters required).{ name: 'get_network_info', description: '获取网络信息', inputSchema: { type: 'object', properties: {}, }, },
- src/tools/powershell.js:79-80 (registration)Dispatches to the getNetworkInfo handler in the executeTool switch statement.case 'get_network_info': return await this.getNetworkInfo();
- src/tools/powershell.js:64-66 (registration)Includes 'get_network_info' in the list of tools that this handler can process in the canHandle method.const tools = ['run_powershell', 'run_cmd', 'get_system_info', 'get_disk_info', 'get_network_info']; return tools.includes(toolName);