Skip to content

About

MCP (Model Context Protocol) server that exposes the LibreNMS REST API as MCP tools. Built with FastMCP.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

mcp-librenms

Server MCP (Model Context Protocol) yang mengekspos REST API LibreNMS sebagai tool MCP. Dibangun dengan FastMCP. Hubungkan asisten AI (Claude Desktop, GitHub Copilot, dll.) ke instance LibreNMS Anda untuk mengueri perangkat yang dipantau, port, alert, log, routing, dan lain-lain. Semua tool bersifat read-only — tidak pernah menambah, mengubah, atau menghapus apa pun di LibreNMS.

Fitur

±51 tool read-only yang mencakup:

Kategori Tool
System ping, system_info
Devices list_devices, get_device, discover_device, get_device_ports, get_device_ip_addresses, get_device_availability, get_device_outages, get_device_groups, get_device_components, get_device_graphs, get_device_maintenance
Alerts list_alerts, get_alert, list_alert_rules, get_alert_rule
Ports get_all_ports, search_ports, get_port_info, get_port_ip_info, ports_with_mac
Logs list_eventlog, list_syslog, list_alertlog, list_authlog
Locations list_locations, get_location
Sensors list_sensors
Device groups list_devicegroups, get_devicegroup
ARP list_arp
Services list_services
Inventory get_inventory
Routing get_routing_table, list_bgp_peers, get_bgp_peer, list_bgp_prefix_counters, list_ospf_neighbors, list_ospf_ports, list_ospfv3_neighbors, list_ospfv3_ports
Health / VLAN / MAC get_device_health, list_vlans, get_device_vlans, list_mac, get_mac, search_mac
Lookup / BGP / Report lookup_device, bgp_session, device_report

Persyaratan

  • Python 3.9+
  • Instance LibreNMS dengan akses API
  • API token (web UI LibreNMS: Settings > API > API Settings)

Instalasi

# 1. Buat dan aktifkan virtual environment
python -m venv .venv
.venv\Scripts\activate        # Windows
source .venv/bin/activate     # Linux/macOS

# 2. Instal paket (mode editable)
pip install -e .

# 3. Konfigurasi
copy config.example.yaml config.yaml   # Windows
# cp config.example.yaml config.yaml   # Linux/macOS
# lalu edit config.yaml dengan URL dan API token LibreNMS Anda

Atau
# dari clone lokal repository ini
pipx install mcp-librenms

Atau
# langsung dari GitHub (ganti <your-username>)
pipx install "git+https://github.com/LLMNetOps/mcp-librenms.git"

Konfigurasi

config.yaml (gitignored — jangan pernah di-commit):

librenms:
  url: "http://your-librenms-host"   # base URL, tanpa slash di akhir
  token: "your-api-token"            # web UI LibreNMS: Settings > API > API Settings

Menjalankan

Server secara default berbicara MCP melalui streamable HTTP, terikat pada 0.0.0.0:5757:

# Console script (foreground)
mcp-librenms --config config.yaml

# Atau sebagai modul
python -m mcp_librenms --config config.yaml

Endpoint: http://<IP>:5757/mcp

Opsi

Flag Default Keterangan
--config FILE config.yaml Path file konfigurasi YAML (CWD, lalu root proyek)
--host IP 0.0.0.0 Alamat bind
--port PORT 5757 Port bind
--daemon off Jalankan di background (proses detached)
--stdio off Gunakan transport stdio alih-alih HTTP

Contoh:

# Background pada alamat/port kustom
mcp-librenms --config config.yaml --daemon --host 192.168.1.10 --port 8080
# → http://192.168.1.10:8080/mcp

# Transport stdio (untuk klien MCP yang menjalankan server)
mcp-librenms --config config.yaml --stdio

Konfigurasi klien MCP

Contoh untuk klien MCP mana pun yang mendukung server streamable HTTP:

{
  "mcpServers": {
    "librenms": {
      "url": "http://your-librenms-host:5757/mcp"
    }
  }
}

Untuk klien berbasis stdio (Claude Desktop, dll.), jalankan server dengan --stdio dan arahkan --config ke file konfigurasi Anda:

{
  "mcpServers": {
    "librenms": {
      "command": "D:\\path\\to\\.venv\\Scripts\\mcp-librenms.exe",
      "args": ["--config", "D:\\path\\to\\mcp-librenms\\config.yaml", "--stdio"]
    }
  }
}

Catatan: klien menggunakan verify=False untuk TLS, sehingga tetap berfungsi dengan instance LibreNMS yang berada di balik sertifikat self-signed.

Struktur proyek

mcp-librenms/
├── config.example.yaml   # Template konfigurasi lokal
├── config.yaml           # Konfigurasi lokal Anda (gitignored)
├── .gitignore
├── README.md
├── pyproject.toml        # Metadata paket + console script
├── requirements.txt      # Daftar dependensi
└── mcp_librenms/
    ├── __init__.py
    ├── __main__.py       # python -m mcp_librenms
    ├── client.py         # Klien HTTP REST API LibreNMS
    └── server.py         # Server MCP + definisi tool

Lisensi

MIT

About

MCP (Model Context Protocol) server that exposes the LibreNMS REST API as MCP tools. Built with FastMCP.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages