getIpv4Info
Retrieve IPv4 address details for the current device to identify network configuration and connectivity status.
Instructions
获取当前设备的 IPv4 信息
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": "getIpv4Info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:405-429 (handler)Handler implementation for getIpv4Info tool that retrieves IPv4 addresses from network interfaces using os.networkInterfaces(), filters for IPv4, and returns structured JSON.
case "getIpv4Info": { const networkInterfaces = os.networkInterfaces(); const ipInfo: Record<string, { address: string; netmask: string; family: string; internal: boolean }[]> = {}; for (const [interfaceName, interfaces = []] of Object.entries(networkInterfaces)) { const ipv4Interfaces = interfaces .filter((info) => info.family === 'IPv4') .map((info) => ({ address: info.address, netmask: info.netmask, family: info.family, internal: info.internal })); if (ipv4Interfaces.length > 0) { ipInfo[interfaceName] = ipv4Interfaces; } } return { content: [{ type: "text", text: JSON.stringify(ipInfo, null, 2) }] }; } - src/index.ts:100-108 (schema)Tool schema definition including name, description, and empty input schema for getIpv4Info in the tools list.
{ name: "getIpv4Info", description: "获取当前设备的 IPv4 信息", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:790-790 (registration)Registration of the general tool call handler (handleCallToolRequest) which contains the switch case for getIpv4Info.
server.setRequestHandler(CallToolRequestSchema, handleCallToolRequest); - src/index.ts:787-787 (registration)Registration of the list tools handler which includes the schema for getIpv4Info.
server.setRequestHandler(ListToolsRequestSchema, handleRequest);