Skip to main content
Glama
badchars

osint-mcp-server

by badchars

geoip_lookup

Geolocate any IP address to retrieve country, city, ISP, ASN, and detect proxies, hosting, or mobile connections.

Instructions

Geolocate an IP address: country, city, ISP, ASN, proxy/hosting/mobile detection. Uses ip-api.com (free, no API key).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP address to geolocate

Implementation Reference

  • Core handler function that performs a single IP geolocation lookup via ip-api.com free API. Accepts an IP string, applies rate limiting, fetches from http://ip-api.com/json/, and returns a GeoIpResult with country, city, ISP, ASN, proxy/hosting/mobile flags.
    export async function geoipLookup(ip: string): Promise<GeoIpResult> {
      await limiter.acquire();
      // ip-api.com free tier requires HTTP (not HTTPS)
      const res = await fetch(`http://ip-api.com/json/${encodeURIComponent(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 returned ${res.status}`);
      const data = await res.json();
      if (data.status === "fail") throw new Error(`ip-api.com: ${data.message}`);
      return data;
    }
  • GeoIpResult interface defining the response shape: query, status, country, countryCode, region, city, lat/lon, timezone, ISP, org, ASN, and boolean flags for mobile/proxy/hosting.
    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;
    }
  • Tool definition/registration for 'geoip_lookup'. Defines name, description, Zod schema (ip: string), and execute handler that calls geoipLookup().
    const geoipLookupTool: ToolDef = {
      name: "geoip_lookup",
      description: "Geolocate an IP address: country, city, ISP, ASN, proxy/hosting/mobile detection. Uses ip-api.com (free, no API key).",
      schema: {
        ip: z.string().describe("IP address to geolocate"),
      },
      execute: async (args) => json(await geoipLookup(args.ip as string)),
    };
  • Registration of geoipLookupTool in the exported allTools array that collects all tool definitions for the MCP server.
    // GeoIP (2)
    geoipLookupTool,
    geoipBatchTool,
  • RateLimiter class used by geoipLookup to ensure minimum delay (1400ms = ~45 req/min) between requests to ip-api.com free tier.
    // Queue-based rate limiter — ensures minimum delay between requests
    export class RateLimiter {
      private lastRequest = 0;
      private queue: (() => void)[] = [];
      private processing = false;
    
      constructor(private minDelayMs: number) {}
    
      async acquire(): Promise<void> {
        return new Promise<void>((resolve) => {
          this.queue.push(resolve);
          if (!this.processing) this.processQueue();
        });
      }
    
      private async processQueue(): Promise<void> {
        this.processing = true;
        while (this.queue.length > 0) {
          const now = Date.now();
          const elapsed = now - this.lastRequest;
          if (elapsed < this.minDelayMs) {
            await sleep(this.minDelayMs - elapsed);
          }
          this.lastRequest = Date.now();
          const resolve = this.queue.shift();
          resolve?.();
        }
        this.processing = false;
      }
    }
    
    function sleep(ms: number): Promise<void> {
      return new Promise((r) => setTimeout(r, ms));
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It reveals the external dependency and free usage, but omits details like rate limits, error handling, data privacy, or whether it logs queries. It states what data is returned but not the response structure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with action and key details. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple single-parameter lookup tool without output schema, the description covers purpose, backend, and output types. Could add basic error or rate limit context, but overall sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (the single 'ip' parameter has a description), so the baseline is 3. The description adds context about output but does not enhance the parameter's meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it geolocates an IP and lists specific data points (country, city, ISP, ASN, proxy/hosting/mobile detection). This distinguishes it from sibling tools like geoip_batch that process multiple IPs, and from other network tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Mentions the free external service with no API key, implying ease of use. However, no explicit guidance on when to use vs alternatives (e.g., when you need batch lookups) or when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.