MikroTik RouterOS MCP
This server is an MCP interface for managing MikroTik RouterOS devices, offering multi-router discovery, read-heavy network inspection, and guarded safe-mode configuration changes.
Manage multiple named routers from one MCP server, with per-device write permission gating and tags.
Discover configured devices and inspect their identity, version, uptime, and hardware via
system_info,list_devices, anddescribe_device.Read network state: interfaces, IP addresses, routes, firewall filters, NAT rules, DNS, DHCP servers/leases, address lists, bridges/ports, neighbors, WireGuard interfaces/peers, and logs.
Perform network diagnostics and config export: ping from a device, export full config, and run read-only API print commands on arbitrary RouterOS paths.
Preview risky script changes with
plan_script_change, which returns a risk assessment and approval code.Apply approved changes via
apply_script_changeinside RouterOS Safe Mode, with automatic config snapshot before the write and rollback if the session drops or the post-apply health check fails.Inspect write history by listing config snapshots and diffing two snapshots to review exactly what changed.
Connect via transport fallback: API, then API-SSL, then SSH, enabling use in environments where only SSH is available.
Optionally run a bundled REST-backed web dashboard for viewing routers and common network state.
Allows managing MikroTik RouterOS devices, including system info, interfaces, IP addresses, routes, firewall, NAT, DHCP, DNS, bridges, WireGuard, logs, ping, config export, and guarded script execution via API or SSH fallback.
Enables management of WireGuard interfaces and peers on MikroTik RouterOS devices.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MikroTik RouterOS MCP show interfaces on home router"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MikroTik RouterOS MCP
An MCP server for MikroTik RouterOS with a lightweight web dashboard for multi-router management. Exposes 26 MCP tools covering transport fallback (API → API-SSL → SSH), read-heavy network inspection, and guarded write access, while the bundled dashboard provides a simple REST-backed UI for viewing routers and common network state.
Quick start
git clone https://github.com/drohi-r/mikrotik-routeros-mcp && cd mikrotik-routeros-mcp
uv sync
# Configure devices
cp devices.yaml.example devices.yaml # then edit with your router details
# Run the MCP server
uv run python -m mikrotik_routeros_mcp.server
# Or run the web dashboard
uv run python -m mikrotik_routeros_mcp.dashboard --host 0.0.0.0 --port 8080The server looks for config in this order: MIKROTIK_ROUTEROS_CONFIG env var → ./devices.yaml → ./devices.yml → ./devices.json.
Related MCP server: MikroTik MCP
Architecture
graph TD
A["MikroTik RouterOS MCP Server<br/><code>mikrotik_routeros_mcp</code><br/>26 tools · safe-mode writes"] --> B
B["Transport Layer<br/>Fallback: API → API-SSL → SSH"] --> C
C["RouterOS Devices<br/>Named targets from devices.yaml"]
D["Multi-Device Config<br/>Named routers · tags · per-device write control"] -.-> A
E["Safe-Mode Write Engine<br/>snapshot → apply → health check → commit/revert"] -.-> A
F["SSH Fallback<br/>Config export · limited-API environments"] -.-> B
style A fill:#1a1a2e,stroke:#2196F3,color:#fff
style B fill:#1a1a2e,stroke:#2196F3,color:#fff
style C fill:#1a1a2e,stroke:#0f3460,color:#fff
style D fill:#0f3460,stroke:#0f3460,color:#fff
style E fill:#0f3460,stroke:#0f3460,color:#fff
style F fill:#0f3460,stroke:#0f3460,color:#fffConfiguration
Device config example:
devices:
- name: home
host: 192.168.88.1
username: admin
password: change-me
transport_order:
- api
- api-ssl
- ssh
allow_writes: false
tags:
- home
- lab
- name: office
host: office-router.example.com
username: admin
password: change-me
fallback_ip: 203.0.113.10
transport_order:
- api-ssl
- ssh
allow_writes: false
tags:
- office
- productionTools
Server and discovery
Tool | What it does |
| Return current MCP server configuration and safety settings |
| List all configured RouterOS devices |
| Return detailed info for a named device |
System and network reads
Tool | What it does |
| Return system identity, version, uptime, and hardware info |
| List all network interfaces with status |
| List IP addresses assigned to interfaces |
| List the routing table |
| List firewall filter rules |
| List NAT rules |
| Return DNS configuration |
| List DHCP server instances |
| List DHCP leases |
| List firewall address list entries |
| List bridge interfaces |
| List bridge port memberships |
| List discovered network neighbors |
| List WireGuard interfaces |
| List WireGuard peers |
| Retrieve system log entries |
| Ping a target from a device |
| Export device configuration |
| Read-only API print for any RouterOS path |
Guarded writes
Tool | What it does |
| Preview a RouterOS script change with risk assessment |
| Apply a planned change inside a Safe Mode session with snapshot and auto-rollback |
| List config snapshots taken before writes, newest first |
| Unified diff between two config snapshots of a device |
Write access is blocked unless the target device has allow_writes: true. The intended workflow is: plan_script_change → inspect risk level and approval code → apply_script_change only if the plan is acceptable.
Safe Mode writes
Every apply_script_change runs a lockout-proof pipeline — there is no unprotected write path:
Snapshot — the full config is exported to
~/.mikrotik-mcp/snapshots/<device>/<timestamp>.rscbefore anything is sent.Safe Mode — the change is applied inside a RouterOS Safe Mode console session over a persistent SSH PTY. Safe Mode is console-only (neither the binary API nor REST expose it), which is why this engine drives a real terminal.
Health check — after applying, the router must still answer over a separate SSH connection.
Commit or revert — healthy: Safe Mode is released and the change is kept. Unhealthy, timed out, or the session drops (including because the change itself cut our connectivity): the router reverts the change itself. That is RouterOS's own rollback mechanism, not a best-effort undo script.
Devices without ssh in transport_order fail closed — writes are refused rather than applied unprotected. The health check is deliberately minimal (management path answers); it catches lockouts, not subtle misconfiguration — review diff_snapshots output after any change that matters.
Claude Desktop
{
"mcpServers": {
"mikrotik-routeros": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mikrotik-routeros-mcp", "python", "-m", "mikrotik_routeros_mcp.server"],
"env": {
"MIKROTIK_ROUTEROS_CONFIG": "/path/to/devices.yaml"
}
}
}
}VS Code / Cursor
{
"servers": {
"mikrotik-routeros": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mikrotik-routeros-mcp", "python", "-m", "mikrotik_routeros_mcp.server"],
"env": {
"MIKROTIK_ROUTEROS_CONFIG": "/path/to/devices.yaml"
}
}
}
}Codex
Create a codex.json MCP config file:
{
"mcpServers": {
"mikrotik-routeros": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mikrotik-routeros-mcp", "python", "-m", "mikrotik_routeros_mcp.server"],
"env": {
"MIKROTIK_ROUTEROS_CONFIG": "/path/to/devices.yaml"
}
}
}
}Then run Codex with:
codex --mcp-config codex.jsonProduction safety
Device-scoped targeting — the model must choose a named target router explicitly. No ambient "default device" behavior.
Write gating — write access is blocked per-device unless
allow_writes: trueis set in config. Read tools are always available.Guarded write flow —
plan_script_changereturns a risk assessment and approval code.apply_script_changerequires that approval code to proceed.Transport fallback — attempts
api, thenapi-ssl, thensshin order, so the server connects via the best available transport without manual switching.Read-only API guard —
run_api_printblocks mutating RouterOS API paths by design.Input validation — all tools validate parameters before any API call is made. Invalid inputs return structured JSON errors, never raw exceptions.
Development
uv sync
uv run python -m pytest -vLicense
Available Tools
26 toolsaddress_listsD
Inputs: device (required), list_name. Returns: result
apply_script_changeA
Apply a change inside a RouterOS Safe Mode session: the config is snapshotted first, and the router itself reverts the change if the session drops or the post-apply health check fails.
Inputs: device (required), reason (required), script (required), approval_code (required). Returns: result
bridge_portsD
Inputs: device (required), bridge_name. Returns: result
bridgesD
Inputs: device (required). Returns: result
describe_deviceD
Inputs: device (required). Returns: result
dhcp_leasesD
Inputs: device (required), dynamic_only. Returns: result
dhcp_serversD
Inputs: device (required). Returns: result
diff_snapshotsC
Unified diff between two config snapshots of a device.
Inputs: device (required), new_id (required), old_id (required). Returns: result
dns_settingsD
Inputs: device (required). Returns: result
export_configD
Inputs: device (required), hide_sensitive. Returns: result
firewall_filtersD
Inputs: device (required), chain, disabled_only. Returns: result
get_server_configD
Inputs: no named parameters. Returns: result
interfacesD
Inputs: device (required), include_disabled. Returns: result
ip_addressesD
Inputs: device (required). Returns: result
list_devicesD
Inputs: no named parameters. Returns: result
list_snapshotsB
List config snapshots taken before Safe Mode writes, newest first.
Inputs: device (required). Returns: result
logsD
Inputs: device (required), limit, topics. Returns: result
nat_rulesD
Inputs: device (required), disabled_only. Returns: result
neighborsD
Inputs: device (required). Returns: result
pingD
Inputs: device (required), address (required), count. Returns: result
plan_script_changeD
Inputs: device (required), reason (required), script (required). Returns: result
routesD
Inputs: device (required), active_only. Returns: result
run_api_printD
Inputs: path (required), device (required), parameters_json. Returns: result
system_infoD
Inputs: device (required). Returns: result
wireguard_interfacesD
Inputs: device (required). Returns: result
wireguard_peersD
Inputs: device (required), interface_name. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 26 tools
Most tools target a distinct RouterOS resource, but `run_api_print` overlaps broadly with the per-resource getters, and `describe_device` vs `system_info` could be confused for device-level metadata. Overall, boundaries are mostly clear but not completely unambiguous.
Names use lower_snake_case, but the pattern varies: `list_devices`, `describe_device`, and `get_server_config` are verb_noun, while `interfaces`, `routes`, and `nat_rules` are bare plural nouns. `run_api_print` and `diff_snapshots` further mix action styles, making the convention inconsistent yet still readable.
With 26 tools, the set is over the comfortable range and many look like 1-1 maps to read a single recurring resource. The count adds clutter for an agent, and `run_api_print` already covers a more generic route. Some overlapping read tools could be consolidated.
The set covers device discovery, system info, networking health endpoints, dynamic tables, WireGuard, logs, ping, config export, and a safe-mode script-change workflow with snapshots. It lacks explicit per-resource CRUD and a rollback-restore from snapshots, but `apply_script_change` is a reasonable generic mechanism for management.
Maintenance
Related MCP Connectors
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
BYOK AI router & FinOps control plane: audit token waste, check tool safety, and rank models.
Ask your Quickbase apps in plain language. Read-only by default; writes need human approval.
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
- AlicenseCqualityAmaintenanceProvides a bridge between AI assistants and MikroTik RouterOS devices, enabling natural language management of VLANs, firewall rules, DNS settings, and more.2392,499 PyPI348MIT
- AlicenseNot gradedqualityCmaintenanceProvides read-only (with limited address-list management) access to MikroTik RouterOS routers, enabling monitoring of system info, interfaces, DHCP leases, firewall rules, and more via natural language.2MIT
- AlicenseNot gradedqualityCmaintenanceBridges AI assistants with MikroTik RouterOS devices, enabling natural language management of network configurations, firewall, VLANs, VPNs, and diagnostics via ~300 tools.1MIT