Skip to main content
Glama
iplocate

IPLocate

Official
by iplocate

Look up IP Address Details

lookup_ip_address_details

Retrieve geolocation, network details, security information, and abuse contacts for any IPv4 or IPv6 address to identify origin and assess security risks.

Instructions

Get comprehensive information about an IP address including geolocation, network details, privacy/security information, company data, and abuse contacts. Can look up any IPv4 or IPv6 address, or your own IP if no address is provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNoIPv4 or IPv6 address to look up. If not provided, returns information about the caller's IP address.

Implementation Reference

  • The handler function that implements the core logic of the lookup_ip_address_details tool: IP validation, API call, disclaimer addition, and response formatting.
    async ({ ip }) => {
      if (ip && !isValidIP(ip)) {
        return {
          content: [{
            type: "text",
            text: `Error: "${ip}" is not a valid IPv4 or IPv6 address.`
          }],
          isError: true
        };
      }
    
      try {
        const data = await fetchIPData(ip);
    
        const dataWithDisclaimer = {
          ...data,
          disclaimer: DISCLAIMER
        };
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(dataWithDisclaimer, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Input schema for the tool defining the optional 'ip' parameter.
    const IPAddressSchema = {
      ip: z.string().optional().describe("IPv4 or IPv6 address to look up. If not provided, returns information about the caller's IP address.")
    };
  • src/index.ts:92-134 (registration)
    Registration of the lookup_ip_address_details tool with the MCP server, specifying name, metadata, input schema, and handler.
    server.registerTool(
      "lookup_ip_address_details",
      {
        title: "Look up IP Address Details",
        description: "Get comprehensive information about an IP address including geolocation, network details, privacy/security information, company data, and abuse contacts. Can look up any IPv4 or IPv6 address, or your own IP if no address is provided.",
        inputSchema: IPAddressSchema
      },
      async ({ ip }) => {
        if (ip && !isValidIP(ip)) {
          return {
            content: [{
              type: "text",
              text: `Error: "${ip}" is not a valid IPv4 or IPv6 address.`
            }],
            isError: true
          };
        }
    
        try {
          const data = await fetchIPData(ip);
    
          const dataWithDisclaimer = {
            ...data,
            disclaimer: DISCLAIMER
          };
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(dataWithDisclaimer, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );
  • Helper function that performs the actual API request to iplocate.io to retrieve IP address details.
    async function fetchIPData(ip?: string): Promise<IPLocateResponse> {
      const baseUrl = "https://iplocate.io/api/lookup";
      const apiKey = process.env.IPLOCATE_API_KEY;
    
      let url = ip ? `${baseUrl}/${ip}` : `${baseUrl}/`;
    
      // Add API key if available
      if (apiKey) {
        url += `?apikey=${apiKey}`;
      }
    
      try {
        const response = await fetch(url, {
          headers: {
            'User-Agent': `mcp-server-iplocate/${VERSION}`
          }
        });
    
        if (!response.ok) {
          const errorText = await response.text();
          let errorMessage = `API request failed with status ${response.status}`;
    
          try {
            const errorJson = JSON.parse(errorText);
            if (errorJson.error) {
              errorMessage = errorJson.error;
            }
          } catch {
            // If not JSON, use the raw text
            if (errorText) {
              errorMessage = errorText;
            }
          }
    
          throw new Error(errorMessage);
        }
    
        const data = await response.json() as IPLocateResponse;
        return data;
      } catch (error) {
        if (error instanceof Error) {
          throw error;
        }
        throw new Error(`Failed to fetch IP data: ${String(error)}`);
      }
    }
  • Helper function to validate if a given string is a valid IPv4 or IPv6 address.
    function isValidIP(ip: string): boolean {
      // IPv4 pattern
      const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}$/;
      // IPv6 pattern (simplified)
      const ipv6Pattern = /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/;
    
      if (ipv4Pattern.test(ip)) {
        // Validate IPv4 octets
        const octets = ip.split('.');
        return octets.every(octet => {
          const num = parseInt(octet, 10);
          return num >= 0 && num <= 255;
        });
      }
    
      return ipv6Pattern.test(ip);
    }
  • TypeScript interface defining the structure of the IP location response data used by the tool.
    export interface IPLocateResponse {
      ip: string;
      country?: string | null;
      country_code?: string | null;
      is_eu?: boolean;
      city?: string | null;
      continent?: string | null;
      latitude?: number | null;
      longitude?: number | null;
      time_zone?: string | null;
      postal_code?: string | null;
      subdivision?: string | null;
      currency_code?: string | null;
      calling_code?: string | null;
      network?: string | null;
      asn?: ASNInfo | null;
      privacy?: PrivacyInfo;
      company?: CompanyInfo | null;
      hosting?: HostingInfo | null;
      abuse?: AbuseInfo | null;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's scope (IPv4/IPv6 addresses, default to caller's IP) and the types of information returned. However, it doesn't mention potential limitations like rate limits, data freshness, accuracy, or error handling for invalid inputs, which would be valuable for a tool with no annotation coverage.

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?

The description is perfectly front-loaded and efficient: the first sentence establishes the comprehensive scope, and the second sentence clarifies input flexibility and default behavior. Every word earns its place with zero redundancy, making it easy for an agent to quickly understand the tool's purpose and usage.

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?

Given the tool's moderate complexity (single optional parameter, no output schema, no annotations), the description does an excellent job covering purpose, usage guidelines, and parameter semantics. However, without annotations or output schema, it could benefit from more behavioral details about response format, error conditions, or data sources to achieve full completeness for agent invocation.

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

Parameters4/5

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

The schema description coverage is 100%, so the baseline is 3. The description adds meaningful context by explaining that the tool can look up 'any IPv4 or IPv6 address' and clarifies the default behavior when no address is provided ('returns information about the caller's IP address'), which complements the schema's parameter description. This additional semantic context justifies a score above baseline.

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?

The description clearly states the verb ('Get') and resource ('comprehensive information about an IP address') with specific details about what information is included (geolocation, network details, privacy/security information, company data, and abuse contacts). It explicitly distinguishes this comprehensive tool from its specialized sibling tools that focus on individual aspects like abuse contacts, company, location, network, or privacy.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: it states that this tool provides 'comprehensive information' covering multiple aspects, while the sibling tools (lookup_ip_address_abuse_contacts, lookup_ip_address_company, etc.) are specialized for specific data types. It also clarifies the default behavior when no IP is provided (returns caller's IP information).

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

Install Server

Other Tools

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/iplocate/mcp-server-iplocate'

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