Skip to main content
Glama
scarecr0w12

discord-mcp

leave_thread

Remove the bot from a Discord thread to stop receiving notifications and messages in that specific conversation channel.

Instructions

Make the bot leave a thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
threadIdYesThe ID of the thread

Implementation Reference

  • The async handler function for the leave_thread tool. Fetches the Discord guild and thread, verifies it's a thread channel, calls thread.leave(), handles errors with withErrorHandling, and returns formatted response.
    async ({ guildId, threadId }) => {
      const result = await withErrorHandling(async () => {
        const client = await getDiscordClient();
        const guild = await client.guilds.fetch(guildId);
        const thread = await guild.channels.fetch(threadId);
    
        if (!thread || !thread.isThread()) {
          throw new Error('Thread not found');
        }
    
        await thread.leave();
    
        return { threadId, threadName: thread.name, message: 'Left thread successfully' };
      });
    
      if (!result.success) {
        return { content: [{ type: 'text', text: result.error }], isError: true };
      }
    
      return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
    }
  • Zod input schema defining required parameters: guildId (server ID) and threadId.
    {
      guildId: z.string().describe('The ID of the server (guild)'),
      threadId: z.string().describe('The ID of the thread'),
    },
  • Direct registration of the leave_thread tool using server.tool() with name, description, input schema, and handler function.
    server.tool(
      'leave_thread',
      'Make the bot leave a thread',
      {
        guildId: z.string().describe('The ID of the server (guild)'),
        threadId: z.string().describe('The ID of the thread'),
      },
      async ({ guildId, threadId }) => {
        const result = await withErrorHandling(async () => {
          const client = await getDiscordClient();
          const guild = await client.guilds.fetch(guildId);
          const thread = await guild.channels.fetch(threadId);
    
          if (!thread || !thread.isThread()) {
            throw new Error('Thread not found');
          }
    
          await thread.leave();
    
          return { threadId, threadName: thread.name, message: 'Left thread successfully' };
        });
    
        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:64-64 (registration)
    Invocation of registerThreadTools(server) in the main MCP server setup, which registers the leave_thread tool among other thread tools.
    registerThreadTools(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this requires permissions, is reversible, affects thread visibility, or has side effects. 'Leave' is ambiguous—it could imply silent exit or notification. More context on behavior is needed for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero waste—'Make the bot leave a thread' is front-loaded and efficiently conveys the core action. No extraneous details or redundancy are present.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on permissions, effects, error conditions, or return values. Given the complexity of thread management and sibling tools, more context is needed to ensure correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, clearly documenting both parameters (guildId and threadId). The description adds no additional meaning beyond the schema, such as parameter relationships or usage examples. Baseline 3 is appropriate since the schema adequately covers parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Make the bot leave a thread' states the action (leave) and resource (thread), but it's vague about what 'leave' means operationally (e.g., exiting participation vs. deleting). It distinguishes from siblings like 'join_thread' and 'delete_thread' by implying a non-destructive exit, but lacks specificity about the bot's role or effects.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'delete_thread' or 'remove_thread_member'. The description implies usage for bot departure from threads, but doesn't specify prerequisites (e.g., bot must be in the thread) or exclusions (e.g., cannot leave if bot owns the thread).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/scarecr0w12/discord-mcp'

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