### Manual Installation of MCP-Discord Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Steps for manually installing MCP-Discord by cloning the repository, installing dependencies, and building the project. This method is suitable for development or when direct control over the codebase is needed. ```bash # Clone the repository git clone https://github.com/barryyip0625/mcp-discord.git cd mcp-discord # Install dependencies npm install # Compile TypeScript npm run build ``` -------------------------------- ### Start HTTP Server Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Starts the HTTP server, listening on a specified port and host. A callback function can be provided to execute upon successful startup. ```typescript const httpServer = app.listen(port, '0.0.0.0', callback); ``` -------------------------------- ### Basic Startup with Environment Variable Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Starts the bot using the DISCORD_TOKEN from the environment. This is a common way to provide the bot token securely. ```bash DISCORD_TOKEN=xyz node build/index.js ``` -------------------------------- ### .env File Example Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Example of a .env file used to store sensitive information like the Discord bot token. This file is automatically loaded by the dotenv package. ```dotenv # .env file in project root DISCORD_TOKEN=your_actual_token_here ``` -------------------------------- ### Install MCP-Discord via NPM Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Use this command to install and run MCP-Discord directly from NPM. Ensure your Discord token is available as an environment variable. ```bash npx mcp-discord --config ${DISCORD_TOKEN} ``` -------------------------------- ### Install MCP Discord Bot Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Install the MCP Discord Bot using npm. This is the standard method for adding the package to your project. ```bash npm install mcp-discord ``` -------------------------------- ### Configure Stdio Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Examples for configuring the Stdio transport, which is the default and suitable for local integrations. No specific configuration is needed for the default behavior. ```bash # Default - no configuration needed node build/index.js --config "token" ``` ```bash # Or explicitly specify node build/index.js --transport stdio --config "token" ``` -------------------------------- ### Run Project with Stdio Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Starts the MCP Discord server using the default Stdio transport. This is the standard way to run the application. ```bash npm start ``` -------------------------------- ### All Arguments Together Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Demonstrates starting the bot with all available command-line arguments: HTTP transport, a custom port (5000), and the Discord bot token via --config. ```bash node build/app.js --transport http --port 5000 --config "xyz" ``` -------------------------------- ### Run Project with HTTP Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Starts the MCP Discord server using the HTTP transport. Use this command if you need to communicate over HTTP. ```bash npm run start-app ``` -------------------------------- ### Run Project in Development Mode Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Starts the MCP Discord server in development mode using ts-node. This allows for faster iteration during development. ```bash npm run dev ``` -------------------------------- ### DiscordMCPServer Tool Routing Example Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Illustrates how tool execution is routed within the DiscordMCPServer. This pattern is used for all tool requests, mapping tool names to their respective handlers. ```typescript switch (name) { case "discord_send": return await sendMessageHandler(args, toolContext); case "discord_login": return await loginHandler(args, toolContext); // ... 40+ other tools } ``` -------------------------------- ### Run Discord Bot in Development Mode Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Use this command to start the Discord bot in development mode. This is useful for making code changes and testing them live. ```bash # Development mode npm run dev ``` -------------------------------- ### Server and Member Information Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Functions for listing servers, getting server info, and managing members. ```APIDOC ## discord_list_servers ### Description Lists all servers the bot is currently in. ### Method GET ### Endpoint /servers ### Response #### Success Response (200) - **servers** (array) - An array of server objects. - **guild_id** (string) - The ID of the server. - **name** (string) - The name of the server. #### Response Example { "servers": [ { "guild_id": "guild_1", "name": "My Awesome Server" }, { "guild_id": "guild_2", "name": "Another Server" } ] } ``` ```APIDOC ## discord_get_server_info ### Description Retrieves information about a specific server. ### Method GET ### Endpoint /guilds/{guild_id} ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the server. ### Response #### Success Response (200) - **guild_id** (string) - The ID of the server. - **name** (string) - The name of the server. - **member_count** (integer) - The number of members in the server. - **owner_id** (string) - The ID of the server owner. #### Response Example { "guild_id": "guild_1", "name": "My Awesome Server", "member_count": 100, "owner_id": "user_owner_1" } ``` ```APIDOC ## discord_list_members ### Description Lists members of a server. ### Method GET ### Endpoint /guilds/{guild_id}/members ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the server. #### Query Parameters - **limit** (integer) - Optional - The maximum number of members to retrieve. - **after** (string) - Optional - Retrieve members after this user ID. ### Response #### Success Response (200) - **members** (array) - An array of member objects. - **user_id** (string) - The ID of the member. - **username** (string) - The username of the member. - **roles** (array) - An array of role IDs the member has. #### Response Example { "members": [ { "user_id": "user_101", "username": "Alice", "roles": ["role_member"] }, { "user_id": "user_102", "username": "Bob", "roles": ["role_member", "role_moderator_123"] } ] } ``` ```APIDOC ## discord_get_member ### Description Retrieves information about a specific member in a server. ### Method GET ### Endpoint /guilds/{guild_id}/members/{user_id} ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the server. - **user_id** (string) - Required - The ID of the member. ### Response #### Success Response (200) - **user_id** (string) - The ID of the member. - **username** (string) - The username of the member. - **roles** (array) - An array of role IDs the member has. - **joined_at** (string) - The timestamp when the member joined. #### Response Example { "user_id": "user_101", "username": "Alice", "roles": ["role_member"], "joined_at": "2023-01-15T09:30:00Z" } ``` ```APIDOC ## discord_search_messages ### Description Searches for messages within a server. ### Method GET ### Endpoint /guilds/{guild_id}/messages/search ### Parameters #### Path Parameters - **guild_id** (string) - Required - The ID of the server. #### Query Parameters - **query** (string) - Required - The search query. - **limit** (integer) - Optional - The maximum number of messages to return. - **channel_id** (string) - Optional - Filter results to a specific channel. ### Response #### Success Response (200) - **messages** (array) - An array of message objects matching the search query. - **message_id** (string) - The ID of the message. - **channel_id** (string) - The ID of the channel the message is in. - **content** (string) - The content of the message. - **author_id** (string) - The ID of the message author. - **timestamp** (string) - The timestamp when the message was sent. #### Response Example { "messages": [ { "message_id": "msg_search_1", "channel_id": "channel_general", "content": "Found a relevant message.", "author_id": "user_101", "timestamp": "2023-10-27T13:00:00Z" } ] } ``` -------------------------------- ### ToolResponse Examples Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/types.md Illustrates successful and error responses using the ToolResponse interface. Use the `isError` flag to indicate failure. ```typescript // Success response { content: [{ type: "text", text: "Successfully created text channel \"general\" with ID: 123456789012345678" }] } ``` ```typescript // Error response { content: [{ type: "text", text: "Discord API Error: Cannot find guild with ID: 999999999999999999" }], isError: true } ``` -------------------------------- ### Example Error Handling Flow in Try-Catch Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/errors.md Demonstrates how to wrap API calls in a try-catch block to capture and handle potential errors using the `handleDiscordError` function. ```typescript try { const channel = await context.client.channels.fetch(channelId); if (!channel || !channel.isTextBased()) { return { content: [{ type: "text", text: `Cannot find text channel ID: ${channelId}` }], isError: true }; } } catch (error) { return handleDiscordError(error); } ``` -------------------------------- ### JSON-RPC Log Output Format Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Example of the JSON-RPC message format used for logging. This structure is sent to standard output. ```json { "jsonrpc": "2.0", "method": "log", "params": { "level": "info", "message": "Successfully logged in to Discord" } } ``` -------------------------------- ### Configure Discord Bot Token Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Provides examples for setting the Discord bot token via command-line argument, environment variable, or a .env file. The token is essential for bot authentication. ```bash # Via command line node build/index.js --config "your_bot_token_here" ``` ```bash # Via environment variable DISCORD_TOKEN=your_bot_token_here node build/index.js ``` ```bash # Via .env file # Create .env file in working directory: # DISCORD_TOKEN=your_bot_token_here node build/index.js ``` -------------------------------- ### Create Role with Hex Color Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/types.md Example of creating a role with a color specified in hexadecimal format. Ensure the color is a valid hex string. ```typescript const response = await createRoleHandler({ guildId: '123456789012345678', name: 'Moderator', color: '#FF5733' // Hex format }, context); ``` -------------------------------- ### Self-Host MCP Discord HTTP Server (Node.js) Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Start the mcp-discord streamable HTTP server using Node.js. Ensure the DISCORD_TOKEN is set and specify the desired port. ```bash DISCORD_TOKEN=your_discord_bot_token node build/app.js --transport http --port 3000 ``` -------------------------------- ### Configure Discord Token via Environment Variable Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Set the DISCORD_TOKEN environment variable to authenticate your Discord bot. This is a common setup step for many integrations. ```bash DISCORD_TOKEN=your_discord_bot_token ``` -------------------------------- ### Stdio Transport with Explicit Token Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Starts the bot using the stdio transport method and explicitly provides the Discord bot token via the --config argument. ```bash node build/index.js --config "xyz" ``` -------------------------------- ### Graceful Degradation Example Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/errors.md Demonstrates a fallback strategy where if a primary method (e.g., sending a message directly) fails, an alternative method (e.g., sending via webhook) is attempted. ```typescript // If send fails, try webhook const sendResponse = await sendMessageHandler(args, context); if (sendResponse.isError) { // Fall back to webhook send const webhookResponse = await sendWebhookMessageHandler(webhookArgs, context); return webhookResponse; } ``` -------------------------------- ### Run MCP Discord with Stdio Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Execute the mcp-discord client using stdio transport, suitable for basic integrations. This command starts the default stdio server. ```bash node build/index.js --config "your_discord_bot_token" ``` -------------------------------- ### HTTP Transport on Custom Port Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Starts the bot using the HTTP transport method on a custom port (3000) and provides the Discord bot token via the --config argument. ```bash node build/app.js --transport http --port 3000 --config "xyz" ``` -------------------------------- ### Configure Streamable HTTP Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Examples for enabling and configuring the Streamable HTTP transport for stateless operation and remote access. The default port is 8080 if not specified. ```bash # Enable HTTP transport node build/app.js --transport http --port 3000 --config "token" ``` ```bash # Default port is 8080 if not specified node build/app.js --transport http --config "token" ``` -------------------------------- ### Zod Schema Structure Example Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Shows the structure for defining Zod schemas used for validating tool arguments in MCP-Discord. This includes required, optional, validated, and enum fields. ```typescript export const ToolNameSchema = z.object({ requiredField: z.string({ description: "Field description" }), optionalField: z.string().optional(), validatedField: z.number().min(1).max(100), enumField: z.enum(['value1', 'value2']) }, { description: "Tool description for MCP client" }); ``` -------------------------------- ### Pagination Pattern with ListMembersHandler Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Illustrates how to fetch members in pages using the 'listMembersHandler'. The first call retrieves the initial set, and subsequent calls use the 'after' parameter with the last received user ID to get the next page. ```typescript // Get first page let members = await listMembersHandler( { guildId: "...", limit: 100 }, { client } ); // Get next page using last user ID members = await listMembersHandler( { guildId: "...", limit: 100, after: "last_user_id" }, { client } ); ``` -------------------------------- ### Build Project Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Compiles TypeScript code to JavaScript in the build directory. Run this command to prepare the project for deployment. ```bash npm run build ``` -------------------------------- ### List Discord Servers Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/servers-and-members.md Use this function to get a list of all Discord servers the bot is currently a member of. It requires no parameters. ```typescript const response = await listServersHandler({}, { client }); ``` -------------------------------- ### Login and Execute Handler Pattern Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Demonstrates the typical workflow of logging into the Discord client first, then using a handler function to execute a tool. Ensure you have the correct discord_token and client instance. ```typescript // 1. Login first const loginResp = await loginHandler( { token: "discord_token" }, { client } ); // 2. Use any tool const msgResp = await sendMessageHandler( { channelId: "...", message: "Hello" }, { client } ); ``` -------------------------------- ### Login with Token from Environment Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/login-and-authentication.md Logs in to Discord using the bot token from the environment variable DISCORD_TOKEN. Ensure the client object is available. ```typescript // Login with token from environment const response = await loginHandler({}, { client }); ``` -------------------------------- ### Get Discord Forum Tags Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/forum.md Retrieves all available tags for a specified forum channel. Ensure the client is logged in and the forum channel ID is valid. ```typescript const response = await getForumTagsHandler( { forumChannelId: '123456789012345678' }, { client } ); ``` -------------------------------- ### Get Forum Post Details Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/forum.md Retrieves details of a specific forum post, including its messages. Ensure the client is logged in and the thread ID is valid. ```typescript const response = await getForumPostHandler( { threadId: '123456789012345678' }, { client } ); ``` -------------------------------- ### Configure MCP Server Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md Initializes the MCP server with its name, version, and capabilities. The capabilities object can declare support for various features like tools. ```typescript const server = new Server( { name: "MCP-Discord", version: "1.0.0" }, { capabilities: { tools: {} } } ); ``` -------------------------------- ### Run MCP-Discord with Docker Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Instructions for running MCP-Discord using Docker. This includes pulling the latest image, running the HTTP server on a specified port, and overriding the listening port if necessary. The Discord token is provided via an environment variable. ```bash # Pull the latest image docker pull barryy625/mcp-discord:latest # Run HTTP server on port 8080 docker run -e DISCORD_TOKEN=your_discord_bot_token -p 8080:8080 barryy625/mcp-discord:latest # Override the listening port if needed docker run -e DISCORD_TOKEN=your_discord_bot_token -p 3000:3000 barryy625/mcp-discord:latest --transport http --port 3000 ``` -------------------------------- ### MCPTransport Interface Definition Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Defines the standard interface for transport layers in MCP-Discord. Any custom transport implementation must adhere to this interface, providing start and stop methods. ```typescript interface MCPTransport { start(server: Server): Promise; stop(): Promise; } ``` -------------------------------- ### Login and Authentication Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Documentation for login and authentication operations. ```APIDOC ## Login and Authentication ### Description Provides methods for authenticating with Discord. ### Function Signature (Details to be provided in the specific API reference document) ### Parameters (Details to be provided in the specific API reference document) ### Return Type (Details to be provided in the specific API reference document) ### Error Conditions (Details to be provided in the specific API reference document) ### Usage Examples (Details to be provided in the specific API reference document) ``` -------------------------------- ### Tool Execution Flow Diagram Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Illustrates the sequence of operations from an MCP Client request to the Discord API and back. ```text MCP Client ↓ CallToolRequest → DiscordMCPServer ↓ Match tool name → Route to appropriate handler (login, send, etc.) ↓ Validate arguments → Schema.parse(args) ↓ Check client state → client.isReady() ↓ Execute Discord operation → client.channels.fetch(), etc. ↓ Format response → ToolResponse object ↓ Return to MCP Client ``` -------------------------------- ### Servers & Members Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Documentation for server queries and member management. ```APIDOC ## Servers & Members ### Description Provides methods for querying server information and managing members. ### Function Signature (Details to be provided in the specific API reference document) ### Parameters (Details to be provided in the specific API reference document) ### Return Type (Details to be provided in the specific API reference document) ### Error Conditions (Details to be provided in the specific API reference document) ### Usage Examples (Details to be provided in the specific API reference document) ``` -------------------------------- ### Self-Host MCP Discord HTTP Server (PowerShell) Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Launch the mcp-discord streamable HTTP server using PowerShell on Windows. Set the DISCORD_TOKEN environment variable before running the Node.js command. ```powershell $env:DISCORD_TOKEN="your_discord_bot_token" node build/app.js --transport http --port 3000 ``` -------------------------------- ### List Members - First Page Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/servers-and-members.md Fetches the first page of members for a given Discord server, specifying the maximum number of members to retrieve. Ensure the 'client' object is properly initialized. ```typescript const response = await listMembersHandler( { guildId: '123456789012345678', limit: 100 }, { client } ); ``` -------------------------------- ### Run MCP Discord Bot with Docker Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Deploy the MCP Discord Bot using Docker. Ensure you set the DISCORD_TOKEN environment variable and map the necessary port. ```bash docker run -e DISCORD_TOKEN=your_token \ -p 8080:8080 \ barryy625/mcp-discord:latest ``` -------------------------------- ### Usage Example for readMessagesHandler with Snowflake or Date Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/types.md Demonstrates how to use the readMessagesHandler function with either a Discord snowflake ID or an ISO 8601 date string for the 'after' parameter. Both inputs are handled equivalently. ```typescript // Both of these are equivalent: await readMessagesHandler({ channelId: '123456789012345678', after: '987654321098765432' // snowflake ID }, context); await readMessagesHandler({ channelId: '123456789012345678', after: '2025-03-01T00:00:00Z' // ISO 8601 date }, context); ``` -------------------------------- ### Login and Authentication Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Handles user login and authentication processes. ```APIDOC ## discord_login ### Description Logs in to Discord using provided credentials. ### Method POST ### Endpoint /auth/login ### Parameters #### Request Body - **username** (string) - Required - The username for login. - **password** (string) - Required - The password for login. ### Request Example { "username": "user123", "password": "securepassword" } ### Response #### Success Response (200) - **token** (string) - The authentication token. #### Response Example { "token": "your_auth_token_here" } ``` -------------------------------- ### Administrator Permission OAuth2 URL Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md An example OAuth2 authorization URL that grants the bot administrator permissions (permission value 8) in a Discord server. Replace YOUR_CLIENT_ID with your bot's actual Client ID. ```url https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=8 ``` -------------------------------- ### Minimum Required Permissions OAuth2 URL Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/configuration.md An example OAuth2 authorization URL that grants the bot the minimum required permissions (value 52076489808) for essential functionality. Replace YOUR_CLIENT_ID with your bot's actual Client ID. ```url https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=52076489808 ``` -------------------------------- ### Generic Tool Handler Pattern Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Demonstrates the standard pattern for implementing tool handlers in MCP-Discord. This includes argument validation, checking client readiness, performing Discord operations, and handling errors. ```typescript export async function handlerName( args: unknown, context: ToolContext ): Promise { // 1. Validate arguments const { field1, field2 } = SomeSchema.parse(args); try { // 2. Check client ready state if (!context.client.isReady()) { return { content: [{type: "text", text: "Not logged in."}], isError: true }; } // 3. Perform Discord operation const result = await context.client.something(); // 4. Return success response return { content: [{type: "text", text: "Success!"}] }; } catch (error) { // 5. Handle errors return handleDiscordError(error); } } ``` -------------------------------- ### Get Discord Member Information Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/servers-and-members.md Fetches detailed information about a specific member within a Discord server. Requires the server (guild) ID and the user ID. Ensure the client is logged in and the bot is a member of the specified guild. ```typescript const response = await getMemberHandler( { guildId: '123456789012345678', userId: '111222333444555666' }, { client } ); ``` -------------------------------- ### Run MCP Discord via Docker Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Deploy mcp-discord using Docker, exposing it as a streamable HTTP server. Map the container's port to the host and pass the Discord token as an environment variable. ```bash docker run -e DISCORD_TOKEN=your_discord_bot_token -p 3000:3000 barryy625/mcp-discord:latest --transport http --port 3000 ``` -------------------------------- ### Get Discord Server Information Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/servers-and-members.md Retrieve detailed information about a specific Discord server using its ID. This includes server details, member count, channel information, and premium features. Ensure the client is logged in and the guild ID is valid. ```typescript const response = await getServerInfoHandler( { guildId: '123456789012345678' }, { client } ); ``` -------------------------------- ### Get Reaction Users Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/reactions.md Lists users who reacted to a message with a specific emoji. Use this when you need to retrieve a list of users who have engaged with a particular message using a certain emoji. The function handles emoji matching by unicode or custom name and defaults to fetching 100 users if no limit is specified. ```typescript const response = await getReactionUsersHandler( { channelId: '123456789012345678', messageId: '987654321098765432', emoji: '👍', limit: 50 }, { client } ); ``` -------------------------------- ### Initialize discord.js Client with Intents Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/types.md Initializes the discord.js client with necessary intents for accessing guild, message, and member data. Ensure these intents are enabled in the Discord Developer Portal. ```typescript const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers ] }); ``` -------------------------------- ### File Structure Overview Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md This snippet displays the directory structure of the MCP-Discord project, indicating the purpose of each markdown file and the organization of the API reference modules. ```tree output/ ├── README.md # Start here - overview and quick reference ├── INDEX.md # This file ├── types.md # Type definitions and schemas ├── configuration.md # Configuration, intents, permissions ├── errors.md # Error codes, handling, recovery ├── architecture.md # System design, components, data flow └── api-reference/ # Detailed API documentation ├── login-and-authentication.md # discord_login ├── messaging.md # discord_send, discord_edit_message, discord_delete_message, discord_read_messages ├── channels.md # Channel creation, editing, deletion, permissions ├── categories.md # Category management ├── forum.md # Forum channels, posts, tags ├── reactions.md # Message reactions ├── webhooks.md # Webhook operations ├── roles.md # Role and member management └── servers-and-members.md # Server info, member lists, message search ``` -------------------------------- ### Run MCP Discord with Streamable HTTP Transport Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Launch mcp-discord as a streamable HTTP server, enabling stateless operation. Specify the transport mode and port number. ```bash node build/app.js --transport http --port 3000 --config "your_discord_bot_token" ``` -------------------------------- ### Configure MCP Discord for Claude/Cursor (Stdio) Source: https://github.com/barryyip0625/mcp-discord/blob/main/README.md Integrate mcp-discord with Claude Desktop or Cursor by configuring the MCP client to use the stdio transport. This JSON defines the command, arguments, and environment variables needed. ```json { "mcpServers": { "discord": { "command": "node", "args": [ "path/to/mcp-discord/build/index.js" ], "env": { "DISCORD_TOKEN": "your_discord_bot_token" } } } } ``` -------------------------------- ### Webhooks Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Documentation for webhook operations. ```APIDOC ## Webhooks ### Description Provides functionality for interacting with Discord webhooks. ### Function Signature (Details to be provided in the specific API reference document) ### Parameters (Details to be provided in the specific API reference document) ### Return Type (Details to be provided in the specific API reference document) ### Error Conditions (Details to be provided in the specific API reference document) ### Usage Examples (Details to be provided in the specific API reference document) ``` -------------------------------- ### Forum Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Documentation for forum posts and tags. ```APIDOC ## Forum ### Description Manages forum posts and associated tags. ### Function Signature (Details to be provided in the specific API reference document) ### Parameters (Details to be provided in the specific API reference document) ### Return Type (Details to be provided in the specific API reference document) ### Error Conditions (Details to be provided in the specific API reference document) ### Usage Examples (Details to be provided in the specific API reference document) ``` -------------------------------- ### discord_login Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/login-and-authentication.md Logs in to Discord using a bot token. The bot will authenticate and become ready to execute tool commands. ```APIDOC ## discord_login ### Description Logs in to Discord using a bot token. The bot will authenticate and become ready to execute tool commands. ### Method `discord_login` (TypeScript function) ### Parameters #### Arguments - **token** (string) - Optional - The Discord bot token to authenticate with. If omitted, uses the token from the environment variable `DISCORD_TOKEN` or previously configured token. ### Return Type `ToolResponse` — Contains message confirming successful login or error details. ### Throws - **Authentication error**: Invalid or malformed token provided - **Privileged intent error**: Required intents (Message Content, Server Members, Presence) not enabled in Discord Developer Portal - **Timeout error**: Client ready event does not fire within 30 seconds ### Example Usage ```typescript // Login with token from environment const response = await loginHandler({}, { client }); // Login with explicit token const response = await loginHandler( { token: 'YOUR_BOT_TOKEN' }, { client } ); ``` ``` -------------------------------- ### Run MCP Discord Bot Directly Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/README.md Execute the MCP Discord Bot directly using npx, providing your Discord bot token as a configuration argument. ```bash npx mcp-discord --config YOUR_DISCORD_TOKEN ``` -------------------------------- ### discord_create_webhook Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/webhooks.md Creates a new webhook for a Discord channel, returning its ID and token for future use. ```APIDOC ## discord_create_webhook ### Description Creates a new webhook for a Discord channel. The response includes the webhook ID and token, which are necessary for sending messages via the webhook. ### Signature ```typescript discord_create_webhook(args: { channelId: string; name: string; avatar?: string; reason?: string; }): Promise ``` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **channelId** (string) - Required - The ID of the channel to create the webhook in. * **name** (string) - Required - The name to assign to the webhook. * **avatar** (string) - Optional - Optional avatar URL or data for the webhook. * **reason** (string) - Optional - Optional reason for creation (shown in audit logs). ### Request Example ```json { "channelId": "123456789012345678", "name": "Integration Bot", "avatar": "https://example.com/avatar.png", "reason": "External service integration" } ``` ### Response #### Success Response (200) * **ToolResponse** - Success message includes the webhook ID and token. #### Response Example ```json { "webhookId": "12345678901234567890", "token": "aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789" } ``` ### Throws * **Not logged in**: Client is not ready or authenticated. * **Channel not found**: Channel ID does not exist or is not text-based. * **Channel type unsupported**: Channel type does not support webhooks. ``` -------------------------------- ### discord_create_forum_post Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/forum.md Creates a new forum post in a specified forum channel. Requires the forum channel ID, title, and content. Optionally accepts an array of tags. ```APIDOC ## discord_create_forum_post ### Description Creates a new forum post in a specified forum channel. ### Method `discord_create_forum_post` ### Parameters #### Path Parameters - **forumChannelId** (string) - Required - The ID of the forum channel where the post will be created - **title** (string) - Required - The title of the forum post - **content** (string) - Required - The body content of the forum post - **tags** (string[]) - Optional - Array of tag names to apply to the post (must exist in forum) ### Return Type `ToolResponse` — Success message with the created post title and thread ID. ### Throws - **Not logged in**: Client is not ready or authenticated - **Channel not found**: Channel ID does not exist or is not a forum - **Invalid tag**: Specified tag name does not exist in the forum's available tags ### Example Usage ```typescript const response = await createForumPostHandler( { forumChannelId: '123456789012345678', title: 'How to get started?', content: 'I am new to the server and need help getting started.', tags: ['Help', 'Beginner'] }, { client } ); ``` ``` -------------------------------- ### Reactions Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/INDEX.md Documentation for message reaction operations. ```APIDOC ## Reactions ### Description Handles operations related to adding and removing reactions from messages. ### Function Signature (Details to be provided in the specific API reference document) ### Parameters (Details to be provided in the specific API reference document) ### Return Type (Details to be provided in the specific API reference document) ### Error Conditions (Details to be provided in the specific API reference document) ### Usage Examples (Details to be provided in the specific API reference document) ``` -------------------------------- ### List Members - Next Page Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/servers-and-members.md Fetches the next page of members for a Discord server using pagination. The 'after' parameter should be set to the ID of the last user from the previous call. Ensure the 'client' object is properly initialized. ```typescript const response = await listMembersHandler( { guildId: '123456789012345678', limit: 100, after: 'last_user_id_from_previous_call' }, { client } ); ``` -------------------------------- ### Login with Explicit Token Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/login-and-authentication.md Logs in to Discord by providing the bot token directly in the arguments. Replace 'YOUR_BOT_TOKEN' with your actual token. ```typescript // Login with explicit token const response = await loginHandler( { token: 'YOUR_BOT_TOKEN' }, { client } ); ``` -------------------------------- ### Check Discord Client Ready State Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/architecture.md Perform an early check to ensure the Discord client is logged in and ready before executing operations. Returns an error if the client is not ready. ```typescript if (!context.client.isReady()) { return { content: [{ type: "text", text: "Discord client not logged in." }], isError: true }; } ``` -------------------------------- ### discord_get_forum_channels Source: https://github.com/barryyip0625/mcp-discord/blob/main/_autodocs/api-reference/forum.md Lists all forum channels in a specified Discord server. Requires the guild ID as input and returns a list of forum channel objects. ```APIDOC ## discord_get_forum_channels ### Description Lists all forum channels in a specified Discord server. ### Method `discord_get_forum_channels` ### Parameters #### Path Parameters - **guildId** (string) - Required - The ID of the server (guild) to list forum channels from ### Return Type `ToolResponse` — JSON array containing forum channel objects with id, name, and topic. ### Throws - **Not logged in**: Client is not ready or authenticated - **Guild not found**: Guild ID does not exist or bot is not a member ### Example Usage ```typescript const response = await getForumChannelsHandler( { guildId: '123456789012345678' }, { client } ); // Returns: [{ id: "...", name: "suggestions", topic: "..." }] ``` ```