add_thread_member
Add a user to a Discord thread by providing the server, thread, and user IDs. This tool enables thread management within Discord servers.
Instructions
Add a member to 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 | |
| userId | Yes | The ID of the user to add |
Implementation Reference
- src/tools/thread-tools.ts:343-363 (handler)The handler function that executes the tool: fetches Discord client, guild, and thread, validates thread, adds user member with thread.members.add(userId), handles errors, and returns result.async ({ guildId, threadId, userId }) => { 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.members.add(userId); return { threadId, userId, message: 'Member added to thread' }; }); 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:338-342 (schema)Zod input schema defining required string parameters: guildId, threadId, userId.{ guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), userId: z.string().describe('The ID of the user to add'), },
- src/tools/thread-tools.ts:335-364 (registration)Registration of the 'add_thread_member' tool using McpServer.tool() with name, description, input schema, and inline handler function.server.tool( 'add_thread_member', 'Add a member to a thread', { guildId: z.string().describe('The ID of the server (guild)'), threadId: z.string().describe('The ID of the thread'), userId: z.string().describe('The ID of the user to add'), }, async ({ guildId, threadId, userId }) => { 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.members.add(userId); return { threadId, userId, message: 'Member added to thread' }; }); if (!result.success) { return { content: [{ type: 'text', text: result.error }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] }; } );