test_connection
Verify connectivity to the Nautobot API by executing a test through the MCP Nautobot Server, ensuring seamless integration with network automation and source of truth systems.
Instructions
Test the connection to the Nautobot API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler for the 'test_connection' tool within the handle_call_tool function. It tests the connection using the NautobotClient and returns a formatted result.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 list_tools handler, including its name, description, and input schema.types.Tool( name="test_connection", description="Test the connection to the Nautobot API", inputSchema={ "type": "object", "properties": {}, "additionalProperties": False }, ),
- The NautobotClient.test_connection() helper method that performs the actual API connection test by requesting the /status/ endpoint.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