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
Visit Server

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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured