Discord MCP Server

repository·main·Indexed 42 days ago

https://github.com/v-3/discordmcp

A Model Context Protocol (MCP) server version 1.0.0 that enables LLMs, such as Claude for Desktop, to interact with Discord channels. It provides tools to send and read messages via the Discord API, requiring a bot token with Guilds, GuildMessages, and MessageContent intents.

Tokens
1.4K
Snippets
7
Records
7
Agent score
4%

What's inside Discord MCP

  1. Install and Setup the Discord MCP Server

    main

    To use the Discord MCP server, you must first clone the repository, install dependencies, and provide a Discord bot token.

    Prerequisites

    • Node.js 16.x or higher
    • A Discord bot token
    • The bot must have the following permissions in your Discord server:
      • Read Messages/View Channels
      • Send Messages
      • Read Message History

    Installation Steps

    1. Clone the repository:
      git clone https://github.com/yourusername/discordmcp.git
      cd discordmcp
    2. Install dependencies:
      npm install
    3. Create a .env file in the root directory and add your token:
      DISCORD_TOKEN=your_discord_bot_token_here
    4. Build the server:
      npm run build
    git clone https://github.com/yourusername/discordmcp.git
    cd discordmcp
    npm install
    # Create .env with DISCORD_TOKEN
    npm run build
  2. Configure Discord MCP for Claude for Desktop

    main

    To integrate the Discord MCP server with Claude for Desktop, add the server configuration to your claude_desktop_config.json file.

    Config File Locations:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json

    After updating the configuration, restart Claude for Desktop.

    {
      "mcpServers": {
        "discord": {
          "command": "node",
          "args": ["path/to/discordmcp/build/index.js"],
          "env": {
            "DISCORD_TOKEN": "your_discord_bot_token_here"
          }
        }
      }
    }
  3. Configure the Discord MCP Server environment

    main

    To run the Discord MCP server, you must provide a valid Discord Bot Token via an environment variable.

    Required Environment Variables

    • DISCORD_TOKEN: The token for your Discord bot. This token must have the necessary intents enabled in the Discord Developer Portal (specifically Guilds, GuildMessages, and MessageContent).

    Setup Note

    The server uses dotenv to load variables, so you can also define this in a .env file in the project root.

    export DISCORD_TOKEN=your_token_here
  4. Use the read-messages tool

    main

    The read-messages tool allows an LLM to fetch recent messages from a Discord channel.

    Parameters:

    • channel (required): Channel name (e.g., "general") or ID.
    • limit (optional): Number of messages to fetch. Default is 50, maximum is 100.
    • server (optional): Server name or ID (required if the bot is in multiple servers).
    {
      "channel": "general",
      "limit": 10
    }
  5. Use the send-message tool

    main

    The send-message tool allows an LLM to send a message to a specific Discord channel. You can specify a channel by name or ID. If the bot is present in multiple servers, providing the server parameter (name or ID) is required to disambiguate.

    {
      "channel": "general",
      "message": "Hello from MCP!"
    }
  6. Reference: Discord MCP Tools

    main

    The following tools are exposed by the discord MCP server.

    [
      {
        "name": "send-message",
        "description": "Send a message to a Discord channel",
        "inputSchema": {
          "type": "object",
          "properties": {
            "server": { "type": "string", "description": "Server name or ID (optional if bot is only in one server)" },
            "channel": { "type": "string", "description": "Channel name (e.g., \"general\") or ID" },
            "message": { "type": "string", "description": "Message content to send" }
          },
          "required": ["channel", "message"]
        }
      },
      {
        "name": "read-messages",
        "description": "Read recent messages from a Discord channel",
        "inputSchema": {
          "type": "object",
          "properties": {
            "server": { "type": "string", "description": "Server name or ID (optional if bot is only in one server)" },
            "channel": { "type": "string", "description": "Channel name (e.g., \"general\") or ID" },
            "limit": { "type": "number", "description": "Number of messages to fetch (max 100)", "default": 50 }
          },
          "required": ["channel"]
        }
      }
    ]