Skip to main content
Glama

get_asn_info

Retrieve detailed information about an Autonomous System Number (ASN), including network prefixes, peer connections, and organizational details for network analysis and intelligence.

Instructions

Get information about an Autonomous System Number (ASN).

Args: asn: The ASN number (without 'AS' prefix)

Returns: ASN information including prefixes, peers, and network details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
asnYes

Implementation Reference

  • The main handler function for the 'get_asn_info' tool, decorated with @mcp.tool() for automatic registration. It retrieves the IPInfo client and calls client.get_asn(asn) to fetch ASN details.
    @mcp.tool() async def get_asn_info(asn: int, ctx: Context[Any, Any, Any]) -> AsnResponse: """Get information about an Autonomous System Number (ASN). Args: asn: The ASN number (without 'AS' prefix) Returns: ASN information including prefixes, peers, and network details. """ client = get_client(ctx) try: return await client.get_asn(asn) except IPInfoAPIError as e: ctx.error(f"API error: {e.message}") raise
  • Pydantic model defining the output schema for the get_asn_info tool response.
    class AsnResponse(BaseModel): asn: str = Field(..., description="ASN identifier") name: str = Field(..., description="Name of the ASN") country: str | None = Field(None, description="Country code") allocated: str | None = Field(None, description="Allocation date") registry: str | None = Field(None, description="Registry name") domain: str = Field(..., description="Domain") num_ips: int | None = Field(None, description="Number of IPs") route: str | None = Field(None, description="Route") type: CompanyType = Field(..., description="Type of organization") prefixes: list[dict[str, Any]] | None = Field(None) prefixes6: list[dict[str, Any]] | None = Field(None) peers: list[str] | None = Field(None) upstreams: list[str] | None = Field(None) downstreams: list[str] | None = Field(None)
  • Helper method in IPInfoClient that makes the actual HTTP GET request to the IPInfo API for ASN data and parses it into AsnResponse.
    async def get_asn(self, asn: int) -> AsnResponse: """Get information about an ASN.""" data = await self._request("GET", f"/AS{asn}") return AsnResponse(**data)
  • Utility function to lazily initialize and retrieve the shared IPInfoClient instance used by all tools including get_asn_info.
    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

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