test_connection
Verify connectivity to the Nautobot API for network automation and infrastructure data access.
Instructions
Test the connection to the Nautobot API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool handler for 'test_connection': calls NautobotClient.test_connection(), formats the result with connection status, URL, and timestamp, and returns it as formatted text content.elif name == "test_connection": logger.info("Testing Nautobot API connection") # Test connection is_connected = await client.test_connection() result = { "connected": is_connected, "nautobot_url": client.base_url, "timestamp": str(asyncio.get_event_loop().time()) } status_text = "✅ Connected" if is_connected else "❌ Connection Failed" return [ types.TextContent( type="text", text=f"Nautobot API Connection Test: {status_text}\n\n" f"```json\n{result}\n```" ) ]
- src/mcp_nautobot_server/server.py:518-526 (registration)Registration of the 'test_connection' tool in the MCP server's list_tools() method, defining its name, description, and empty input schema.types.Tool( name="test_connection", description="Test the connection to the Nautobot API", inputSchema={ "type": "object", "properties": {}, "additionalProperties": False }, ),
- Core helper method in NautobotClient that tests the API connection by making a GET request to the Nautobot /status/ endpoint and returns True on success or False on failure.async def test_connection(self) -> bool: """ Test the connection to Nautobot API. Returns: True if connection successful, False otherwise """ try: await self._make_request("GET", "/status/") logger.info("Successfully connected to Nautobot API") return True except Exception as e: logger.error(f"Failed to connect to Nautobot API: {e}") return False