Skip to main content
Glama
aiopnet

MCP Nautobot Server

by aiopnet

search_ip_addresses

Search IP addresses in Nautobot by querying IP addresses, descriptions, or other network data to retrieve infrastructure information.

Instructions

Search IP addresses using a general query string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (can match IP address, description, etc.)
limitNoMaximum number of results to return (default: 50, max: 500)

Implementation Reference

  • Specific handler logic within the shared handle_call_tool function for executing the search_ip_addresses tool: validates input parameters, calls the Nautobot client helper, formats the results as JSON, and returns a formatted text response.
    elif name == "search_ip_addresses":
        query = args.get("query")
        if not query:
            raise ValueError("query is required")
        
        limit = min(args.get("limit", 50), 500)  # Cap at 500 for search
        
        logger.info(f"Searching IP addresses with query: {query}")
        
        # Search IP addresses
        ip_addresses = await client.search_ip_addresses(query, limit)
        
        # Format results
        result = {
            "query": query,
            "count": len(ip_addresses),
            "results": [ip.model_dump() for ip in ip_addresses]
        }
        
        return [
            types.TextContent(
                type="text",
                text=f"Found {len(ip_addresses)} IP addresses matching '{query}':\n\n"
                     f"```json\n{result}\n```"
            )
        ]
  • Input schema defining parameters for the search_ip_addresses tool: requires 'query' string, optional 'limit' integer (default 50, 1-500).
    inputSchema={
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "Search query (can match IP address, description, etc.)"
            },
            "limit": {
                "type": "integer",
                "description": "Maximum number of results to return (default: 50, max: 500)",
                "default": 50,
                "minimum": 1,
                "maximum": 500
            }
        },
        "required": ["query"],
        "additionalProperties": False
    },
  • Registration of the search_ip_addresses tool in the @server.list_tools() handler, defining name, description, and input schema.
    types.Tool(
        name="search_ip_addresses",
        description="Search IP addresses using a general query string",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search query (can match IP address, description, etc.)"
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum number of results to return (default: 50, max: 500)",
                    "default": 50,
                    "minimum": 1,
                    "maximum": 500
                }
            },
            "required": ["query"],
            "additionalProperties": False
        },
    ),
  • NautobotClient helper method implementing the core search logic: sends GET request to /ipam/ip-addresses/ with q=query and limit params, parses response into IPAddress objects.
    async def search_ip_addresses(
        self, 
        query: str, 
        limit: int = 50
    ) -> List[IPAddress]:
        """
        Search IP addresses using a general query.
        
        Args:
            query: Search query (can be IP, description, etc.)
            limit: Maximum number of results
            
        Returns:
            List of matching IPAddress objects
        """
        params: Dict[str, Any] = {
            "q": query,
            "limit": limit,
        }
        
        try:
            response = await self._make_request("GET", "/ipam/ip-addresses/", params)
            
            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"Found {len(ip_addresses)} IP addresses matching '{query}'")
            return ip_addresses
            
        except Exception as e:
            logger.error(f"Failed to search IP addresses: {e}")
            raise
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'Search' but doesn't disclose behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what happens on no matches. The description is minimal and lacks critical context for safe and effective use.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, with every element contributing to clarity.

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

Completeness3/5

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

Given no annotations and no output schema, the description is incomplete for a search tool with 2 parameters. It covers the basic purpose but lacks details on behavior, return values, or error handling. However, the high schema coverage and simple structure keep it from being severely inadequate.

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?

Schema description coverage is 100%, with clear documentation for 'query' (matches IP address, description, etc.) and 'limit' (default, max). The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high coverage without compensating value.

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 ('Search') and resource ('IP addresses') with the method ('using a general query string'). It distinguishes from siblings like 'get_ip_address_by_id' (specific ID lookup) and 'get_ip_addresses' (likely unfiltered list) by specifying search functionality, though it doesn't explicitly name these alternatives.

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

Usage Guidelines3/5

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

The description implies usage for searching IP addresses with a query, suggesting it's for filtered retrieval versus unfiltered listing. However, it doesn't explicitly state when to use this tool over siblings like 'get_ip_addresses' or 'get_ip_address_by_id', nor does it provide exclusion criteria or prerequisites.

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