Skip to main content
Glama

list_servers

View all Discord servers where the bot is currently active to manage connections and monitor bot presence.

Instructions

List the Discord servers the bot is currently connected to.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that iterates over discord_client.guilds, collects server details (name, ID, member count, created_at, owner_id), formats a markdown list, and returns as TextContent. Handles empty case.
    @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}" )]
  • Registers the 'list_servers' tool in the @app.list_tools() function with description and empty inputSchema (no args needed).
    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": [] } ) ]
  • In @app.call_tool() dispatcher, includes 'list_servers' in core_tool_names list and dynamically calls CoreToolHandlers.handle_list_servers if matched.
    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)
  • Imports the CoreToolHandlers class containing the list_servers handler.
    from .core_tool_handlers import CoreToolHandlers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wowjinxy/mcp-discord'

If you have feedback or need assistance with the MCP directory API, please join our Discord server