list_servers
Retrieve all Discord servers where the bot is a member. Use this tool to view accessible guilds for management tasks.
Instructions
List all Discord servers (guilds) the bot has access to
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_servers"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/server-tools.ts:12-37 (handler)The handler function for the 'list_servers' tool. It uses the Discord client to fetch all guilds (servers) the bot is in, extracts basic information (id, name, memberCount, ownerId, icon), handles errors with withErrorHandling, and returns the list as a formatted JSON string.
async () => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guilds = client.guilds.cache.map((guild) => ({ id: guild.id, name: guild.name, memberCount: guild.memberCount, ownerId: guild.ownerId, icon: guild.iconURL(), })); return guilds; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [ { type: 'text', text: JSON.stringify(result.data, null, 2), }, ], }; } - src/tools/server-tools.ts:11-11 (schema)Input schema for 'list_servers' tool: empty object, indicating no input parameters are required.
{}, - src/tools/server-tools.ts:8-38 (registration)Direct registration of the 'list_servers' tool on the MCP server within the registerServerTools function, including name, description, schema, and handler.
server.tool( 'list_servers', 'List all Discord servers (guilds) the bot has access to', {}, async () => { const result = await withErrorHandling(async () => { const client = await getDiscordClient(); const guilds = client.guilds.cache.map((guild) => ({ id: guild.id, name: guild.name, memberCount: guild.memberCount, ownerId: guild.ownerId, icon: guild.iconURL(), })); return guilds; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [ { type: 'text', text: JSON.stringify(result.data, null, 2), }, ], }; } ); - src/index.ts:54-54 (registration)Invocation of registerServerTools to register the server tools module (including 'list_servers') on the main MCP server instance.
registerServerTools(server);