Skip to main content
Glama

get_ip_location

Retrieve latitude and longitude coordinates for any IP address to determine its geographic location. When no IP is specified, returns the coordinates of your current location.

Instructions

Get just the coordinates for an IP address.

Args: ip: IP address to lookup. If None, returns current location.

Returns: Latitude,longitude coordinates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNo

Implementation Reference

  • The MCP tool handler and registration for 'get_ip_location'. This async function executes the tool logic by calling the IPInfoClient to retrieve latitude/longitude coordinates for the specified IP or current IP.
    @mcp.tool() async def get_ip_location(ctx: Context[Any, Any, Any], ip: str | None = None) -> str: """Get just the coordinates for an IP address. Args: ip: IP address to lookup. If None, returns current location. Returns: Latitude,longitude coordinates. """ client = get_client(ctx) try: if ip: return await client.get_location_by_ip(ip) else: return await client.get_current_location() except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
  • Core helper method in IPInfoClient that makes the HTTP request to IPInfo API endpoint /{ip}/loc to fetch the location coordinates string.
    async def get_location_by_ip(self, ip: str) -> str: """Get location coordinates for an IP.""" data = await self._request("GET", f"/{ip}/loc") return str(data.get("result", ""))

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/NimbleBrainInc/mcp-ipinfo'

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