mikrotik-mcp

mikrotik-mcp

MCP server for managing MikroTik RouterOS fleets, exposing 65+ tools for system administration, interfaces, firewall, DHCP/DNS, PPP, diagnostics, and SSH command execution with KeePass-backed credentials.

Category
访问服务器

README

mikrotik-mcp

CI License Docker

An MCP (Model Context Protocol) server for managing fleets of MikroTik RouterOS devices from AI assistants such as Claude.

It exposes 65 tools covering system administration, interfaces, bridging, IP, firewall, DHCP/DNS, PPP, monitoring, and diagnostics — all executed over the RouterOS REST API, with SSH reserved for free-form ros-command execution. Device credentials are never passed through the model: they are resolved from a KeePass vault at runtime.

Highlights

  • Fleet-aware by design — every tool accepts a target of a single device ID, a comma-separated list (R1,R2,R3), or all. Commands fan out in parallel and return per-device results; one unreachable device never fails the batch.
  • REST-first transport — structured JSON from the RouterOS REST API (RouterOS v7.1+), no brittle terminal scraping. SSH is used only for the ros-command escape hatch.
  • KeePass-backed credentials — devices are enumerated from a .kdbx vault group. The LLM only ever sees device IDs, never passwords.
  • Enforced read-only modeREAD_ONLY=true withholds all 14 write/execution and active-diagnostic tools at the protocol level, exposing only the 51 state-query tools. Ideal for monitoring-only agent access. Approval of individual write calls is left to the MCP client, which is where it can actually be enforced (see Write operations and approval).
  • Two MCP transportsstdio for local clients (Claude Desktop, Claude Code) and Streamable HTTP (with legacy SSE fallback) for a shared team server.

Tool overview

Area Examples
System identity, clock, health, hardware, packages, license, history, note, certificates, log, files
Interfaces & bridging interface list/stats, enable/disable, interface lists, bridges, ports, VLANs, MAC table, neighbors
IP addresses, ARP, routes, pools, IP settings, IP services
Firewall filter, NAT, mangle, address lists, connection tracking, RADIUS
DHCP & DNS DHCP client/server, leases, networks, DNS settings, static entries
PPP & users profiles, secrets, active sessions, AAA, system users, scheduler, scripts, logging rules
Services NTP, SNMP, reboot/shutdown
Diagnostics ping, traceroute, bandwidth test, torch, packet sniffer, profile, netwatch, fetch, speed test, WoL, MAC/IP scan, traffic generator
Fleet & escape hatch device-list, setup-new-device, ros-command (arbitrary CLI over SSH)

Quick start

1. Prepare the credential vault

Create a KeePass vault (e.g. config/vault.kdbx) with one entry per device inside a group (default: mikrotik):

  • Title → device ID (how you'll refer to the device in prompts)
  • Username / Password → RouterOS credentials
  • URL → device hostname or IP

2. Run with Docker (shared HTTP server)

Using the prebuilt image:

docker run -d -p 8000:8000 \
  -v ./config:/config:ro \
  -e KEEPASS_PASSWORD='…' \
  ghcr.io/vesact/mikrotik-mcp:latest   # serves MCP on http://localhost:8000/mcp

Or build from source:

cp .env.example .env        # set KEEPASS_PASSWORD at minimum
docker compose up -d

3. Or run locally over stdio (Claude Desktop / Claude Code)

npm ci && npm run build
{
  "mcpServers": {
    "mikrotik": {
      "command": "node",
      "args": ["/path/to/mikrotik-mcp/dist/index.js"],
      "env": {
        "KEEPASS_PATH": "/path/to/vault.kdbx",
        "KEEPASS_PASSWORD": "…"
      }
    }
  }
}

Then ask things like:

"What's the RouterOS version across the whole fleet?" "Show DHCP leases on router-01." "Add a firewall filter on R1,R2."

Configuration

All configuration is via environment variables (see .env.example):

Variable Default Purpose
KEEPASS_PASSWORD — (required) Master password of the KeePass vault
KEEPASS_PATH /config/keepass.kdbx Path to the .kdbx vault file
KEEPASS_GROUP mikrotik Vault group to enumerate devices from
ROUTEROS_REST_PORT 443 REST API port on target devices
ROUTEROS_REST_SCHEME https https or http
ROUTEROS_TIMEOUT_MS 10000 REST request timeout
SSH_TIMEOUT_MS 10000 Per-command SSH timeout (ros-command)
ROUTEROS_SETUP_PORT 80 (unchanged) Target www port when bootstrapping via setup-new-device
MCP_TRANSPORT stdio (http in the Docker image) MCP transport
MCP_HTTP_PORT 3000 (8000 in the Docker image) HTTP listen port
MCP_HOST 0.0.0.0 HTTP bind address
READ_ONLY false Expose only read-only state-query tools

Read-only mode

With READ_ONLY=true (also accepts 1/yes/on), the server exposes only the 51 read-only tools. ros-command, setup-new-device, and all active diagnostics (ping, traceroute, torch, bandwidth test, scans, …) are withheld — they mutate state or generate network traffic. The allow-list is explicit, so tools added in the future are withheld until deliberately classified.

Write operations and approval

The server does not implement its own confirmation step for writes. Write tools execute on the first call, and ros-command in particular runs whatever it is given, verbatim, on every device matched by target.

Approving individual calls is the MCP client's job — it is the layer that can actually enforce a decision and scope it per agent:

  • Claude Code — permission modes plus allow/ask/deny rules, e.g. "deny": ["mcp__mikrotik__ros-command"] or an ask rule for the whole server, in .claude/settings.json.
  • Claude Desktop and other hosts — per-tool approval prompts, kept enabled for this server.

ros-command carries MCP annotations (readOnlyHint: false, destructiveHint: true) so clients can classify it without parsing its description.

Two server-side controls remain, because they are enforcement rather than instruction:

  • READ_ONLY=true — the tools are never registered, so no client configuration can invoke them.
  • The RouterOS credentials in the vault — a device account with restricted permissions bounds what any approved command can do.

Requirements

  • Node.js ≥ 22 (or Docker)
  • RouterOS v7.1+ with the REST API enabled (www-ssl or www service) on managed devices
  • SSH enabled on devices only if you use ros-command or setup-new-device

Development

npm ci
npm run build          # TypeScript → dist/
npm test               # unit tests (Vitest, no hardware needed)
npm run check          # lint + format check (Biome)
npm run check:fix      # apply Biome's fixes and formatting
npm run test:integration   # integration tests against real hardware (see .env.test.example)

Unit tests run against fixtures, including a committed test vault (tests/fixtures/test-vault.kdbx, password test-password-123 — fake credentials only). Integration tests require a reachable RouterOS device and are configured via .env.test.

Architecture

MCP client (Claude, …)
   │  stdio / Streamable HTTP
   ▼
mikrotik-mcp server ──► KeePass vault (device inventory + credentials)
   │
   │  fan-out: target = "R1" | "R1,R2" | "all"   (parallel, per-device results)
   ▼
RouterOS REST API (all tools)  /  SSH (ros-command only)

The full architecture document lives in docs/architecture.md, and the original product requirements in docs/prd.md.

Contributing

See CONTRIBUTING.md. Security issues: see SECURITY.md.

License

Licensed under the Apache License 2.0.

Copyright 2026 Actemium Schweiz AG — a VINCI Energies company.

MikroTik and RouterOS are trademarks of Mikrotīkls SIA. This project is not affiliated with or endorsed by MikroTik.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选