get_carrier_info
Retrieve mobile carrier details for any IP address, including MCC and MNC codes, to identify network operators and their associated mobile networks.
Instructions
Get mobile carrier information for an IP address.
Args: ip: IP address to lookup
Returns: Mobile carrier details including MCC and MNC codes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes |
Implementation Reference
- src/mcp_ipinfo/server.py:188-203 (handler)The main handler function for the 'get_carrier_info' tool, decorated with @mcp.tool() for automatic registration in FastMCP. It fetches the IPInfo client and calls its get_carrier method to retrieve carrier information for the given IP, handling API errors.@mcp.tool() async def get_carrier_info(ip: str, ctx: Context[Any, Any, Any]) -> CarrierResponse: """Get mobile carrier information for an IP address. Args: ip: IP address to lookup Returns: Mobile carrier details including MCC and MNC codes. """ client = get_client(ctx) try: return await client.get_carrier(ip) except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
- src/mcp_ipinfo/api_models.py:46-50 (schema)Pydantic BaseModel defining the structure of the CarrierResponse returned by the get_carrier_info tool, including carrier name, MCC, and MNC fields.class CarrierResponse(BaseModel): name: str = Field(..., description="Carrier name") mcc: str = Field(..., description="Mobile Country Code") mnc: str = Field(..., description="Mobile Network Code")
- src/mcp_ipinfo/server.py:188-188 (registration)The @mcp.tool() decorator on the get_carrier_info function registers it as an MCP tool.@mcp.tool()