getPublicIP
Retrieve your public IP address using ip-api.com for network diagnostics, system monitoring, or IP geolocation tasks within the Toolkit MCP Server environment.
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 fetches the public IP address from ip-api.com API and returns it as JSON.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 the getPublicIP tool, which requires no parameters.inputSchema: { type: 'object', properties: {} },
- src/tools/network.ts:85-106 (registration)Definition and local registration of the getPublicIP tool within the networkTools export.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)Global registration of networkTools (including getPublicIP) into allTools, which is used by the MCP server for tool listing and execution.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };