Skip to main content
Glama
aiopnet

MCP Nautobot Server

by aiopnet

get_ip_address_by_id

Retrieve a specific IP address from Nautobot by providing its unique ID. Facilitates network automation and infrastructure data queries through the MCP Nautobot Server integration.

Instructions

Retrieve a specific IP address by its Nautobot ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ip_idYesThe Nautobot ID of the IP address

Implementation Reference

  • MCP tool handler in handle_call_tool that validates ip_id argument, calls NautobotClient.get_ip_address_by_id, and formats the response as JSON text content or not found message.
    elif name == "get_ip_address_by_id": ip_id = args.get("ip_id") if not ip_id: raise ValueError("ip_id is required") logger.info(f"Retrieving IP address by ID: {ip_id}") # Get specific IP address ip_address = await client.get_ip_address_by_id(ip_id) if ip_address is None: return [ types.TextContent( type="text", text=f"IP address with ID '{ip_id}' not found in Nautobot." ) ] result = ip_address.model_dump() return [ types.TextContent( type="text", text=f"Retrieved IP address from Nautobot:\n\n" f"```json\n{result}\n```" ) ]
  • Pydantic model defining the output structure for IP address data returned by the tool.
    class IPAddress(BaseModel): """Pydantic model for Nautobot IP address data.""" id: str url: HttpUrl address: str status: Dict[str, Any] role: Optional[Dict[str, Any]] = None tenant: Optional[Dict[str, Any]] = None vrf: Optional[Dict[str, Any]] = None nat_inside: Optional[Dict[str, Any]] = None nat_outside: Optional[Dict[str, Any]] = None dns_name: Optional[str] = None description: Optional[str] = None comments: Optional[str] = None tags: List[Dict[str, Any]] = Field(default_factory=list) custom_fields: Dict[str, Any] = Field(default_factory=dict) created: str last_updated: str
  • Registers the tool with MCP server including name, description, and input schema requiring 'ip_id' parameter.
    types.Tool( name="get_ip_address_by_id", description="Retrieve a specific IP address by its Nautobot ID", inputSchema={ "type": "object", "properties": { "ip_id": { "type": "string", "description": "The Nautobot ID of the IP address" } }, "required": ["ip_id"], "additionalProperties": False }, ),
  • Core helper method that performs the actual API request to Nautobot to fetch IP address by ID, parses into IPAddress model, returns None on 404.
    async def get_ip_address_by_id(self, ip_id: str) -> Optional[IPAddress]: """ Retrieve a specific IP address by its ID. Args: ip_id: The IP address ID Returns: IPAddress object or None if not found Raises: NautobotError: For API or connection errors """ try: response = await self._make_request("GET", f"/ipam/ip-addresses/{ip_id}/") return IPAddress(**response) except NautobotAPIError as e: if e.status_code == 404: return None raise

Other Tools

Related Tools

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/aiopnet/mcp-nautobot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server