MikroTik MCP
Manages MikroTik RouterOS devices over SSH: firewall filter rules, NAT, DNS (static entries, regexp, cache), DHCP servers/pools/networks, routes, IP addresses and pools, VLANs, wireless interfaces and security profiles, users/groups, BGP sessions, connections, templates, advertisements and routing filters, mangle rules, backups/exports, file upload/download and logs. Includes multi-device support (device registry, switching the active router at runtime) and a run_command tool for executing arbitrary RouterOS CLI commands.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MikroTik MCP
Fork of jeff-nasseri/mikrotik-mcp with extended functionality.
MCP server for managing MikroTik RouterOS devices via AI assistants (Claude Desktop, Claude Code, etc.)
What's changed (vs upstream)
New modules
devices.py+scope/devices.py— Multi-device support: the server is no longer tied to a single router. Keep a registry of devices and switch between them at runtime — see Multi-device supportscope/routing.py— Full BGP management (sessions, connections, templates, instances, advertisements, routing filters, routing tables)scope/mangle.py— Firewall mangle rules (list, add, remove, enable/disable with full parameter support)
New tools
Tool | Module | Description |
|
| List all configured devices; the active one is marked with |
|
| Switch the active device — all subsequent tools target it |
|
| Register a device at runtime (optionally persist to the devices file) |
|
| Remove a device from the registry |
|
| Test SSH connectivity, show identity/version (without switching) |
|
| Execute any RouterOS CLI command (no dedicated tool needed) |
|
| List BGP sessions with status |
|
| List BGP connection configurations |
|
| List BGP templates |
|
| List BGP instances |
|
| List BGP advertisements (prefixes) |
|
| Create BGP peer (AS, routing-table, multihop, hold-time, etc.) |
|
| Remove BGP connection by name |
|
| Enable BGP connection |
|
| Disable BGP connection |
|
| Create BGP template (AS, filters, timers) |
|
| Remove BGP template |
|
| List routing filter rules (by chain) |
|
| Add routing filter rule |
|
| Remove all rules in a filter chain |
|
| List routing tables |
|
| Create routing table |
|
| List mangle rules (filter by chain/action) |
|
| List mangle rules with full detail |
|
| Create mangle rule (mark-routing, mark-connection, etc.) |
|
| Remove mangle rule by ID |
|
| Enable mangle rule |
|
| Disable mangle rule |
Architecture changes
devices.py— Device registry with an "active device" concept; loads from a JSON devices file,MIKROTIK_DEVICESenv/CLI JSON, and legacy--host/--usernameflags (registered as devicedefault)connector.py— All commands run against the active device from the registry; added SFTP read/write support (sftp_read_file,sftp_write_file) for file operations on the deviceapp.py— Added tool annotation constants (READ,WRITE,WRITE_IDEMPOTENT,DESTRUCTIVE,DANGEROUS) for MCP tool hints; added/healthendpointmikrotik_ssh_client.py— Addedsftp_read()andsftp_write()methods to the SSH clientAll scope modules updated to use tool annotations
Existing tools (from upstream)
Category | Tools |
System |
|
Firewall |
|
NAT |
|
DNS |
|
DHCP |
|
Routes |
|
IP Address |
|
IP Pool |
|
VLAN |
|
Wireless |
|
Users |
|
Backup |
|
Logs |
|
Related MCP server: RouterOS MCP Server
Installation
git clone https://github.com/Korotkov113/mikrotik-mcp.git
cd mikrotik-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .Configuration
Single device (Claude Desktop / Claude Code)
Add to your MCP config (claude_desktop_config.json or .claude/settings.json):
{
"mcpServers": {
"mikrotik": {
"command": "/path/to/mikrotik-mcp/.venv/bin/mcp-server-mikrotik",
"args": [
"--host", "192.168.0.1",
"--username", "admin",
"--key-filename", "/path/to/ssh/key",
"--port", "22"
]
}
}
}Environment variables
Alternatively, configure via environment:
export MIKROTIK_HOST=192.168.0.1
export MIKROTIK_USERNAME=admin
export MIKROTIK_PASSWORD=your_password
export MIKROTIK_PORT=22Multi-device support
The server keeps a device registry and an active device. Every tool
(firewall, DNS, routes, backups, ...) targets the active device; switch
devices at any time with use_device — no server restart needed.
The registry is built from three sources (later wins):
Devices file — JSON file at
--devices-file/MIKROTIK_DEVICES_FILE(default:~/.config/mikrotik-mcp/devices.json)MIKROTIK_DEVICESenv var (or--devices) with inline JSONLegacy flags
--host/--username/--password/--port/--key-filename, registered as devicedefault(existing single-device setups keep working unchanged)
Devices file
{
"default_device": "home",
"devices": {
"home": {
"host": "192.168.88.1",
"username": "admin",
"password": "secret",
"port": 22,
"description": "home router"
},
"office": {
"host": "10.0.0.1",
"username": "admin",
"key_filename": "/path/to/ssh/key",
"port": 2222,
"description": "office edge router"
}
}
}MCP config for the multi-device setup:
{
"mcpServers": {
"mikrotik": {
"command": "/path/to/mikrotik-mcp/.venv/bin/mcp-server-mikrotik",
"args": ["--devices-file", "/path/to/devices.json"]
}
}
}Inline JSON via environment
export MIKROTIK_DEVICES='{"home": {"host": "192.168.88.1", "username": "admin", "password": "secret"}, "office": {"host": "10.0.0.1", "username": "admin", "key_filename": "/path/to/key"}}'
export MIKROTIK_DEFAULT_DEVICE=homeManaging devices at runtime
> What routers do I have?
Tool: list_devices()
* home: admin@192.168.88.1:22 [password] — home router
office: admin@10.0.0.1:2222 [ssh-key] — office edge router
> Switch to the office router
Tool: use_device(name="office")
> Add the lab router and remember it
Tool: add_device(name="lab", host="172.16.0.1", username="admin", password="...", make_active=true, save=true)
> Check if the office router is reachable
Tool: test_device_connection(name="office")add_device(..., save=true) persists the registry to the devices file
(created with 0600 permissions, since it may contain passwords). Prefer
key_filename over passwords where possible.
Usage examples
Run arbitrary command
> Show me BGP session status
Tool: run_command("/routing bgp session print")BGP management
> Create a BGP connection to antifilter service
Tool: add_bgp_connection(name="antifilter", remote_address="45.148.244.55/32", remote_as=65444, ...)Mangle rules
> Mark traffic from FreeInternet_list users to routing table to_proxy
Tool: add_mangle_rule(chain="prerouting", action="mark-routing", new_routing_mark="to_proxy", src_address_list="FreeInternet_list")License
MIT License. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Migrate and validate firewall, router and switch configurations from your AI assistant.
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Remote Desktop Commander: use files, terminal and processes on your own computers from any AI app.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA bridge between AI assistants and MikroTik RouterOS devices, allowing natural language interaction to manage network configurations including VLANs, firewalls, DNS settings, and more.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with MikroTik RouterOS devices through API and SSH connections, supporting network monitoring, configuration management, and diagnostics across multiple routers with automatic connection fallback.3MIT
- AlicenseCqualityAmaintenanceProvides a bridge between AI assistants and MikroTik RouterOS devices, enabling natural language management of VLANs, firewall rules, DNS settings, and more.2551,695 PyPI363MIT
- AlicenseNot gradedqualityCmaintenanceBridges AI assistants with MikroTik RouterOS devices, enabling natural language management of network configurations, firewall, VLANs, VPNs, and diagnostics via ~300 tools.1MIT