Skip to main content
Glama
aiopnet

MCP Nautobot Server

by aiopnet

get_ip_addresses

Retrieve IP addresses from Nautobot using filters for address, prefix, status, role, tenant, or VRF to manage network inventory.

Instructions

Retrieve IP addresses from Nautobot with filtering options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNoSpecific IP address to search for
prefixNoNetwork prefix to filter by (e.g., 10.0.0.0/24)
statusNoStatus to filter by (e.g., active, reserved, deprecated)
roleNoRole to filter by (e.g., loopback, secondary, anycast)
tenantNoTenant to filter by
vrfNoVRF to filter by
limitNoMaximum number of results to return (default: 100, max: 1000)
offsetNoNumber of results to skip for pagination (default: 0)

Implementation Reference

  • MCP tool handler implementation for 'get_ip_addresses': extracts input arguments, calls NautobotClient.get_ip_addresses with filters, formats results as JSON and returns as TextContent.
    if name == "get_ip_addresses":
        # Extract and validate arguments
        address = args.get("address")
        prefix = args.get("prefix") 
        status = args.get("status")
        role = args.get("role")
        tenant = args.get("tenant")
        vrf = args.get("vrf")
        limit = min(args.get("limit", 100), 1000)  # Cap at 1000
        offset = args.get("offset", 0)
        
        logger.info(f"Retrieving IP addresses with filters: {args}")
        
        # Get IP addresses from Nautobot
        ip_addresses = await client.get_ip_addresses(
            address=address,
            prefix=prefix,
            status=status,
            role=role,
            tenant=tenant,
            vrf=vrf,
            limit=limit,
            offset=offset
        )
        
        # Format results
        result = {
            "count": len(ip_addresses),
            "filters_applied": {k: v for k, v in args.items() if v is not None},
            "results": [ip.model_dump() for ip in ip_addresses]
        }
        
        return [
            types.TextContent(
                type="text",
                text=f"Retrieved {len(ip_addresses)} IP addresses from Nautobot:\n\n"
                     f"```json\n{result}\n```"
            )
        ]
  • Input schema (JSON Schema) for the 'get_ip_addresses' tool, defining parameters like address, prefix, status, role, tenant, vrf, limit, offset.
    inputSchema={
        "type": "object",
        "properties": {
            "address": {
                "type": "string",
                "description": "Specific IP address to search for"
            },
            "prefix": {
                "type": "string", 
                "description": "Network prefix to filter by (e.g., 10.0.0.0/24)"
            },
            "status": {
                "type": "string",
                "description": "Status to filter by (e.g., active, reserved, deprecated)"
            },
            "role": {
                "type": "string",
                "description": "Role to filter by (e.g., loopback, secondary, anycast)"
            },
            "tenant": {
                "type": "string",
                "description": "Tenant to filter by"
            },
            "vrf": {
                "type": "string",
                "description": "VRF to filter by"
            },
            "limit": {
                "type": "integer",
                "description": "Maximum number of results to return (default: 100, max: 1000)",
                "default": 100,
                "minimum": 1,
                "maximum": 1000
            },
            "offset": {
                "type": "integer", 
                "description": "Number of results to skip for pagination (default: 0)",
                "default": 0,
                "minimum": 0
            }
        },
        "additionalProperties": False
    },
  • Registration of the 'get_ip_addresses' tool in the handle_list_tools() function, including name, description, and input schema.
    types.Tool(
        name="get_ip_addresses",
        description="Retrieve IP addresses from Nautobot with filtering options",
        inputSchema={
            "type": "object",
            "properties": {
                "address": {
                    "type": "string",
                    "description": "Specific IP address to search for"
                },
                "prefix": {
                    "type": "string", 
                    "description": "Network prefix to filter by (e.g., 10.0.0.0/24)"
                },
                "status": {
                    "type": "string",
                    "description": "Status to filter by (e.g., active, reserved, deprecated)"
                },
                "role": {
                    "type": "string",
                    "description": "Role to filter by (e.g., loopback, secondary, anycast)"
                },
                "tenant": {
                    "type": "string",
                    "description": "Tenant to filter by"
                },
                "vrf": {
                    "type": "string",
                    "description": "VRF to filter by"
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum number of results to return (default: 100, max: 1000)",
                    "default": 100,
                    "minimum": 1,
                    "maximum": 1000
                },
                "offset": {
                    "type": "integer", 
                    "description": "Number of results to skip for pagination (default: 0)",
                    "default": 0,
                    "minimum": 0
                }
            },
            "additionalProperties": False
        },
    ),
  • Core handler in NautobotClient: constructs API query parameters from filters, makes GET request to /ipam/ip-addresses/, parses JSON response into list of IPAddress Pydantic models.
    async def get_ip_addresses(
        self,
        address: Optional[str] = None,
        prefix: Optional[str] = None,
        status: Optional[str] = None,
        role: Optional[str] = None,
        tenant: Optional[str] = None,
        vrf: Optional[str] = None,
        limit: int = 100,
        offset: int = 0
    ) -> List[IPAddress]:
        """
        Retrieve IP addresses from Nautobot.
        
        Args:
            address: Filter by specific IP address
            prefix: Filter by network prefix
            status: Filter by status slug
            role: Filter by role slug
            tenant: Filter by tenant slug
            vrf: Filter by VRF name
            limit: Maximum number of results to return
            offset: Number of results to skip
            
        Returns:
            List of IPAddress objects
            
        Raises:
            NautobotError: For API or connection errors
        """
        params: Dict[str, Any] = {
            "limit": limit,
            "offset": offset,
        }
        
        # Add optional filters
        if address:
            params["address"] = address
        if prefix:
            params["parent"] = prefix
        if status:
            params["status"] = status
        if role:
            params["role"] = role
        if tenant:
            params["tenant"] = tenant
        if vrf:
            params["vrf"] = vrf
        
        try:
            response = await self._make_request("GET", "/ipam/ip-addresses/", params)
            
            # Parse results
            ip_addresses = []
            for item in response.get("results", []):
                try:
                    ip_addresses.append(IPAddress(**item))
                except Exception as e:
                    logger.warning(f"Failed to parse IP address data: {e}")
                    continue
            
            logger.info(f"Retrieved {len(ip_addresses)} IP addresses")
            return ip_addresses
            
        except Exception as e:
            logger.error(f"Failed to retrieve IP addresses: {e}")
            raise
  • Pydantic schema/model for IPAddress objects returned by the tool, defining structure for parsing Nautobot API responses.
    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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'filtering options' but doesn't describe important behaviors like pagination details (implied by limit/offset parameters), authentication requirements, rate limits, error conditions, or what format the results will be returned in. The description is insufficient for a tool with 8 parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose without unnecessary words. It's appropriately sized for a retrieval tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 8 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, how results are structured, or important behavioral aspects like authentication needs or error handling. The description fails to compensate for the lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already documents all 8 parameters thoroughly. The description adds no additional parameter semantics beyond mentioning 'filtering options' generically. The baseline score of 3 is appropriate since the schema does the heavy lifting for parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Retrieve') and resource ('IP addresses from Nautobot'), making the tool's purpose understandable. It distinguishes itself from 'get_ip_address_by_id' by retrieving multiple addresses with filtering, but doesn't explicitly differentiate from 'search_ip_addresses' which might offer similar functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_ip_addresses' or 'get_ip_address_by_id'. It mentions 'filtering options' but doesn't specify use cases, prerequisites, or when other tools might be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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