Skip to main content
Glama
NimbleBrainInc

IPInfo MCP Server

get_ip_org

Retrieve the organization and ASN details for any IP address to identify network ownership and internet service providers.

Instructions

Get just the organization/ASN for an IP address.

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

Returns: ASN and organization name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNo

Implementation Reference

  • The primary MCP tool handler for 'get_ip_org', decorated with @mcp.tool() for registration. Handles input parameter 'ip' and delegates to IPInfoClient for organization lookup.
    @mcp.tool()
    async def get_ip_org(ctx: Context[Any, Any, Any], ip: str | None = None) -> str:
        """Get just the organization/ASN for an IP address.
    
        Args:
            ip: IP address to lookup. If None, returns current organization.
    
        Returns:
            ASN and organization name.
        """
        client = get_client(ctx)
        try:
            if ip:
                return await client.get_org_by_ip(ip)
            else:
                return await client.get_current_org()
        except IPInfoAPIError as e:
            ctx.error(f"API error: {e.message}")
            raise
  • Utility function to retrieve or lazily initialize the shared IPInfoClient instance used by all tools.
    def get_client(ctx: Context[Any, Any, Any]) -> IPInfoClient:
        """Get or create the API client instance."""
        global _client
        if _client is None:
            api_token = os.environ.get("IPINFO_API_TOKEN")
            if not api_token:
                ctx.warning("IPINFO_API_TOKEN is not set - some features may be limited")
            _client = IPInfoClient(api_token=api_token)
        return _client
  • Core API client methods that perform the HTTP requests to IPInfo.io /org endpoint to fetch the organization string for current IP or specific IP.
    async def get_current_org(self) -> str:
        """Get current ASN organization."""
        data = await self._request("GET", "/org")
        return str(data.get("result", ""))
    
    async def get_org_by_ip(self, ip: str) -> str:
        """Get ASN organization for an IP."""
        data = await self._request("GET", f"/{ip}/org")
        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