Skip to main content
Glama
moimran

EVE-NG MCP Server

by moimran

connect_node_to_node

Create direct point-to-point connections between nodes in EVE-NG network labs to enable communication between devices.

Instructions

Connect two nodes together directly.

This tool creates a direct point-to-point connection between two nodes in the lab, enabling direct communication between them.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argumentsYes

Implementation Reference

  • MCP tool handler: @mcp.tool()-decorated function that validates arguments, checks connection, calls eveng_client.connect_node_to_node, and returns formatted TextContent response.
    @mcp.tool()
    async def connect_node_to_node(arguments: ConnectNodeToNodeArgs) -> list[TextContent]:
        """
        Connect two nodes together directly.
    
        This tool creates a direct point-to-point connection between two nodes
        in the lab, enabling direct communication between them.
        """
        try:
            logger.info(f"Connecting node {arguments.src_node_id} to node {arguments.dst_node_id}")
    
            if not eveng_client.is_connected:
                return [TextContent(
                    type="text",
                    text="Not connected to EVE-NG server. Use connect_eveng_server tool first."
                )]
    
            # Connect nodes together
            result = await eveng_client.connect_node_to_node(
                arguments.lab_path,
                arguments.src_node_id,
                arguments.src_interface,
                arguments.dst_node_id,
                arguments.dst_interface
            )
    
            if result:  # connect_node_to_node returns boolean
                return [TextContent(
                    type="text",
                    text=f"Successfully connected nodes!\n\n"
                         f"Lab: {arguments.lab_path}\n"
                         f"Source Node: {arguments.src_node_id} ({arguments.src_interface})\n"
                         f"Destination Node: {arguments.dst_node_id} ({arguments.dst_interface})\n\n"
                         f"Point-to-point connection established successfully."
                )]
            else:
                return [TextContent(
                    type="text",
                    text="Failed to connect nodes: Connection could not be established."
                )]
    
        except Exception as e:
            logger.error(f"Failed to connect nodes: {e}")
            return [TextContent(
                type="text",
                text=f"Failed to connect nodes: {str(e)}"
            )]
  • Pydantic BaseModel defining the input schema/arguments for the connect_node_to_node tool.
    class ConnectNodeToNodeArgs(BaseModel):
        """Arguments for connect_node_to_node tool."""
        lab_path: str = Field(description="Full path to the lab (e.g., /lab_name.unl)")
        src_node_id: str = Field(description="Source node ID")
        src_interface: str = Field(description="Source node interface name")
        dst_node_id: str = Field(description="Destination node ID")
        dst_interface: str = Field(description="Destination node interface name")
  • Helper method in EVENGClientWrapper that wraps the underlying evengsdk.api.connect_node_to_node call with error handling and logging.
    async def connect_node_to_node(self, lab_path: str, src: str, src_label: str, dst: str, dst_label: str) -> Dict[str, Any]:
        """Connect two nodes together."""
        await self.ensure_connected()
    
        try:
            result = await asyncio.to_thread(self.api.connect_node_to_node, lab_path, src, src_label, dst, dst_label)
            self.logger.info("Connected nodes", lab_path=lab_path, src=src, dst=dst)
            return result
        except Exception as e:
            self.logger.error("Failed to connect nodes", **log_error(e, {"lab_path": lab_path, "src": src, "dst": dst}))
            raise EVENGAPIError(f"Failed to connect nodes: {str(e)}")
  • Registration call for network tools (including connect_node_to_node) during overall tools registration.
    # Network management tools
    register_network_tools(mcp, eveng_client)
  • Top-level registration of all tools in the MCP server startup.
    # Register tools
    register_tools(self.mcp, self.eveng_client)

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/moimran/eveng-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server