tools.list_active_servers module
List all servers/guilds and channels the bot is active in.
╔═══════════════════════════════════════════════════════════════════════════════╗ ║ 🌐 CROSS-PLATFORM SERVER LISTING ║ ╠═══════════════════════════════════════════════════════════════════════════════╣ ║ list_active_servers — Shows every server, guild, and channel across all ║ ║ connected platforms (Discord, Matrix, …) ║ ╚═══════════════════════════════════════════════════════════════════════════════╝
- async tools.list_active_servers.run(ctx=None)[source]
Return a JSON inventory of every platform, server, and channel.
Entry point for the
list_active_serverstool. It gives the bot a cross-platform view of where it is present – every Discord guild, Matrix room, and so on – grouped by platform with each server’s channels nested underneath, so the model can reason about where it can act.Prefers a fast Redis path: it scans
sg:platform:inventory:*keys onctx.redisand reconstructs the inventory from those cached blobs, deriving the platform name from the key suffix. If the cache is empty or unavailable, it falls back to live adapters fromctx.all_adapters, awaiting each running adapter’slist_servers_and_channels()and recording per-platform errors rather than failing the whole call. Read-only apart from those Redis reads; per-platform exceptions are logged via the modulelogger. Dispatched through the tool loader’sgetattr(module, "run")path (seetool_loader.py) and exercised directly bytests/core/migration/test_list_active_servers_caching.py.- Parameters:
ctx (
ToolContext|None) – TheToolContext;redisandall_adaptersare read from it.Noneyields an error envelope.- Returns:
A pretty-printed JSON object with
success,platform_countand aplatformslist (each entry carryingrunning, itsservers, andserver_count/total_channelsor anerror); or an error envelope when no context or no adapters are available.- Return type: