Skip to main content
Glama

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
NameRequiredDescriptionDefault
guildIdYesThe ID of the server (guild)
threadIdYesThe ID of the thread
userIdYesThe ID of the user to add

Implementation Reference

  • 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) }] }; }
  • 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'), },
  • 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) }] }; } );

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