get_company_info
Retrieve company details including name, domain, and type associated with any IP address to identify network ownership and organizational information.
Instructions
Get company information for an IP address.
Args: ip: IP address to lookup
Returns: Company name, domain, and type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes |
Implementation Reference
- src/mcp_ipinfo/server.py:167-182 (handler)The primary handler function for the 'get_company_info' MCP tool. It is decorated with @mcp.tool() for registration and executes the tool logic by calling IPInfoClient.get_company(ip).@mcp.tool() async def get_company_info(ip: str, ctx: Context[Any, Any, Any]) -> CompanyResponse: """Get company information for an IP address. Args: ip: IP address to lookup Returns: Company name, domain, and type. """ client = get_client(ctx) try: return await client.get_company(ip) except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
- src/mcp_ipinfo/api_models.py:40-44 (schema)Pydantic BaseModel defining the output schema (CompanyResponse) for the get_company_info tool, including fields for name, domain, and type.class CompanyResponse(BaseModel): name: str = Field(..., description="Company name") domain: str = Field(..., description="Company domain") type: CompanyType = Field(..., description="Company type")
- src/mcp_ipinfo/api_client.py:188-192 (helper)Supporting method in IPInfoClient that makes the HTTP request to IPInfo API's /{ip}/company endpoint and parses the response into CompanyResponse.async def get_company(self, ip: str) -> CompanyResponse: """Get company information for an IP.""" data = await self._request("GET", f"/{ip}/company") return CompanyResponse(**data)
- src/mcp_ipinfo/api_models.py:7-13 (schema)Enum defining the possible company types used in the CompanyResponse schema for get_company_info.class CompanyType(str, Enum): ISP = "isp" BUSINESS = "business" EDUCATION = "education" HOSTING = "hosting" INACTIVE = "inactive"
- src/mcp_ipinfo/server.py:29-38 (helper)Utility function to obtain or initialize the shared IPInfoClient instance, used by get_company_info and other 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