getIpv4Info
Retrieve IPv4 address details for the current device to identify network configuration and connectivity status.
Instructions
获取当前设备的 IPv4 信息
Input Schema
TableJSON 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);