list_servers
View all Discord servers where the bot is currently active to manage connections and monitor presence.
Instructions
List the Discord servers the bot is currently connected to.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function `handle_list_servers` that executes the tool logic by fetching and formatting the list of Discord guilds (servers) the bot is in.@staticmethod async def handle_list_servers(discord_client, arguments: Dict[str, Any]) -> List[TextContent]: """List all servers the bot has access to""" servers_info = [] for guild in discord_client.guilds: servers_info.append({ "name": guild.name, "id": guild.id, "member_count": guild.member_count, "created_at": guild.created_at.strftime('%Y-%m-%d'), "owner_id": guild.owner_id }) if not servers_info: return [TextContent(type="text", text="No servers found. Make sure the bot is invited to servers.")] # Format the server list server_list = "\n".join([ f"**{server['name']}**\n" f" - ID: {server['id']}\n" f" - Members: {server['member_count']}\n" f" - Created: {server['created_at']}\n" for server in servers_info ]) return [TextContent( type="text", text=f"**Available Servers ({len(servers_info)}):**\n\n{server_list}" )]
- src/discord_mcp/integrated_server.py:928-937 (registration)Registration of the 'list_servers' tool in the MCP server's tool list, including its description and empty input schema.Tool( name="list_servers", description="Get a list of all Discord servers the bot has access to with detailed information", inputSchema={ "type": "object", "properties": {}, "required": [] } ) ]
- src/discord_mcp/integrated_server.py:1021-1032 (registration)Routing logic in `call_tool` that maps the 'list_servers' tool name to the corresponding handler method in CoreToolHandlers.core_tool_names = [ "get_server_info", "list_servers", "get_channels", "list_members", "get_user_info", "send_message", "read_messages", "add_reaction", "add_multiple_reactions", "remove_reaction", "moderate_message", "create_text_channel", "delete_channel", "add_role", "remove_role" ] if name in core_tool_names: handler_method = f"handle_{name}" if hasattr(CoreToolHandlers, handler_method): return await getattr(CoreToolHandlers, handler_method)(discord_client, arguments)