get_ip_location
Retrieve geographic location data for any IP address to identify user regions or analyze network traffic origins.
Instructions
Get the location of an IP address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ipAddress | No | The IP address to get the location of. |
Implementation Reference
- src/index.ts:82-98 (handler)Handler logic for the 'get_ip_location' tool within the CallToolRequestSchema handler. It extracts the ipAddress from arguments, calls the helper, handles errors, and returns the result as formatted JSON text.if (request.params.name === "get_ip_location") { const input = request.params.arguments as { ipAddress: string }; const output = await ipfind.apiRequest.getIPLocation(input.ipAddress); if (!output) { throw new Error("Failed to fetch IP location."); } return { content: [ { type: "text", text: JSON.stringify(output, null, 2), }, ], }; }
- src/index.ts:48-59 (schema)Schema definition for the 'get_ip_location' tool, specifying the input as an object with 'ipAddress' string property.name: "get_ip_location", description: "Get the location of an IP address", inputSchema: { type: "object", properties: { ipAddress: { type: "string", description: "The IP address to get the location of.", }, }, }, },
- src/ipfind.ts:32-36 (helper)Helper method in APIRequest class that makes the HTTP request to IPFind API for the given IP address location.async getIPLocation(ip: string): Promise<IPFindIPResponse> { return await this.makeRequest<IPFindIPResponse>( `/?auth=${this.apiKey}&ip=${ip}` ); }