This guide helps you set up WireGuard VPN for use with the MCP Remote Testing server.
The MCP server can automatically detect WireGuard configurations in common locations. If you already have a WireGuard config, you may not need to do anything!
The server searches for VPN configs in this order:
- Environment variable:
VPN_CONFIG_PATH(if set) - Secrets directory:
{LAB_TESTING_ROOT}/secrets/wg0.conf(orwireguard.conf,vpn.conf) - User config:
~/.config/wireguard/*.conf - System config:
/etc/wireguard/*.conf
If your config is in a non-standard location:
export VPN_CONFIG_PATH=/path/to/your/wg0.confOr in Cursor MCP config:
{
"mcpServers": {
"ai-lab-testing": {
"command": "python3.10",
"args": ["/path/to/lab_testing/server.py"],
"env": {
"LAB_TESTING_ROOT": "/path/to/ai-lab-testing",
"VPN_CONFIG_PATH": "/path/to/your/wg0.conf"
}
}
}
}Debian/Ubuntu:
sudo apt update
sudo apt install wireguard-toolsRHEL/CentOS:
sudo yum install wireguard-toolsArch Linux:
sudo pacman -S wireguard-toolsmacOS:
brew install wireguard-toolsFor connecting without root privileges:
Debian/Ubuntu:
sudo apt install network-manager network-manager-wireguardThe MCP server provides tools to help you set up WireGuard:
-
Check if WireGuard is installed:
- Use tool:
check_wireguard_installed
- Use tool:
-
Get setup instructions:
- Use tool:
vpn_setup_instructions
- Use tool:
-
Create a config template:
- Use tool:
create_vpn_config_template - This creates a template at
{LAB_TESTING_ROOT}/secrets/wg0.conf
- Use tool:
-
Edit the template with your VPN server details:
- Private key (generate with:
wg genkey) - Server public key
- Server endpoint
- Allowed IPs (lab network subnets)
- Private key (generate with:
-
Import into NetworkManager (optional):
- Use tool:
setup_networkmanager_vpn - This allows connecting without root
- Use tool:
# Generate private key
wg genkey | tee privatekey | wg pubkey > publickey
# View your public key (share with VPN server admin)
cat publickeyCreate {LAB_TESTING_ROOT}/secrets/wg0.conf:
[Interface]
# Your private key (from Step 1)
PrivateKey = YOUR_PRIVATE_KEY_HERE
# Your local IP address on the VPN network
Address = 10.0.0.X/24
# Optional: DNS servers
# DNS = 8.8.8.8
[Peer]
# Server's public key (from your VPN administrator)
PublicKey = SERVER_PUBLIC_KEY_HERE
# Server endpoint
Endpoint = vpn.example.com:51820
# Allowed IPs (routes to send through VPN)
# Use specific subnets for lab network only:
AllowedIPs = 192.168.0.0/16, 10.0.0.0/8
# Keep connection alive
PersistentKeepalive = 25Important: Replace:
YOUR_PRIVATE_KEY_HEREwith your private keySERVER_PUBLIC_KEY_HEREwith the server's public keyvpn.example.com:51820with your VPN server address10.0.0.X/24with your assigned VPN IPAllowedIPswith the lab network subnets you need access to
chmod 600 {LAB_TESTING_ROOT}/secrets/wg0.confUsing wg-quick (requires root):
sudo wg-quick up {LAB_TESTING_ROOT}/secrets/wg0.confUsing NetworkManager (no root needed):
nmcli connection import type wireguard file {LAB_TESTING_ROOT}/secrets/wg0.conf
nmcli connection up wg0NetworkManager allows connecting to WireGuard VPN without root privileges, which is safer and more convenient.
nmcli connection import type wireguard file /path/to/wg0.conf# Connect
nmcli connection up wg0
# Disconnect
nmcli connection down wg0
# Check status
nmcli connection show --activeThe MCP server will automatically detect and use NetworkManager connections if available.
Only route lab network traffic through VPN:
AllowedIPs = 192.168.0.0/16, 10.0.0.0/8Route all internet traffic through VPN:
AllowedIPs = 0.0.0.0/0If you have multiple VPN servers:
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.0.0.2/24
[Peer]
PublicKey = SERVER1_PUBLIC_KEY
Endpoint = server1.example.com:51820
AllowedIPs = 192.168.1.0/24
[Peer]
PublicKey = SERVER2_PUBLIC_KEY
Endpoint = server2.example.com:51820
AllowedIPs = 192.168.2.0/24- Check if config exists: Use
list_vpn_configstool - Set
VPN_CONFIG_PATHenvironment variable - Ensure config file has
.confextension - Check file permissions (should be 600)
-
Check WireGuard installation:
wg --version
-
Test manually:
sudo wg-quick up /path/to/wg0.conf
-
Check logs:
sudo journalctl -u wg-quick@wg0
-
Verify server details:
- Public key matches server
- Endpoint is reachable
- Port is not blocked by firewall
-
Check if NetworkManager supports WireGuard:
nmcli --version
-
Re-import config:
nmcli connection delete wg0 # Remove old connection nmcli connection import type wireguard file /path/to/wg0.conf
- Config file should be readable by your user:
chmod 600 wg0.conf - For wg-quick, you need sudo access
- NetworkManager doesn't require root for user connections
-
Keep private keys secure:
- Never share your private key
- Use
chmod 600on config files - Don't commit configs to git
-
Use NetworkManager when possible:
- Avoids need for root/sudo
- Better integration with system
-
Limit AllowedIPs:
- Only route necessary subnets through VPN
- Reduces attack surface
-
Regular key rotation:
- Periodically regenerate keys
- Update server configuration
- Use MCP tool:
vpn_setup_instructionsfor detailed help - Check WireGuard documentation: https://www.wireguard.com/
- Check server logs:
~/.cache/ai-lab-testing/logs/