### WireGuard Server Setup Steps Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/wireguard/README.md Step-by-step guide to setting up a WireGuard server on MikroTik. ```APIDOC ## Setting Up a WireGuard Server (Step-by-Step) To configure a complete WireGuard VPN server, use the individual single-responsibility tools in sequence: 1. **Create the WireGuard interface** — `mikrotik_create_wireguard_interface` ```python mikrotik_create_wireguard_interface(name="wg0", listen_port=51820) ``` 2. **Assign an IP address to the interface** — `mikrotik_add_ip_address` ```python mikrotik_add_ip_address(address="10.0.0.1/24", interface="wg0") ``` 3. **Allow incoming WireGuard UDP traffic** — `mikrotik_create_filter_rule` ```python mikrotik_create_filter_rule( chain="input", action="accept", protocol="udp", dst_port="51820", comment="WireGuard wg0 input" ) ``` 4. *(Optional)* **Enable internet access for VPN clients via NAT** — `mikrotik_create_nat_rule` ```python mikrotik_create_nat_rule( chain="srcnat", action="masquerade", out_interface="ether1", comment="WireGuard wg0 masquerade" ) ``` 5. **Retrieve the server's public key** for client configuration — `mikrotik_get_wireguard_interface` ```python mikrotik_get_wireguard_interface(name="wg0") ``` 6. **Register each client** on the server — `mikrotik_add_wireguard_peer` ```python mikrotik_add_wireguard_peer( interface="wg0", public_key="client-base64pubkey==", allowed_address="10.0.0.2/32" ) ``` 7. **Generate the client config file** — `mikrotik_generate_wireguard_client_config` ```python mikrotik_generate_wireguard_client_config( client_private_key="client-base64privkey==", client_address="10.0.0.2/24", server_public_key="server-base64pubkey==", server_endpoint="203.0.113.1" ) ``` ``` -------------------------------- ### Run Inspector Using Configuration File Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/inspector.md Set up and run the inspector using a configuration file. This involves installing the inspector globally, copying an example configuration, editing it with your specific details, and then running the inspector with the config file. ```shell npm install -g @modelcontextprotocol/inspector cp mcp-config.json.example mcp-config.json nano mcp-config.json # Edit the values mcp-inspector --config mcp-config.json --server mikrotik-mcp-server ``` -------------------------------- ### Manual Installation Steps Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/installation.md Steps to manually install the MikroTik MCP server, including cloning the repository, setting up a virtual environment, installing dependencies, and running the server with different transport options. ```bash # Clone the repository git clone https://github.com/jeff-nasseri/mikrotik-mcp/tree/master cd mcp-mikrotik # Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -e . # Run the server (stdio, default) mcp-server-mikrotik # Run with SSE transport mcp-server-mikrotik --mcp.transport sse # Run with streamable HTTP transport mcp-server-mikrotik --mcp.transport streamable-http ``` -------------------------------- ### Install test dependencies Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/testing.md Install the required development dependencies listed in requirements-dev.txt. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Create Simple Queue Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/queue/README.md Example of creating a simple queue entry for a guest network. ```python create_simple_queue( name="guest-limit", target="192.168.10.0/24", max_limit="5M/5M", comment="Guest network speed cap" ) ``` -------------------------------- ### Install MCPO Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/mcpo.md Methods for installing or running the MCPO tool using uvx or pip. ```bash # Option 1: Using uvx (recommended - no installation needed) uvx mcpo --help # Option 2: Using pip pip install mcpo ``` -------------------------------- ### List All Wireless Interfaces Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Displays a list of all configured wireless interfaces on the MikroTik device. This command helps in getting an overview of the wireless setup. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_wireless_interfaces --tool-args '{}' ``` -------------------------------- ### Create Queue Tree Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/queue/README.md Example of creating a queue tree entry with specified parameters. ```python create_queue_tree( name="isp-download", parent="bridge", queue="cake-isp", max_limit="100M", priority=1 ) ``` -------------------------------- ### Example Scope Implementation Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/CONTRIBUTING.md An example of how to implement a new scope for creating a resource on a MikroTik device. ```python from typing import Optional from mcp.server.fastmcp import Context from ..connector import execute_mikrotik_command from ..app import mcp, READ, WRITE @mcp.tool(name="create_my_resource", annotations=WRITE) async def mikrotik_create_my_resource( ctx: Context, name: str, required_param: str, optional_param: Optional[str] = None, comment: Optional[str] = None ) -> str: """Creates a new resource on MikroTik device.""" await ctx.info(f"Creating resource: name={name}") cmd = f"/my/feature add name={name} param={required_param}" if optional_param: cmd += f" optional-param={optional_param}" if comment: cmd += f' comment="{comment}"' result = await execute_mikrotik_command(cmd, ctx) if "failure:" in result.lower() or "error" in result.lower(): return f"Failed to create resource: {result}" return f"Resource created successfully:\n\n{result}" ``` -------------------------------- ### Setup Basic Home Network Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Workflow to create a security profile, define an interface, and enable it for home use. ```bash # 1. Create security profile uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_security_profile --tool-args '{"name": "home-security", "mode": "dynamic-keys", "authentication_types": ["wpa2-psk"], "unicast_ciphers": ["aes-ccm"], "group_ciphers": ["aes-ccm"], "wpa2_pre_shared_key": "MyHomePassword123"}' # 2. Create wireless interface uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "home-wifi", "radio_name": "wlan1", "mode": "ap-bridge", "ssid": "HomeNetwork", "band": "2ghz-b/g/n", "comment": "Main home network"}' # 3. Apply security profile uv run mcp-cli cmd --server mikrotik --tool mikrotik_set_wireless_security_profile --tool-args '{"interface_name": "home-wifi", "security_profile": "home-security"}' # 4. Enable the interface uv run mcp-cli cmd --server mikrotik --tool mikrotik_enable_wireless_interface --tool-args '{"name": "home-wifi"}' ``` -------------------------------- ### Setup Guest Network Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Workflow to create an open security profile and configure a guest wireless interface. ```bash # 1. Create open security profile for guests uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_security_profile --tool-args '{"name": "guest-open", "mode": "none", "comment": "Open guest network"}' # 2. Create guest wireless interface uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "guest-wifi", "radio_name": "wlan1", "mode": "ap-bridge", "ssid": "GuestNetwork", "comment": "Guest access network"}' # 3. Apply open security profile uv run mcp-cli cmd --server mikrotik --tool mikrotik_set_wireless_security_profile --tool-args '{"interface_name": "guest-wifi", "security_profile": "guest-open"}' # 4. Enable guest network uv run mcp-cli cmd --server mikrotik --tool mikrotik_enable_wireless_interface --tool-args '{"name": "guest-wifi"}' ``` -------------------------------- ### Enable Safe Mode - Example Response Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Example response after successfully enabling Safe Mode. ```text Safe mode ENABLED. All changes are temporary — they will be reverted automatically if the connection drops or you call rollback_safe_mode. Call commit_safe_mode to make changes permanent. ``` -------------------------------- ### Start MCPO Server Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/mcpo.md Commands to launch the MCPO server with or without API key authentication. ```bash # Start MCPO with API key authentication uvx mcpo --port 8000 --api-key "your-secret-key" --config ./mcp-config.json # Or without authentication (not recommended for production) uvx mcpo --port 8000 --config ./mcp-config.json ``` -------------------------------- ### Create Queue Type Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/queue/README.md Example of creating a new queue type with specific CAKE parameters. ```python create_queue_type( name="cake-isp", kind="cake", cake_flowmode="triple-isolate", cake_nat=True, cake_overhead=34, cake_diffserv="diffserv4" ) ``` -------------------------------- ### Docker Build Command Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/installation.md Command to build the Docker image for the MikroTik MCP server. ```bash docker build -t mikrotik-mcp . ``` -------------------------------- ### Safe Mode Status - Active Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Example response when Safe Mode is active. ```text Safe mode is ACTIVE. Changes are pending — they are NOT yet persisted. Call commit_safe_mode to persist or rollback_safe_mode to revert. ``` -------------------------------- ### Create Basic MikroTik Firewall Setup Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/firewall/README.md Apply a predefined set of common and essential firewall filter rules to secure the MikroTik device. ```python mikrotik_create_basic_firewall_setup() ``` -------------------------------- ### Example Scope Implementation Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Python code demonstrating how to implement a new scope and register a tool. ```python from typing import Optional from mcp.server.fastmcp import Context from ..connector import execute_mikrotik_command from ..app import mcp, READ, WRITE, annotate @mcp.tool(name="create_my_resource", annotations=annotate(WRITE, "Create My Resource")) async def mikrotik_create_my_resource( ctx: Context, name: str, required_param: str, optional_param: Optional[str] = None, comment: Optional[str] = None ) -> str: """Creates a new resource on the MikroTik device.""" await ctx.info(f"Creating resource: name={name}") cmd = f"/my/feature add name={name} param={required_param}" if optional_param: cmd += f" optional-param={optional_param}" if comment: cmd += f' comment="{comment}"' result = await execute_mikrotik_command(cmd, ctx) if "failure:" in result.lower() or "error" in result.lower(): return f"Failed to create resource: {result}" return f"Resource created successfully:\n\n{result}" ``` -------------------------------- ### Example Workflow: Guest Network Creation Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/articles/README.md Illustrates a natural language interaction for creating a guest network with specific VLAN and DHCP configurations. The AI assistant translates the request into automated execution of MCP tools. ```natural language You: "Create a guest network on VLAN 200 with DHCP" AI: I'll set up a complete guest network for you: - Creates VLAN interface - Assigns IP address - Configures DHCP server - Adds NAT rules [Executes MCP tools] Result: Guest network is ready and operational! ``` -------------------------------- ### Commit Safe Mode - Example Response Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Example response after successfully committing Safe Mode changes. ```text Changes committed successfully. Safe mode DISABLED. ``` -------------------------------- ### Create Simple Queue Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/queue/README.md Example of creating simple queues for per-client limits using the create_simple_queue function. ```python create_simple_queue(name="client-001", target="192.168.1.10", max_limit="25M/25M") ``` -------------------------------- ### Safe Mode Status - Inactive Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Example response when Safe Mode is not active. ```text Safe mode is NOT active. Changes take effect and persist immediately. ``` -------------------------------- ### Typical Workflow Example Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Demonstrates a typical workflow for using Safe Mode, including checking status, enabling, making changes, and then committing or rolling back. ```python # 1. Check current state safe_mode_status() # 2. Enable safe mode before making changes enable_safe_mode() # 3. Make changes (routed through persistent session automatically) create_simple_queue(name="limit-guest", target="192.168.10.0/24", max_limit="5M/5M") create_filter_rule(chain="input", action="drop", src_address="10.0.0.0/8") # 4a. If satisfied — persist commit_safe_mode() # 4b. If not — revert everything rollback_safe_mode() ``` -------------------------------- ### Install and use MCP Inspector Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Commands to install MCP Inspector and test your MCP server using the stdio transport. ```bash # Install MCP Inspector npm install -g @modelcontextprotocol/inspector # Test your MCP server (stdio transport) mcp-inspector python -m mcp_mikrotik.server ``` -------------------------------- ### Configure Separate VLANs for Departments Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md This example demonstrates setting up isolated networks for different departments using VLANs, each with its own IP subnet and DHCP server configuration. ```bash # HR Department - VLAN 110 /interface vlan add name=vlan110-hr vlan-id=110 interface=bridge /ip address add address=192.168.110.1/24 interface=vlan110-hr /ip pool add name=hr-pool ranges=192.168.110.10-192.168.110.100 /ip dhcp-server add name=dhcp-hr interface=vlan110-hr address-pool=hr-pool ``` ```bash # Finance Department - VLAN 120 /interface vlan add name=vlan120-finance vlan-id=120 interface=bridge /ip address add address=192.168.120.1/24 interface=vlan120-finance /ip pool add name=finance-pool ranges=192.168.120.10-192.168.120.100 /ip dhcp-server add name=dhcp-finance interface=vlan120-finance address-pool=finance-pool ``` ```bash # IT Department - VLAN 130 /interface vlan add name=vlan130-it vlan-id=130 interface=bridge /ip address add address=192.168.130.1/24 interface=vlan130-it /ip pool add name=it-pool ranges=192.168.130.10-192.168.130.100 /ip dhcp-server add name=dhcp-it interface=vlan130-it address-pool=it-pool ``` -------------------------------- ### Rollback Safe Mode - Example Response Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/safe-mode/README.md Example response after rolling back Safe Mode changes. ```text Safe mode session closed. MikroTik has reverted all uncommitted changes automatically. ``` -------------------------------- ### Add MikroTik MCP from MCP Registry Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/installation.md Command to add the MikroTik MCP server using the Claude CLI from the MCP Registry. ```bash claude mcp add io.github.jeff-nasseri/mikrotik-mcp ``` -------------------------------- ### Setup VPN Server VLAN Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Creates a dedicated VLAN for VPN clients with a specific IP range, DHCP server, and NAT masquerade rule. ```bash /interface vlan add name=vlan100-vpn vlan-id=100 interface=bridge comment="VPN Clients" /ip address add address=10.10.100.1/24 interface=vlan100-vpn /ip pool add name=vpn-pool ranges=10.10.100.10-10.10.100.250 /ip dhcp-server network add address=10.10.100.0/24 gateway=10.10.100.1 dns-server=8.8.8.8 /ip dhcp-server add name=dhcp-vpn interface=vlan100-vpn address-pool=vpn-pool lease-time=8h /ip firewall nat add chain=srcnat src-address=10.10.100.0/24 action=masquerade comment="VPN Internet Access" ``` -------------------------------- ### Docker Run with stdio for IDE Integration Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/installation.md Configuration for running the MikroTik MCP server via Docker with stdio transport, suitable for IDE integration. This JSON snippet should be added to `~/.cursor/mcp.json`. ```json { "mcpServers": { "mikrotik-mcp-server": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "MIKROTIK_HOST=192.168.88.1", "-e", "MIKROTIK_USERNAME=sshuser", "-e", "MIKROTIK_PASSWORD=your_password", "-e", "MIKROTIK_PORT=22", "mikrotik-mcp" ] } } } ``` -------------------------------- ### Get MikroTik User Group Details Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/users/README.md Fetches configuration details for a specific user group. ```text mikrotik_get_user_group(name="operators") ``` -------------------------------- ### Example Integration Test Structure Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Python code demonstrating the structure for integration tests using testcontainers. ```python """Integration tests for MikroTik my feature using testcontainers.""" import pytest from mcp_mikrotik.scope.my_feature import ( mikrotik_create_my_resource, mikrotik_list_my_resources ) @pytest.mark.integration class TestMikroTikMyFeatureIntegration: def test_01_create_resource(self, mikrotik_container): result = mikrotik_create_my_resource( name="test_resource", required_param="test_value" ) assert "failed" not in result.lower() assert "test_resource" in result def test_02_list_resources(self, mikrotik_container): result = mikrotik_list_my_resources() assert "test_resource" in result ``` -------------------------------- ### Registering a Scope Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Example of how to import a new scope module in app.py to register its tools. ```python from mcp_mikrotik.scope import ( backup, dhcp, dns, firewall_filter, firewall_nat, ip_address, ip_pool, logs, my_feature, routes, users, vlan, wireless, ) ``` -------------------------------- ### mikrotik_create_basic_firewall_setup Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/firewall/README.md Applies a default security configuration. ```APIDOC ## POST mikrotik_create_basic_firewall_setup ### Description Creates a basic firewall setup with common security rules. ### Request Example {} ``` -------------------------------- ### Run Inspector Against MikroTik Server Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/inspector.md Execute the inspector directly against a MikroTik server using its host, username, password, and SSH port. Ensure the inspector is installed globally. ```shell npx @modelcontextprotocol/inspector uvx mcp-server-mikrotik --host --username --password --port 22 ``` -------------------------------- ### Docker Run with SSE or Streamable HTTP Transport Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/installation.md Command to run the MikroTik MCP server using Docker with SSE or streamable HTTP transport, exposing the server on port 8000. ```bash docker run --rm -p 8000:8000 \ -e MIKROTIK_HOST=192.168.88.1 \ -e MIKROTIK_USERNAME=sshuser \ -e MIKROTIK_PASSWORD=your_password \ -e MIKROTIK_MCP__TRANSPORT=sse \ mikrotik-mcp ``` -------------------------------- ### List IP Addresses via cURL Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/mcpo.md Example request to list IP addresses from the MikroTik server using the REST API. ```bash curl -X POST http://localhost:8000/mikrotik-mcp-server/mikrotik_list_ip_addresses \ -H "Authorization: Bearer your-secret-key" \ -H "Content-Type: application/json" \ -d '{}' ``` -------------------------------- ### Conventional Commits Example: test Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Example of a commit message for test-related changes. ```markdown ``` test(users): expand integration test coverage Add tests for user group management and permission validation ``` ``` -------------------------------- ### Conventional Commits Example: fix Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Example of a commit message for a bug fix. ```markdown ``` fix(firewall): handle special characters in rule comments Escape special characters when creating firewall rules with comments to prevent command parsing errors on RouterOS devices ``` ``` -------------------------------- ### Conventional Commits Example: feat Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/contributing.md Example of a commit message for a new feature. ```markdown ``` feat(dhcp): add DHCP server creation and management tools Add comprehensive DHCP server management including: - Create DHCP servers with configurable options - List and filter DHCP servers - Create DHCP networks and pools - Remove DHCP servers Includes integration tests with RouterOS container ``` ``` -------------------------------- ### Implement Backup and Restore Strategy Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Commands for manual backups, configuration exports, and automated scheduling for daily backups and cleanup tasks. ```bash # Create backup /system backup save name=daily-backup # Export configuration /export file=daily-config # Schedule daily backup at 2 AM /system scheduler add name=daily-backup start-time=02:00:00 interval=1d on-event="/system backup save name=auto-backup-$[/system clock get date]" comment="Daily Backup" # Schedule weekly cleanup (keep last 7 backups) /system scheduler add name=cleanup-old-backups start-time=03:00:00 interval=7d on-event="/file remove [find name~\"auto-backup\" where creation-time<([:timestamp]-604800)]" comment="Weekly Cleanup" # Export to USB (if USB drive mounted) /file copy [find name~"backup"] destination-path=usb1/backups/ ``` -------------------------------- ### Create a Guest Network with VLAN Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/articles/examples.md Configures a VLAN, IP address, DHCP server, and NAT masquerade rule for a guest network. ```bash /interface vlan add name=vlan200-guest vlan-id=200 interface=ether1 comment="Guest Network" /ip address add address=192.168.200.1/24 interface=vlan200-guest /ip pool add name=guest-pool ranges=192.168.200.10-192.168.200.250 /ip dhcp-server network add address=192.168.200.0/24 gateway=192.168.200.1 dns-server=8.8.8.8,8.8.4.4 /ip dhcp-server add name=dhcp-guest interface=vlan200-guest address-pool=guest-pool lease-time=1h /ip firewall nat add chain=srcnat action=masquerade src-address=192.168.200.0/24 out-interface=ether1 ``` -------------------------------- ### Create Wireless Interfaces Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Commands to provision different types of wireless interfaces with specific configurations. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "wlan1", "radio_name": "wlan1", "mode": "ap-bridge", "ssid": "MyNetwork", "comment": "Main WiFi Network"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "wlan-sta", "radio_name": "wlan2", "mode": "station", "ssid": "UpstreamWiFi"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "wlan-5g", "radio_name": "wlan1", "mode": "ap-bridge", "ssid": "MyNetwork-5G", "frequency": "5180", "band": "5ghz-a/n/ac", "channel_width": "80mhz"}' ``` -------------------------------- ### Perform Backup and Export Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Commands for creating system backups and configuration exports. ```bash # Create system backup uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_backup --tool-args '{"name": "full_backup", "include_password": true}' # Create configuration export uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_export --tool-args '{"name": "config_export", "file_format": "rsc", "export_type": "full"}' ``` -------------------------------- ### mikrotik_backup_info Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/backup/README.md Gets detailed information about a backup file. ```APIDOC ## mikrotik_backup_info ### Description Gets detailed information about a backup file. ### Parameters #### Request Body - **filename** (string) - Required - Backup filename ### Request Example ``` mikrotik_backup_info(filename="backup-2024-01-01.backup") ``` ``` -------------------------------- ### GET mikrotik_list_wireguard_interfaces Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/wireguard/README.md Retrieves a list of WireGuard interfaces configured on the device. ```APIDOC ## GET mikrotik_list_wireguard_interfaces ### Description Lists WireGuard interfaces on MikroTik device. ### Parameters #### Query Parameters - **name_filter** (string) - Optional - Filter by interface name (partial match) - **disabled_only** (boolean) - Optional - Show only disabled interfaces - **running_only** (boolean) - Optional - Show only running interfaces ### Request Example ``` mikrotik_list_wireguard_interfaces() ``` ``` -------------------------------- ### Create Guest Network with VLAN Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Configures a guest VLAN with DHCP and NAT masquerading. Requires an existing ether1 interface. ```text Create a new VLAN 200 for the guest network on ether1, assign IP 192.168.200.1/24, set up DHCP from .10 to .250, and add a masquerade NAT rule for internet access. ``` ```bash /interface vlan add name=vlan200-guest vlan-id=200 interface=ether1 comment="Guest Network" /ip address add address=192.168.200.1/24 interface=vlan200-guest /ip pool add name=guest-pool ranges=192.168.200.10-192.168.200.250 /ip dhcp-server network add address=192.168.200.0/24 gateway=192.168.200.1 dns-server=8.8.8.8,8.8.4.4 /ip dhcp-server add name=dhcp-guest interface=vlan200-guest address-pool=guest-pool lease-time=1h /ip firewall nat add chain=srcnat action=masquerade src-address=192.168.200.0/24 out-interface=ether1 ``` -------------------------------- ### Get Active MikroTik Users Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/users/README.md Lists all users currently logged into the device. ```text mikrotik_get_active_users() ``` -------------------------------- ### Get log statistics Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/logs/README.md Retrieves statistical data regarding log entries. ```python mikrotik_get_log_statistics() ``` -------------------------------- ### get_interface Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/interfaces/README.md Gets detailed information about a single interface by exact name. ```python get_interface(name="ether1-wan") get_interface(name="pppoe-out1") ``` -------------------------------- ### Get MikroTik Route Statistics Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/routes/README.md Retrieves statistics for the routing table on the MikroTik device. ```python mikrotik_get_route_statistics() ``` -------------------------------- ### Create MikroTik DHCP Server Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Sets up a DHCP server on a specified interface, linked to an address pool. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_dhcp_server --tool-args '{"name": "dhcp-200", "interface": "vlan200", "address_pool": "pool-200"}' ``` -------------------------------- ### Get MikroTik User Details Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/users/README.md Fetches detailed information for a specific user by name. ```text mikrotik_get_user(name="john") ``` -------------------------------- ### Configure DHCP Servers Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Commands for setting up DHCP pools, networks, and servers, as well as listing and removing existing DHCP configurations. ```bash # Create DHCP pool uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_dhcp_pool --tool-args '{"name": "pool-vlan100", "ranges": "192.168.100.10-192.168.100.200"}' # Create DHCP network uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_dhcp_network --tool-args '{"network": "192.168.100.0/24", "gateway": "192.168.100.1", "dns_servers": ["8.8.8.8", "8.8.4.4"]}' # Create DHCP server uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_dhcp_server --tool-args '{"name": "dhcp-vlan100", "interface": "vlan100", "address_pool": "pool-vlan100"}' # List DHCP servers uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_dhcp_servers --tool-args '{}' # Get DHCP server details uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_dhcp_server --tool-args '{"name": "dhcp-vlan100"}' # Remove DHCP server uv run mcp-cli cmd --server mikrotik --tool mikrotik_remove_dhcp_server --tool-args '{"name": "dhcp-vlan100"}' ``` -------------------------------- ### Configure DNS with DoH Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Sets up Cloudflare DNS servers with DoH, cache settings, and static entries. ```bash /ip dns set servers=1.1.1.1,1.0.0.1 allow-remote-requests=yes cache-size=4096KiB /ip dns set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes /ip dns static add name=router.local address=192.168.1.1 comment="Router Local DNS" /ip dns static add name=nas.local address=192.168.1.10 comment="NAS Device" ``` -------------------------------- ### Get NAT Rule Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/nat/README.md Retrieves detailed information about a specific NAT rule using its ID. ```APIDOC ## GET /mikrotik/nat/get/{rule_id} ### Description Gets detailed information about a specific NAT rule. ### Method GET ### Endpoint /mikrotik/nat/get/{rule_id} ### Parameters #### Path Parameters - **rule_id** (string) - Required - Rule ID ### Response #### Success Response (200) - **rule** (object) - An object containing the detailed information of the NAT rule. #### Response Example ```json { "rule": { "id": "*1", "chain": "srcnat", "action": "masquerade", "out_interface": "ether1", "comment": "Default masquerade" } } ``` ``` -------------------------------- ### Get MikroTik Route Cache Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/routes/README.md Retrieves the current route cache information from the MikroTik device. ```python mikrotik_get_route_cache() ``` -------------------------------- ### Create Point-to-Point Wireless Station Interface Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Configures a wireless interface in 'station' mode for a point-to-point link. This command should be run on the client device of the P2P connection. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "p2p-station", "radio_name": "wlan1", "mode": "station", "ssid": "P2P-Link", "frequency": "5180", "band": "5ghz-a/n"}' ``` -------------------------------- ### Get VLAN interface details Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/vlan/README.md Retrieves detailed information for a specific VLAN interface by name. ```python mikrotik_get_vlan_interface(name="vlan100") ``` -------------------------------- ### Get Active MikroTik Users Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Retrieves a list of currently active users on the MikroTik device. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_active_users --tool-args '{}' ``` -------------------------------- ### Get DHCP Server Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/dhcp/README.md Fetches detailed information for a specific DHCP server identified by its name. ```APIDOC ## Get DHCP Server ### Description Gets detailed information about a specific DHCP server. ### Method Not specified (function call) ### Endpoint Not specified ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - DHCP server name ### Request Example ```python mikrotik_get_dhcp_server(name="dhcp-vlan100") ``` ### Response #### Success Response (200) Detailed information of the specified DHCP server (structure not specified). #### Response Example None specified ``` -------------------------------- ### Create IoT Network with VLAN 50 Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/articles/examples.md Sets up an IoT VLAN with DHCP and firewall rules to isolate traffic from the main LAN while allowing internet access. ```bash /interface vlan add name=vlan50-iot vlan-id=50 interface=bridge comment="IoT Devices" /ip address add address=192.168.50.1/24 interface=vlan50-iot /ip pool add name=iot-pool ranges=192.168.50.10-192.168.50.200 /ip dhcp-server network add address=192.168.50.0/24 gateway=192.168.50.1 dns-server=192.168.50.1 /ip dhcp-server add name=dhcp-iot interface=vlan50-iot address-pool=iot-pool lease-time=24h /ip firewall filter add chain=forward src-address=192.168.50.0/24 dst-address=192.168.1.0/24 action=drop comment="Block IoT to LAN" /ip firewall nat add chain=srcnat src-address=192.168.50.0/24 out-interface=ether1 action=masquerade ``` -------------------------------- ### Automated Backup Strategy Prompt Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md A prompt for setting up automated daily backups, configuration exports, and weekly cleanup tasks. ```text Set up an automated backup system for my router. Create manual backup named "daily-backup", export configuration to "daily-config" file. Schedule automatic backups to run daily at 2:00 AM with date in filename. Schedule weekly cleanup at 3:00 AM on Sundays to delete backups older than 7 days. If USB drive is mounted as usb1, copy backups to USB drive in a backups folder. ``` -------------------------------- ### Get MikroTik User Details Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Retrieves details for a specific user on the MikroTik device. Requires the username. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_user --tool-args '{"name": "newuser"}' ``` -------------------------------- ### Tool annotation before and after Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/context-optimization.md Illustrates the change in how tool annotations are applied, from a direct annotation constant to using the `annotate` helper function with a short title. ```python # before @mcp.tool(name="create_queue_type", annotations=WRITE) # after @mcp.tool(name="create_queue_type", annotations=annotate(WRITE, "Create Queue Type")) ``` -------------------------------- ### Get MikroTik DNS Settings Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Retrieves the current DNS settings from the MikroTik device. No arguments are required. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_dns_settings --tool-args '{}' ``` -------------------------------- ### Import MikroTik Configuration Script Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/backup/README.md Imports a configuration script file onto the MikroTik device. Options include running the script after a reset and enabling verbose output. ```python mikrotik_import_configuration(filename="config.rsc") ``` -------------------------------- ### Get Specific MikroTik DHCP Server Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/dhcp/README.md Fetch detailed information for a particular DHCP server by its name. ```python mikrotik_get_dhcp_server(name="dhcp-vlan100") ``` -------------------------------- ### mikrotik_create_backup Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/backup/README.md Creates a system backup on the MikroTik device. ```APIDOC ## mikrotik_create_backup ### Description Creates a system backup on MikroTik device. ### Parameters #### Request Body - **name** (string) - Optional - Backup filename - **dont_encrypt** (boolean) - Optional - Don't encrypt backup - **include_password** (boolean) - Optional - Include passwords - **comment** (string) - Optional - Description ### Request Example ``` mikrotik_create_backup(name="backup-2024-01-01") ``` ``` -------------------------------- ### Create WireGuard Interface Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/wireguard/README.md Creates a WireGuard interface. A private key is auto-generated if not provided. Use this to set up a new VPN interface. ```python mikrotik_create_wireguard_interface(name="wg0", listen_port=13231) ``` -------------------------------- ### Get Specific MikroTik IP Pool Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/ip-pool/README.md Fetches detailed information for a single, specified IP pool by its name. ```python mikrotik_get_ip_pool(name="pool1") ``` -------------------------------- ### Get MikroTik DNS Cache Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/dns/README.md Retrieves the current contents of the DNS cache on the MikroTik device. No parameters are needed. ```python mikrotik_get_dns_cache() ``` -------------------------------- ### Manage Wireless Interfaces Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Commands to list, update, toggle, and remove wireless interfaces. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_wireless_interfaces --tool-args '{}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_wireless_interfaces --tool-args '{"mode_filter": "ap-bridge"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_wireless_interfaces --tool-args '{"running_only": true}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_wireless_interface --tool-args '{"name": "wlan1"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_update_wireless_interface --tool-args '{"name": "wlan1", "ssid": "UpdatedNetworkName", "comment": "Updated main network"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_disable_wireless_interface --tool-args '{"name": "wlan1"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_enable_wireless_interface --tool-args '{"name": "wlan1"}' uv run mcp-cli cmd --server mikrotik --tool mikrotik_remove_wireless_interface --tool-args '{"name": "wlan-guest"}' ``` -------------------------------- ### Get MikroTik DNS Settings Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/dns/README.md Retrieves the current DNS server configuration from a MikroTik device. No parameters are required. ```python mikrotik_get_dns_settings() ``` -------------------------------- ### Create MikroTik System Backup Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/backup/README.md Creates a system backup on the MikroTik device. Optional parameters allow for custom naming, encryption control, and inclusion of passwords. ```python mikrotik_create_backup(name="backup-2024-01-01") ``` -------------------------------- ### Configure Claude Desktop for MikroTik MCP Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/integrations/claude-desktop.md Add this configuration to your claude_desktop_config.json file to enable the MikroTik MCP server. Ensure you replace the placeholder values with your actual MikroTik host, username, and password. ```json { "mcpServers": { "mikrotik": { "command": "uvx", "args": ["mcp-server-mikrotik", "--host", "", "--username", "", "--password", "", "--port", "22"] } } } ``` -------------------------------- ### Verify RouterOS Configurations Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Reference commands to list and inspect various system, interface, and network configurations. ```bash # List all VLANs /interface vlan print # List all IP addresses /ip address print # List all IP pools /ip pool print detail # List DHCP servers /ip dhcp-server print # List DHCP networks /ip dhcp-server network print # List NAT rules /ip firewall nat print # List filter rules /ip firewall filter print # List routes /ip route print # List users /user print # List active connections /ip firewall connection print # System resources /system resource print # Interface statistics /interface print stats ``` -------------------------------- ### Create Point-to-Point Wireless AP Interface Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Sets up a wireless interface in 'ap-bridge' mode for a point-to-point link. This command should be run on the access point device of the P2P connection. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_create_wireless_interface --tool-args '{"name": "p2p-ap", "radio_name": "wlan1", "mode": "ap-bridge", "ssid": "P2P-Link", "frequency": "5180", "band": "5ghz-a/n"}' ``` -------------------------------- ### Enable Dual-Band Wireless Interfaces Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Activates both the 2.4GHz and 5GHz wireless interfaces, making them operational after configuration. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_enable_wireless_interface --tool-args '{"name": "wifi-2g"}' ``` ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_enable_wireless_interface --tool-args '{"name": "wifi-5g"}' ``` -------------------------------- ### Get Specific MikroTik Route Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/routes/README.md Retrieves detailed information about a specific route using its ID. The route ID can be a wildcard. ```python mikrotik_get_route(route_id="*1") ``` -------------------------------- ### Correct and incorrect usage of annotate Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/getting-started/context-optimization.md Demonstrates the correct way to use the `annotate()` helper when adding new tools, emphasizing the inclusion of a title. ```python # ✅ correct @mcp.tool(name="my_new_tool", annotations=annotate(READ, "My New Tool")) # ❌ avoid — omits the title @mcp.tool(name="my_new_tool", annotations=READ) ``` -------------------------------- ### Get Specific MikroTik NAT Rule Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/nat/README.md Fetch detailed information for a single NAT rule using its unique ID. ```python mikrotik_get_nat_rule(rule_id="*1") ``` -------------------------------- ### Implement Basic Firewall Security Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Sets up standard input and forward chain rules to secure the router, including ICMP and SSH access control. ```bash /ip firewall filter add chain=input connection-state=established,related action=accept comment="Accept Established/Related" /ip firewall filter add chain=input connection-state=invalid action=drop comment="Drop Invalid" /ip firewall filter add chain=input protocol=icmp action=accept comment="Allow ICMP" /ip firewall filter add chain=input in-interface=ether1 protocol=tcp dst-port=22 action=accept comment="Allow SSH from WAN" /ip firewall filter add chain=input in-interface=ether1 action=drop comment="Drop All Other WAN Input" /ip firewall filter add chain=forward connection-state=established,related action=accept /ip firewall filter add chain=forward connection-state=invalid action=drop ``` -------------------------------- ### Documentation Change (No Version Bump) Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/CONTRIBUTING.md Example of a commit message for documentation changes that do not trigger a version bump. ```bash git commit -m "docs: add queue and safe-mode reference pages" ``` -------------------------------- ### Create Queue Tree Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/queue/README.md Example of creating child queues per traffic class using the create_queue_tree function. ```python create_queue_tree(name="bulk", parent="wan-root", packet_mark="bulk-traffic", priority=8, max_limit="100M") create_queue_tree(name="realtime", parent="wan-root", packet_mark="rt-traffic", priority=1, max_limit="100M") ``` -------------------------------- ### Configure Dual WAN Load Balancing Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/articles/examples.md Sets up per-connection classifier (PCC) load balancing across two WAN interfaces with gateway ping monitoring. ```bash /ip address add address=192.168.1.2/24 interface=ether1 comment="WAN1" /ip address add address=192.168.2.2/24 interface=ether2 comment="WAN2" /ip route add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 routing-mark=wan1-route check-gateway=ping /ip route add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 routing-mark=wan2-route check-gateway=ping /ip firewall mangle add chain=prerouting in-interface=bridge connection-mark=no-mark action=mark-connection new-connection-mark=wan1-conn per-connection-classifier=both-addresses:2/0 /ip firewall mangle add chain=prerouting in-interface=bridge connection-mark=wan1-conn action=mark-routing new-routing-mark=wan1-route ``` -------------------------------- ### List Security Profiles Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Command to retrieve all configured wireless security profiles. ```bash uv run mcp-cli cmd --server mikrotik --tool mikrotik_list_wireless_security_profiles --tool-args '{}' ``` -------------------------------- ### Perform Wireless Network Scanning and Monitoring Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/examples/usage-examples.md Commands to scan for networks and retrieve client registration tables. ```bash # Scan for available networks uv run mcp-cli cmd --server mikrotik --tool mikrotik_scan_wireless_networks --tool-args '{"interface": "wlan1", "duration": 10}' # Quick scan (5 seconds) uv run mcp-cli cmd --server mikrotik --tool mikrotik_scan_wireless_networks --tool-args '{"interface": "wlan2"}' # Get connected clients (all interfaces) uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_wireless_registration_table --tool-args '{}' # Get clients for specific interface uv run mcp-cli cmd --server mikrotik --tool mikrotik_get_wireless_registration_table --tool-args '{"interface": "wlan1"}' ``` -------------------------------- ### Get MikroTik Routing Table Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/routes/README.md Retrieves a specific routing table, defaulting to 'main'. Allows filtering by protocol and active status. ```python mikrotik_get_routing_table(table_name="main") ``` -------------------------------- ### Get MikroTik Backup Information Source: https://github.com/jeff-nasseri/mikrotik-mcp/blob/master/docs/reference/backup/README.md Retrieves detailed information about a specific backup file on the MikroTik device. Requires the filename of the backup. ```python mikrotik_backup_info(filename="backup-2024-01-01.backup") ```