Skip to main content
Glama

get_ip_region

Retrieve the geographic region or state associated with an IP address to determine location-based information for network analysis or geolocation purposes.

Instructions

Get just the region/state for an IP address.

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

Returns: Region or state name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNo

Implementation Reference

  • The handler function implementing the 'get_ip_region' tool logic. Decorated with @mcp.tool() for automatic registration in the FastMCP server. Delegates to IPInfoClient methods for API calls.
    @mcp.tool() async def get_ip_region(ctx: Context[Any, Any, Any], ip: str | None = None) -> str: """Get just the region/state for an IP address. Args: ip: IP address to lookup. If None, returns current region. Returns: Region or state name. """ client = get_client(ctx) try: if ip: return await client.get_region_by_ip(ip) else: return await client.get_current_region() except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
  • Supporting helper methods in the IPInfoClient class that handle the actual HTTP requests to the IPInfo API for retrieving region information.
    async def get_current_region(self) -> str: """Get current region.""" data = await self._request("GET", "/region") return str(data.get("result", "")) async def get_region_by_ip(self, ip: str) -> str: """Get region for an IP.""" data = await self._request("GET", f"/{ip}/region") 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