MikroTik MCP Server

MikroTik MCP Server

Enables management of MikroTik routers running RouterOS 6 and 7 via SSH, Telnet, or API with automatic command adaptation. Provides over 46 MCP tools for device management, firewall, DHCP, VPN, configuration profiles, and more.

Category
访问服务器

README

MikroTik MCP Server

A robust Model Context Protocol (MCP) server for managing MikroTik routers running RouterOS 6 and 7. Provides seamless connectivity via SSH, Telnet, or API with automatic command adaptation.

Python Version License MCP

🚀 Quick Start (Python - Recommended)

Python version is simpler and easier to deploy!

1. Install

pip install -e .

2. Configure

Copy and edit the example configuration:

cp devices.json.example devices.json
# Edit devices.json with your router details

3. Add to Claude Desktop

Add to your Claude Desktop config (%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "mikrotik": {
      "command": "python",
      "args": ["-m", "mikrotik_mcp.server"]
    }
  }
}

4. Start Using

Restart Claude Desktop and try:

List my MikroTik devices
Connect to router-main and show system info

📖 Read Full Python Documentation →

✨ Features

  • 46+ MCP Tools: Complete router management suite
  • Multi-Protocol Support: SSH (recommended), API, Telnet
  • RouterOS 6 & 7 Compatible: Automatic command adaptation
  • Advanced Features:
    • Firewall management (filter, NAT, address lists)
    • DHCP server configuration
    • VPN setup (IPsec, L2TP, WireGuard)
    • Configuration profiles
    • Backup/restore
    • Audit logging
    • Fleet management

📦 Installation Options

Python (Recommended)

# Windows
install-python.bat

# Linux/macOS
chmod +x install-python.sh
./install-python.sh

TypeScript (Advanced)

npm install
npm run build

🔧 MCP Tools Available

Device Management (13 tools)

  • list_devices - List all configured routers
  • connect_device - Establish connection
  • execute_command - Run any RouterOS command
  • get_system_info - System resources
  • get_interfaces - Network interfaces
  • get_firewall_rules - Firewall configuration
  • backup_config - Export configuration
  • And more...

Firewall Management (5 tools)

  • firewall_add_filter_rule - Add filter rules
  • firewall_add_nat_rule - Configure NAT
  • firewall_add_address_list - Manage address lists
  • firewall_get_address_list - View address lists
  • firewall_remove_rule - Remove rules

DHCP Management (5 tools)

  • dhcp_create_server - Create DHCP server
  • dhcp_add_network - Configure network
  • dhcp_add_static_lease - Add static leases
  • dhcp_create_pool - Create IP pools
  • dhcp_get_servers - List DHCP servers

VPN Management (8 tools)

  • IPsec: vpn_add_ipsec_peer, vpn_get_ipsec_peers
  • L2TP: vpn_add_l2tp_user, vpn_configure_l2tp_server, vpn_get_l2tp_connections
  • WireGuard: vpn_add_wireguard_interface, vpn_add_wireguard_peer, vpn_get_wireguard_interfaces
  • Generic: vpn_get_ppp_secrets

Configuration Profiles (6 tools)

  • profile_list - List available profiles
  • profile_get - Get profile details
  • profile_preview - Preview commands
  • profile_apply - Apply profile to device
  • profile_validate - Validate profile
  • profile_save_current - Save device config as profile

Advanced Features (9 tools)

  • execute_batch_commands - Run multiple commands
  • get_fleet_status - Multi-device overview
  • execute_on_all_devices - Run command on all
  • compare_configs - Compare two devices
  • get_command_history - Audit log access
  • get_device_audit_stats - Device statistics
  • get_connection_stats - Connection metrics
  • export_config - Export without saving
  • restore_config - Restore from backup

📁 Project Structure

mikrotik_mcp/
├── server.py              # Main MCP server
├── device_manager.py      # Device lifecycle management
├── models.py              # Pydantic data models
├── connections/           # SSH, Telnet, API implementations
├── modules/               # Feature modules
│   ├── firewall.py       # Firewall management
│   ├── dhcp.py           # DHCP management
│   ├── vpn.py            # VPN management
│   └── profiles.py       # Configuration profiles
├── audit.py              # Audit logging
├── cache.py              # Response caching
├── retry.py              # Connection retry logic
└── logger.py             # Structured logging

🔒 Security

  • Never commit devices.json or .env (already in .gitignore)
  • Use SSH instead of Telnet (encrypted)
  • Store passwords in environment variables
  • Enable audit logging for compliance
  • Regularly update RouterOS firmware

📚 Documentation

🧪 Testing

# Run tests
pytest

# With coverage
pytest --cov=mikrotik_mcp --cov-report=html

# Specific test
pytest tests/test_device_manager.py

🤝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📝 License

MIT License - See LICENSE file for details

🙏 Credits

Built with:

🐛 Support

For issues:

  1. Check Troubleshooting Guide
  2. Review Documentation
  3. Check existing GitHub issues
  4. Create a new issue with details

🗺️ Roadmap

  • [x] Basic device management
  • [x] SSH/API/Telnet support
  • [x] RouterOS 6/7 compatibility
  • [x] Firewall management
  • [x] DHCP management
  • [x] VPN management (IPsec, L2TP, WireGuard)
  • [x] Configuration profiles
  • [x] Audit logging
  • [ ] Wireless management
  • [ ] Queue management
  • [ ] Hotspot management
  • [ ] User management
  • [ ] Backup scheduling
  • [ ] SSH key authentication
  • [ ] Web-based dashboard

Happy routing! 🚀

For detailed setup and usage, see the Python Documentation.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选