- Home
- MCP servers
- Discord
Discord
- python
0
GitHub Stars
python
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You are running a secure Discord MCP server that uses JWT Bearer Token authentication to expose Discord integration tools. It lets you perform actions like sending messages, fetching channel info, retrieving recent messages, searching messages, and moderating content, all while protecting Discord tokens and keeping an auditable trail of tool usage.
How to use
To use this MCP server, first obtain a JWT Bearer token that embeds your Discord token in its claims. Include this token in every request as an Authorization header using the Bearer scheme. With a valid token, you can invoke any available tool by name and provide the required parameters in your client. The server handles authenticating the token, establishing a temporary Discord connection, executing the requested action, and then cleaning up the connection.
Available tools include sending messages to channels, fetching recent messages, obtaining channel metadata, searching messages by keywords, and deleting specific messages. You will reference tools by their names in your client, supply the necessary parameters (such as channel identifiers and message content), and rely on the server to perform the operation and return results.
Remember that tokens are embedded in the JWT claims and never exposed in request parameters. You will see an audit trail that records who performed which action, when, and with which parameters. If anything fails, review the audit logs for clues and verify that your JWT token is valid and not expired.
How to install
Prerequisites you must have installed before running the server:
-
Python 3.8 or newer
-
A Discord bot token with sufficient permissions
-
A shell environment and a virtual environment tool (recommended)
Follow these concrete steps to install and run the MCP server:
# 1. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# 2. Install dependencies
pip install discord.py fastapi fastmcp uvicorn python-dotenv PyJWT
# 3. Set the Discord bot token as an environment variable (optional)
# Create a .env file with the following line if you prefer environment variables
# DISCORD_TOKEN=your_discord_bot_token_here
# 4. Run the server
python app.py
# The server will start on http://localhost:8000
Additional sections
Configuration and security considerations are important for reliable operation.
Environment variables you should be aware of include the Discord bot token, which is provided to the server to perform actions on your behalf. Tokens are stored securely and used only for the duration of a tool call.
Troubleshooting key points include checking that the server is running on the expected port, ensuring the Discord bot has the required permissions in the target channels, and renewing tokens if they expire.
Notes on usage and behavior
The server creates a temporary Discord bot connection for each operation and closes it after the action completes. This reduces exposure and ensures that no long-lived bot instances persist beyond what is needed for a single task.
Available tools
send_message
Send messages to Discord channels by specifying the target channel and the content to post.
get_messages
Fetch recent messages from a specified Discord channel, with optional filtering like limit or time window.
get_channel_info
Retrieve channel metadata and information such as name, id, topic, and permissions.
search_messages
Search for messages containing given keywords within a channel, with optional result limits.
moderate_content
Delete specific messages from a channel based on given criteria or identifiers.