ntopng/scripts/lua/modules/llm/tools/get_interface_addresses.lua
Jacopo Andrea Bianco 1ea8a0b4ef
Add new Lua tools for MCP server (#10476)
* Add new Lua tools for MCP server

* fix: discover_lan.lua
2026-06-23 16:41:58 +02:00

35 lines
967 B
Lua

--
-- (C) 2013-26 - ntop.org
--
local json = require("dkjson")
return {
name = "get_interface_addresses",
description = "Return the IP addresses assigned to the currently monitored network interface. " ..
"Useful to identify the local machine IP without heuristics.",
handler = function(args)
local ifstats = interface.getStats()
if not ifstats then
return nil, "Unable to retrieve interface stats"
end
local out = {
interface = ifstats.name or interface.getName(),
ifid = ifstats.id,
addresses = {},
}
if not isEmptyString(ifstats.ip_addresses) then
local tokens = split(ifstats.ip_addresses, ",")
for _, addr in pairs(tokens or {}) do
if not isEmptyString(addr) then
out.addresses[#out.addresses + 1] = addr
end
end
end
return json.encode(out), nil
end,
opts = { read_only = true }
}