Discord (Full API) MCP server

Integrates with Discord's API to enable flexible bot development and management through simplified REST and slash command interfaces.
Back to servers
Setup instructions
Provider
hanweg
Release date
Jan 06, 2025
Language
Python
Stats
7 stars

The Discord Raw API MCP Server provides a flexible tool for interacting with Discord's API through either REST API calls or slash command syntax. It acts as a bridge between your AI assistant and Discord, allowing you to perform various operations on your Discord server.

Installation Options

Installing via Smithery

For a quick automated installation with Claude Desktop:

npx -y @smithery/cli install @hanweg/mcp-discord-raw --client claude

Manual Installation

To install the server manually:

  1. Set up your Discord bot:

    • Create a new application at the Discord Developer Portal
    • Create a bot and copy the token
    • Enable these required privileged intents:
      • MESSAGE CONTENT INTENT
      • PRESENCE INTENT
      • SERVER MEMBERS INTENT
    • Invite the bot to your server using the OAuth2 URL Generator
  2. Clone and install the package:

    # Clone the repository
    git clone https://github.com/hanweg/mcp-discord-raw.git
    cd mcp-discord-raw
    
    # Create and activate virtual environment
    uv venv
    .venv\Scripts\activate
    
    # Install the package
    uv pip install -e .
    

    Note: If using Python 3.13+, you'll need to install the audioop library with: uv pip install audioop-lts

Configuration

Add this to your claude_desktop_config.json:

"discord-raw": {
  "command": "uv",
  "args": [
    "--directory", 
    "PATH/TO/mcp-discord-raw",
    "run",
    "discord-raw-mcp"
  ],
  "env": {
    "DISCORD_TOKEN": "YOUR-BOT-TOKEN"
  }
}

Be sure to replace PATH/TO/mcp-discord-raw with the actual path to your installation directory and YOUR-BOT-TOKEN with your Discord bot token.

Usage

You can interact with the Discord API in two ways:

REST API Style

This format follows Discord's official API structure:

{
    "method": "POST",
    "endpoint": "guilds/123456789/roles",
    "payload": {
        "name": "Bot Master",
        "permissions": "8",
        "color": 3447003,
        "mentionable": true
    }
}

Slash Command Style

This provides a more intuitive syntax for common operations:

{
    "method": "POST",
    "endpoint": "/role create name:Bot_Master color:blue permissions:8 mentionable:true guild_id:123456789"
}

Usage Examples

Creating a Role

{
    "method": "POST",
    "endpoint": "/role create name:Moderator color:red permissions:moderate_members guild_id:123456789"
}

Sending a Message

{
    "method": "POST",
    "endpoint": "channels/123456789/messages",
    "payload": {
        "content": "Hello from the API!"
    }
}

Getting Server Information

{
    "method": "GET",
    "endpoint": "guilds/123456789"
}

Creating Categories and Channels

// Create a category
{
    "method": "POST",
    "endpoint": "guilds/123456789/channels",
    "payload": {
        "name": "Category Name",
        "type": 4
    }
}

// Create a text channel in the category
{
    "method": "POST",
    "endpoint": "guilds/123456789/channels",
    "payload": {
        "name": "channel-name",
        "type": 0,
        "parent_id": "category_id",
        "topic": "Channel description"
    }
}

Assigning Roles to Users

{
    "method": "PUT",
    "endpoint": "guilds/123456789/members/987654321/roles/567890123",
    "payload": {}
}

Tips for Effective Use

  • Save IDs returned from creation requests to use in follow-up requests
  • Use Discord emoji format like :champagne_glass: in messages
  • Remember these channel types: 0 = text, 2 = voice, 4 = category, 13 = stage
  • Role colors are in decimal format (not hex)
  • Most modification endpoints use the PATCH method
  • Empty payloads should be {} not null

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "discord-raw" '{"command":"uv","args":["--directory","PATH/TO/mcp-discord-raw","run","discord-raw-mcp"],"env":{"DISCORD_TOKEN":"YOUR-BOT-TOKEN"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "discord-raw": {
            "command": "uv",
            "args": [
                "--directory",
                "PATH/TO/mcp-discord-raw",
                "run",
                "discord-raw-mcp"
            ],
            "env": {
                "DISCORD_TOKEN": "YOUR-BOT-TOKEN"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

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

2. Add this to your configuration file:

{
    "mcpServers": {
        "discord-raw": {
            "command": "uv",
            "args": [
                "--directory",
                "PATH/TO/mcp-discord-raw",
                "run",
                "discord-raw-mcp"
            ],
            "env": {
                "DISCORD_TOKEN": "YOUR-BOT-TOKEN"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later