Skip to main content

Discord MCP Server

A Model Context Protocol (MCP) server that provides Discord integration, allowing AI assistants like Claude to retrieve messages and attachments from Discord channels.

PyPI version Python Support License: MIT

⚠️ Python Version Compatibility: This package requires Python 3.8-3.12. Python 3.13 is not supported due to discord.py compatibility issues.

Features

  • 🔍 Retrieve recent messages from Discord channels
  • 📅 Time-based message queries (get messages from last N hours/days)
  • 📎 Find messages with attachments (images, files, etc.)
  • 🔎 Search messages by content with flexible text matching
  • ℹ️ Get channel information and metadata
  • 🔒 Secure authentication using Discord bot tokens
  • 🚀 Easy installation via uvx or pip

Quick Start

Installation

uvx datagen-discord-mcp-server

Option 2: Using pip

pip install datagen-discord-mcp-server

Discord Bot Setup

  1. Go to the Discord Developer Portal
  2. Create a new application and bot
  3. Copy the bot token
  4. Invite the bot to your server with these permissions:
    • Read Messages
    • Read Message History
    • View Channels

Configuration

For Claude Desktop

Add to your Claude Desktop MCP settings (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "discord": {
      "command": "uvx",
      "args": ["datagen-discord-mcp-server"],
      "env": {
        "DISCORD_TOKEN": "your_bot_token_here"
      }
    }
  }
}

For other MCP clients

{
  "mcpServers": {
    "discord": {
      "command": "datagen-discord-mcp-server",
      "env": {
        "DISCORD_TOKEN": "your_bot_token_here"
      }
    }
  }
}

Usage

Once configured, you can use natural language to query Discord messages through your MCP client:

  • "Get the last 10 messages from channel 123456789"
  • "Show me messages with attachments from yesterday"
  • "Search for messages containing 'bug report' from the past week"
  • "What's the info for channel 123456789?"

Available Tools

get_recent_messages

Retrieve the most recent messages from a channel.

  • Parameters: channel_id (string), limit (int, max 100)
  • Returns: List of formatted message objects

get_messages_by_date

Get messages from a specific time period.

  • Parameters: channel_id (string), hours_ago (int), limit (int, max 500)
  • Returns: List of messages within the time range

get_messages_with_attachments

Find messages containing attachments.

  • Parameters: channel_id (string), limit (int, max 200), hours_ago (optional)
  • Returns: List of messages with attachments

search_messages

Search for messages containing specific text.

  • Parameters: channel_id (string), query (string), limit (int, max 200), hours_ago (optional)
  • Returns: List of matching messages

get_channel_info

Get channel information and metadata.

  • Parameters: channel_id (string)
  • Returns: Channel information object

Message Format

Each message is returned with the following structure:

{
  "id": "message_id",
  "content": "message text",
  "author": {
    "id": "user_id", 
    "name": "username",
    "display_name": "display name",
    "bot": false
  },
  "channel": {
    "id": "channel_id",
    "name": "channel_name"
  },
  "timestamp": "2025-01-01T12:00:00+00:00",
  "edited_timestamp": null,
  "attachments": [
    {
      "filename": "image.png",
      "url": "https://cdn.discordapp.com/...",
      "size": 1024,
      "content_type": "image/png"
    }
  ],
  "embeds": 0,
  "reactions": 0
}

Development

Local Development

# Clone the repository
git clone https://github.com/yourusername/discord-mcp-server.git
cd discord-mcp-server

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run the server
datagen-discord-mcp-server --debug

Building and Publishing

# Build the package
python -m build

# Upload to PyPI
twine upload dist/*

Getting Channel IDs

To get Discord channel IDs:

  1. Enable Developer Mode in Discord (User Settings → Advanced → Developer Mode)
  2. Right-click on the channel you want
  3. Select "Copy Channel ID"

Troubleshooting

Common Issues

"Channel not found" errors:

  • Verify the channel ID is correct
  • Ensure your bot has access to the channel
  • Check that the bot has "Read Message History" permission

"Authentication failed":

  • Verify your Discord bot token is correct
  • Make sure the token is set in the environment variable
  • Ensure the bot is added to the Discord server

Import or installation errors:

  • Python 3.13 compatibility: Use Python 3.8-3.12 instead
    # Force specific Python version with uvx
    uvx --python python3.11 datagen-discord-mcp-server
    
  • Reinstall with pip install --upgrade datagen-discord-mcp-server

Debug Mode

Run with debug logging to troubleshoot issues:

datagen-discord-mcp-server --debug

# Or with specific Python version
uvx --python python3.11 datagen-discord-mcp-server -- --debug

Python Version Issues

If you encounter issues with Python 3.13, the package will show an error message with instructions. The package is designed to work with Python 3.8-3.12 only.

Common error symptoms:

  • BrokenPipeError in Claude Desktop logs
  • JSON parsing errors
  • MCP server connection failures

Solution:

# Check your Python version
python --version

# Install with specific Python version
uvx --python python3.11 datagen-discord-mcp-server

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Metadata

Release files for datagen-discord-mcp-server 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datagen-discord-mcp-server 1.0.1
File Size Uploaded Provenance
datagen_discord_mcp_server-1.0.1.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for datagen-discord-mcp-server 1.0.1
File Interpreter ABI Platform
datagen_discord_mcp_server-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / datagen_discord_mcp_server-1.0.1.tar.gz

Download URL datagen_discord_mcp_server-1.0.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7adfcaafc40d44e7ddd99ad46fc52f35a3f1098b1d4a5b4813b127fac9dea87a
BLAKE2b-256 checksum
How to use checksums
e85cfa9142c91f30343838fa9dd98b8b6f0c226fa6b7c1a54f5296ca0e51d714
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / datagen_discord_mcp_server-1.0.1-py3-none-any.whl

Download URL datagen_discord_mcp_server-1.0.1-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d45c001334dec7ef84c2c8dd2a0d44ead9e30afc70a607fd3879901b2343486
BLAKE2b-256 checksum
How to use checksums
fc7b6b41b4cbabed5a48872e5f6dd799419e9900703fc78f56acc22c09c21cae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Security for datagen-discord-mcp-server 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page