get_network_info
Retrieve network configuration details from Windows systems to monitor connectivity and troubleshoot network issues.
Instructions
获取网络信息
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": "get_network_info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/powershell.js:185-215 (handler)The handler function that runs a PowerShell command to get IPv4 network addresses from non-loopback interfaces, parses the JSON output, and returns the interfaces list.
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:55-58 (schema)Input schema definition for the get_network_info tool (no required properties).
inputSchema: { type: 'object', properties: {}, }, - src/tools/powershell.js:52-59 (registration)Tool definition registration in getToolDefinitions(), including name, description, and schema.
{ name: 'get_network_info', description: '获取网络信息', inputSchema: { type: 'object', properties: {}, }, }, - src/tools/powershell.js:78-80 (registration)Registration in the executeTool switch statement that routes to the getNetworkInfo handler.
return await this.getDiskInfo(); case 'get_network_info': return await this.getNetworkInfo(); - src/tools/powershell.js:63-66 (registration)canHandle method registers get_network_info in the supported tools array.
canHandle(toolName) { const tools = ['run_powershell', 'run_cmd', 'get_system_info', 'get_disk_info', 'get_network_info']; return tools.includes(toolName);