Skip to main content
Glama
moimran

EVE-NG MCP Server

by moimran

create_lab_network

Add a network (bridge, cloud, NAT) to an EVE-NG lab topology with configurable positioning for network emulation setups.

Instructions

Create a network in a lab.

This tool creates a new network (cloud, bridge, NAT, etc.) in the lab with the specified type and positioning.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argumentsYes

Implementation Reference

  • The main handler function for the 'create_lab_network' tool. It handles input validation, EVE-NG connection check, creates the network using eveng_client.add_lab_network, and returns formatted TextContent responses.
    @mcp.tool()
    async def create_lab_network(arguments: CreateNetworkArgs) -> list[TextContent]:
        """
        Create a network in a lab.
    
        This tool creates a new network (cloud, bridge, NAT, etc.) in the lab
        with the specified type and positioning.
        """
        try:
            logger.info(f"Creating network in 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."
                )]
    
            # Create network
            result = await eveng_client.add_lab_network(
                arguments.lab_path,
                arguments.network_type,
                name=arguments.name,
                left=arguments.left,
                top=arguments.top,
                visibility=1  # Make network visible by default
            )
    
            if result.get('status') == 'success':
                net_id = result.get('data', {}).get('id', 'Unknown')
                return [TextContent(
                    type="text",
                    text=f"Successfully created network in lab!\n\n"
                         f"Lab: {arguments.lab_path}\n"
                         f"Network Type: {arguments.network_type}\n"
                         f"Network ID: {net_id}\n"
                         f"Name: {arguments.name or f'Network{net_id}'}\n"
                         f"Position: ({arguments.left}%, {arguments.top}%)\n\n"
                         f"Network created successfully. You can now connect nodes to it."
                )]
            else:
                return [TextContent(
                    type="text",
                    text=f"Failed to create network: {result.get('message', 'Unknown error')}"
                )]
    
        except Exception as e:
            logger.error(f"Failed to create network: {e}")
            return [TextContent(
                type="text",
                text=f"Failed to create network: {str(e)}"
            )]
  • Pydantic model defining the input schema (arguments) for the create_lab_network tool.
    class CreateNetworkArgs(BaseModel):
        """Arguments for create_network tool."""
        lab_path: str = Field(description="Full path to the lab (e.g., /lab_name.unl)")
        network_type: str = Field(description="Network type (bridge, cloud, nat, etc.)")
        name: str = Field(default="", description="Network name (optional)")
        left: int = Field(default=50, description="Position from left (percentage, 0-100)")
        top: int = Field(default=50, description="Position from top (percentage, 0-100)")
  • Registration of network management tools, including create_lab_network, by calling register_network_tools during the overall tools registration process.
    # Network management tools
    register_network_tools(mcp, eveng_client)
  • Top-level registration call in the server initialization that triggers the registration of all tools, including create_lab_network.
    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