Skip to main content
Glama

get_ip_postal

Retrieve postal or ZIP code information from any IP address to determine geographic location for location-based services, verification, or analytics.

Instructions

Get just the postal code for an IP address.

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

Returns: Postal or ZIP code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNo

Implementation Reference

  • The main handler function for the 'get_ip_postal' MCP tool. Decorated with @mcp.tool() which handles registration. It fetches the postal code for the specified IP (or current IP) using the IPInfoClient and manages errors via the MCP context.
    @mcp.tool() async def get_ip_postal(ctx: Context[Any, Any, Any], ip: str | None = None) -> str: """Get just the postal code for an IP address. Args: ip: IP address to lookup. If None, returns current postal code. Returns: Postal or ZIP code. """ client = get_client(ctx) try: if ip: return await client.get_postal_by_ip(ip) else: return await client.get_current_postal() except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise

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