getPublicIP
Retrieve your current public IP address to identify network connectivity, configure firewall rules, or troubleshoot remote access issues.
Instructions
Get public IP address using ip-api.com
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/network.ts:92-105 (handler)The handler function that executes the getPublicIP tool logic by fetching the public IP from ip-api.com API.handler: async () => { try { const response = await fetch('http://ip-api.com/json/?fields=query'); const data = await response.json(); return { content: [{ type: 'text', text: JSON.stringify({ ip: data.query }, null, 2) }] }; } catch (error) { throw new Error(`Failed to get public IP: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/tools/network.ts:88-91 (schema)Input schema for getPublicIP tool, which requires no parameters.inputSchema: { type: 'object', properties: {} },
- src/tools/network.ts:85-106 (registration)Registration of the getPublicIP tool within the networkTools object.getPublicIP: { name: 'getPublicIP', description: 'Get public IP address using ip-api.com', inputSchema: { type: 'object', properties: {} }, handler: async () => { try { const response = await fetch('http://ip-api.com/json/?fields=query'); const data = await response.json(); return { content: [{ type: 'text', text: JSON.stringify({ ip: data.query }, null, 2) }] }; } catch (error) { throw new Error(`Failed to get public IP: ${error instanceof Error ? error.message : 'Unknown error'}`); } } },
- src/index.ts:28-35 (registration)The networkTools (containing getPublicIP) are included in the allTools registry used by the MCP server for listing and calling tools.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };