geoip_batch
Batch geolocate up to 100 IP addresses at once using ip-api.com's free API.
Instructions
Batch geolocate up to 100 IP addresses at once. Uses ip-api.com (free, no API key).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ips | Yes | IP addresses to geolocate (max 100) |
Implementation Reference
- src/geoip/index.ts:42-59 (handler)The main handler function for geoip_batch. Sends up to 100 IPs to ip-api.com/batch via POST and returns GeoIpResult[].
export async function geoipBatch(ips: string[]): Promise<GeoIpResult[]> { if (ips.length === 0) return []; const batch = ips.slice(0, 100); await limiter.acquire(); const res = await fetch("http://ip-api.com/batch", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify( batch.map((ip) => ({ query: ip, fields: "status,message,query,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,asname,mobile,proxy,hosting", })), ), }); if (!res.ok) throw new Error(`ip-api.com batch returned ${res.status}`); return res.json(); } - src/protocol/tools.ts:330-337 (schema)ToolDef registration including name, description, and Zod schema (ips: z.array(z.string())).
const geoipBatchTool: ToolDef = { name: "geoip_batch", description: "Batch geolocate up to 100 IP addresses at once. Uses ip-api.com (free, no API key).", schema: { ips: z.array(z.string()).describe("IP addresses to geolocate (max 100)"), }, execute: async (args) => json(await geoipBatch(args.ips as string[])), }; - src/protocol/tools.ts:514-514 (registration)Tool registered in the allTools array alongside geoip_lookup.
geoipBatchTool, - src/index.ts:30-30 (registration)Tool listed in the top-level index.ts tool catalog under 'GeoIP' group.
{ label: "GeoIP", env: null, tools: ["geoip_lookup", "geoip_batch"] }, - src/geoip/index.ts:7-26 (helper)GeoIpResult interface defining the return type for geoip_batch results.
interface GeoIpResult { query: string; status: string; country?: string; countryCode?: string; region?: string; regionName?: string; city?: string; zip?: string; lat?: number; lon?: number; timezone?: string; isp?: string; org?: string; as?: string; asname?: string; mobile?: boolean; proxy?: boolean; hosting?: boolean; }