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_servers tool. 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 on ctx.redis and 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 from ctx.all_adapters, awaiting each running adapter’s list_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 module logger. Dispatched through the tool loader’s getattr(module, "run") path (see tool_loader.py) and exercised directly by tests/core/migration/test_list_active_servers_caching.py.

Parameters:

ctx (ToolContext | None) – The ToolContext; redis and all_adapters are read from it. None yields an error envelope.

Returns:

A pretty-printed JSON object with success, platform_count and a platforms list (each entry carrying running, its servers, and server_count / total_channels or an error); or an error envelope when no context or no adapters are available.

Return type:

str