get_lab_topology
Retrieve complete network lab topology including nodes, networks, and connections for EVE-NG network emulation environments.
Instructions
Get lab topology information.
This tool retrieves the complete topology of the lab including all nodes, networks, and their connections.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| arguments | Yes |
Implementation Reference
- The primary MCP tool handler for 'get_lab_topology'. It processes arguments, calls the underlying client to fetch topology data, formats connections between nodes and networks into readable text, handles errors, and returns formatted TextContent.@mcp.tool() async def get_lab_topology(arguments: GetTopologyArgs) -> list[TextContent]: """ Get lab topology information. This tool retrieves the complete topology of the lab including all nodes, networks, and their connections. """ try: logger.info(f"Getting topology for lab: {arguments.lab_path}") if not eveng_client.is_connected: return [TextContent( type="text", text="Not connected to EVE-NG server. Use connect_eveng_server tool first." )] # Get topology topology = await eveng_client.get_lab_topology(arguments.lab_path) if not topology.get('data'): return [TextContent( type="text", text=f"No topology information found for lab: {arguments.lab_path}" )] # Format topology information topology_text = f"Lab Topology: {arguments.lab_path}\n\n" topology_data = topology['data'] # Show connections topology_text += "🔗 Connections:\n" if topology_data: for connection_id, connection in topology_data.items(): src_type = "Node" if connection.get('source_type') == 'node' else "Network" dst_type = "Node" if connection.get('destination_type') == 'node' else "Network" topology_text += f" {src_type} {connection.get('source', 'Unknown')}" if connection.get('source_label'): topology_text += f" ({connection.get('source_label')})" topology_text += f" ↔ {dst_type} {connection.get('destination', 'Unknown')}" if connection.get('destination_label'): topology_text += f" ({connection.get('destination_label')})" topology_text += "\n" else: topology_text += " No connections found\n" return [TextContent( type="text", text=topology_text )] except Exception as e: logger.error(f"Failed to get lab topology: {e}") return [TextContent( type="text", text=f"Failed to get lab topology: {str(e)}" )]
- Pydantic model defining the input schema for the get_lab_topology tool, specifying the required lab_path parameter.class GetTopologyArgs(BaseModel): """Arguments for get_lab_topology tool.""" lab_path: str = Field(description="Full path to the lab (e.g., /lab_name.unl)")
- eveng_mcp_server/tools/__init__.py:27-28 (registration)Specific registration call for network management tools within the main register_tools function, which defines and registers get_lab_topology using @mcp.tool() decorator.# Network management tools register_network_tools(mcp, eveng_client)
- eveng_mcp_server/server.py:52-53 (registration)Top-level registration of all MCP tools during server initialization, chaining through to the get_lab_topology tool registration.# Register tools register_tools(self.mcp, self.eveng_client)
- Supporting helper method in EVENGClientWrapper that ensures connection and proxies the raw API call to retrieve lab topology data, invoked by the MCP tool handler.async def get_lab_topology(self, lab_path: str) -> Dict[str, Any]: """Get lab topology information.""" await self.ensure_connected() try: topology = await asyncio.to_thread(self.api.get_lab_topology, lab_path) self.logger.debug("Retrieved lab topology", lab_path=lab_path) return topology except Exception as e: self.logger.error("Failed to get lab topology", **log_error(e, {"lab_path": lab_path})) raise EVENGAPIError(f"Failed to get lab topology: {str(e)}")