Skip to main content
Glama
ip2location

IP2Location IP Geolocation MCP Server

Official

get_geolocation

Retrieve detailed geolocation data for any IP address, including country, city, network details, proxy information, and security insights.

Instructions

Fetch geolocation for the given IP address.

It helps users to retrieve detailed information such as country, region, city, latitude, longitude, ZIP code, time zone, ASN, and proxy information for any IPv4 or IPv6 address

Args: ip: The IP address to analyze (IPv4 or IPv6).

Returns: A JSON string result includes:

Location & Geography:
Country, region, district, city, ZIP code, latitude & longitude, time zone.

Network & Connectivity
ASN (Autonomous System Number), ISP (Internet Service Provider), domain, net speed, IDD code, area code, address type, usage type.

Mobile Information
MNC (Mobile Network Code), MCC (Mobile Country Code), Mobile Brand.

Currency & Language
currency code, currency name, currency symbol, language code, language name.

Proxy & Security
proxy type, last seen, threat level/type, proxy provider, fraud score.

Others
IAB category, weather, elevation, population and more.

Note that some information may only available in paid plan. Learn more on this in https://www.ip2location.io/pricing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYes

Implementation Reference

  • The main execution logic for the get_geolocation tool: constructs API params with optional key, makes async request to IP2Location.io, returns parsed JSON or error string.
    async def get_geolocation(ip: str) -> Dict[str, Any] | str:
        """
        Fetch geolocation for the given IP address.
        
        It helps users to retrieve detailed information such as country, region, city, latitude, longitude, ZIP code, time zone, ASN, and proxy information for any IPv4 or IPv6 address
    
        Args:
            ip: The IP address to analyze (IPv4 or IPv6).
    
        Returns:
            A JSON string result includes:
            
            Location & Geography:
            Country, region, district, city, ZIP code, latitude & longitude, time zone.
            
            Network & Connectivity
            ASN (Autonomous System Number), ISP (Internet Service Provider), domain, net speed, IDD code, area code, address type, usage type.
            
            Mobile Information
            MNC (Mobile Network Code), MCC (Mobile Country Code), Mobile Brand.
            
            Currency & Language
            currency code, currency name, currency symbol, language code, language name.
            
            Proxy & Security
            proxy type, last seen, threat level/type, proxy provider, fraud score.
            
            Others
            IAB category, weather, elevation, population and more.
            
            Note that some information may only available in paid plan. Learn more on this in https://www.ip2location.io/pricing.
        """
        params = {"ip": ip}
        api_key = get_api_key()
        if api_key:
            params["key"] = api_key  # IP2Location.io API key parameter
    
        geolocation_result = await make_request(IPLIO_API_BASE, params)
    
        if not geolocation_result:
            return f"Unable to fetch geolocation for IP {ip}."
    
        return geolocation_result
  • Helper function that performs the async HTTP request to the IP2Location.io API endpoint with timeout, headers, and exception handling.
    async def make_request(url: str, params: dict[str, str]) -> dict[str, Any] | None:
        """Make a request to the IP2Location.io API with proper error handling."""
        headers = {
            "User-Agent": USER_AGENT,
            "Accept": "application/json"
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, params=params, timeout=30.0)
                response.raise_for_status()
                return response.json()
            except Exception:
                return None
  • Helper function to retrieve the IP2Location.io API key from the IP2LOCATION_API_KEY environment variable.
    def get_api_key() -> str | None:
        """Retrieve the API key from MCP server config."""
        return os.getenv("IP2LOCATION_API_KEY")
  • src/server.py:32-32 (registration)
    The @mcp.tool() decorator registers the get_geolocation function as an MCP tool.
    async def get_geolocation(ip: str) -> Dict[str, Any] | str:
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 adequately describes what the tool does (fetch geolocation data) and mentions the pricing limitation, but doesn't cover important behavioral aspects like rate limits, authentication requirements, error handling, or whether this is a read-only operation. The description doesn't contradict any annotations since none exist.

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

Conciseness3/5

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

The description is front-loaded with the core purpose, but becomes verbose with the detailed breakdown of return values. While the return value details are helpful, they could be more efficiently structured. The pricing note at the end is important but disrupts the flow.

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 single-parameter tool with no annotations and no output schema, the description provides substantial context. It explains the tool's purpose, parameter meaning, and detailed return structure. The main gaps are behavioral aspects like rate limits and error handling, but overall it's quite complete for this complexity level.

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

Parameters5/5

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

With 0% schema description coverage and only one parameter, the description provides excellent parameter semantics. It clearly explains that the 'ip' parameter is 'The IP address to analyze (IPv4 or IPv6)' and provides context about what will be done with this input, which adds significant value beyond the bare schema.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Fetch geolocation for the given IP address' with specific details about what information is retrieved (country, region, city, etc.). It uses a clear verb ('fetch') and resource ('geolocation'), though it doesn't distinguish from siblings since there are none.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions that some information may only be available in paid plans, but doesn't offer any context about appropriate use cases, prerequisites, or limitations beyond the pricing note.

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/ip2location/mcp-ip2location-io'

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