Skip to main content
Glama
CloudWaddie

OSINT MCP Server

ip_geolocation

Determine the geographic location of an IP address to support security research and open-source intelligence gathering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYesIP address to geolocate

Implementation Reference

  • The `getLocation` method in `IpApiClient` fetches and returns the IP geolocation data.
    async getLocation(ip: string): Promise<IpGeolocation> {
      try {
        const data = await this.fetch<any>(ip, {
          method: "GET",
        }, {
          fields: "status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,mobile,proxy,hosting,query"
        });
    
        if (data.status === "fail") {
          throw new McpError(
            ErrorCode.InvalidRequest,
            `IP Geolocation failed: ${data.message}`
          );
        }
    
        return IpGeolocationSchema.parse({
          ip: data.query,
          country: data.country,
          countryCode: data.countryCode,
          region: data.region,
          regionName: data.regionName,
          city: data.city,
          zip: data.zip,
          lat: data.lat,
          lon: data.lon,
          timezone: data.timezone,
          isp: data.isp,
          org: data.org,
          as: data.as,
          mobile: data.mobile,
          proxy: data.proxy,
          hosting: data.hosting,
        });
      } catch (error) {
        if (error instanceof McpError) throw error;
        throw new McpError(
          ErrorCode.InternalError,
          `IP Geolocation error: ${(error as Error).message}`
        );
      }
    }
  • src/index.ts:99-108 (registration)
    The `ip_geolocation` tool is registered using the `server.tool` method, which calls the `ipClient.getLocation` handler.
    server.tool(
      "ip_geolocation",
      { ip: z.string().describe("IP address to geolocate") },
      async ({ ip }) => {
        const result = await ipClient.getLocation(ip);
        return {
          content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
        };
      }
    );
  • Zod schema defining the structure of the IP geolocation result.
    export const IpGeolocationSchema = z.object({
      ip: z.string(),
      country: z.string().optional(),
      countryCode: z.string().optional(),
      region: z.string().optional(),
      regionName: z.string().optional(),
      city: z.string().optional(),
      zip: z.string().optional(),
      lat: z.number().optional(),
      lon: z.number().optional(),
      timezone: z.string().optional(),
      isp: z.string().optional(),
      org: z.string().optional(),
      as: z.string().optional(),
      mobile: z.boolean().optional(),
      proxy: z.boolean().optional(),
      hosting: z.boolean().optional(),
    });
    
    export type IpGeolocation = z.infer<typeof IpGeolocationSchema>;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CloudWaddie/osint-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server