join_thread
Add a bot to a Discord thread to enable participation and management within that specific conversation channel.
Instructions
Make the bot join a thread
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guildId | Yes | The ID of the server (guild) | |
| threadId | Yes | The ID of the thread |
Implementation Reference
- src/tools/thread-tools.ts:280-301 (handler)Handler function that fetches the Discord guild and thread, validates the thread, calls thread.join() to make the bot join, and returns a formatted response or error.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.join(); return { threadId, threadName: thread.name, message: 'Joined 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/tools/thread-tools.ts:277-279 (schema)Zod input schema defining required string parameters: guildId and threadId.guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), },
- src/tools/thread-tools.ts:274-301 (registration)Registration of the 'join_thread' tool on the MCP server using server.tool(), including name, description, schema, and inline handler.'join_thread', 'Make the bot join 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.join(); return { threadId, threadName: thread.name, message: 'Joined 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)Call to registerThreadTools on the main MCP server instance in the application entry point, which includes the join_thread tool registration.registerThreadTools(server);