Discord MCP Server

Discord MCP Server

Enables LLMs to send and read messages in Discord channels, manage servers, channels, and roles via Discord's API.

Category
访问服务器

README

Discord MCP Server

A Model Context Protocol (MCP) server that enables LLMs to interact with Discord channels, allowing them to send and read messages through Discord's API. Using this server, LLMs like Claude can directly interact with Discord channels while maintaining user control and security.

Features

  • Send messages to Discord channels
  • Read recent messages from channels
  • Automatic server and channel discovery
  • Support for both channel names and IDs
  • Proper error handling and validation

Prerequisites

  • Node.js 16.x or higher
  • A Discord bot token
  • The bot must be invited to your server with proper permissions:
    • Read Messages/View Channels
    • Send Messages
    • Read Message History

Setup

  1. Clone this repository:
git clone https://github.com/yourusername/discordmcp.git
cd discordmcp
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory with your Discord bot token:
DISCORD_TOKEN=your_discord_bot_token_here
  1. Build the server:
npm run build

Usage with Claude for Desktop

  1. Open your Claude for Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the Discord MCP server configuration:

{
  "mcpServers": {
    "discord": {
      "command": "node",
      "args": ["path/to/discordmcp/build/index.js"],
      "env": {
        "DISCORD_TOKEN": "your_discord_bot_token_here"
      }
    }
  }
}
  1. Restart Claude for Desktop

Available Tools

send-message

Sends a message to a specified Discord channel.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • channel: Channel name (e.g., "general") or ID
  • message: Message content to send

Example:

{
  "channel": "general",
  "message": "Hello from MCP!"
}

read-messages

Reads recent messages from a specified Discord channel.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • channel: Channel name (e.g., "general") or ID
  • limit (optional): Number of messages to fetch (default: 50, max: 100)

Example:

{
  "channel": "general",
  "limit": 10
}

list-servers

Lists all servers (guilds) the bot is currently connected to.

Parameters:

  • None

Example:

{}

list-channels

Lists all text channels in a specific server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)

Example:

{
  "server": "My Cool Server"
}

create-channel

Creates a new text channel in a specific server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • channelName: Name for the new text channel

Example:

{
  "server": "My Cool Server",
  "channelName": "new-project-discussion"
}

read-multiple-channels

Reads recent messages from multiple text channels in a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • channels (optional): List of channel names or IDs (defaults to all text channels if omitted)
  • limitPerChannel (optional): Max messages per channel (default: 10, max: 50)

Example (read from specific channels):

{
  "server": "My Cool Server",
  "channels": ["general", "announcements"],
  "limitPerChannel": 5
}

Example (read from all channels):

{
  "server": "My Cool Server",
  "limitPerChannel": 3
}

list-roles

Lists all roles in a specific server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)

Example:

{
  "server": "My Cool Server"
}

assign-role

Assigns a role to a user in a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • user: User name#discriminator, user ID, or user mention
  • role: Role name or ID

Example:

{
  "server": "My Cool Server",
  "user": "SomeUser#1234",
  "role": "Moderator"
}

remove-role

Removes a role from a user in a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • user: User name#discriminator, user ID, or user mention
  • role: Role name or ID

Example:

{
  "server": "My Cool Server",
  "user": "SomeUser#1234",
  "role": "Moderator"
}

create-role

Creates a new role in a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • roleName: Name for the new role
  • color (optional): Hex color code (e.g., "#FF0000")
  • permissions (optional): List of permission names (e.g., ["SendMessages", "ManageMessages"])
  • mentionable (optional): Boolean, whether the role is mentionable (default: false)

Example:

{
  "server": "My Cool Server",
  "roleName": "Team Alpha",
  "color": "#3498db",
  "mentionable": true
}

delete-role

Deletes a role from a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • role: Role name or ID to delete

Example:

{
  "server": "My Cool Server",
  "role": "Old Role Name"
}

update-role

Updates an existing role in a server.

Parameters:

  • server (optional): Server name or ID (required if bot is in multiple servers)
  • role: Role name or ID to update
  • newName (optional): New name for the role
  • newColor (optional): New hex color code
  • newPermissions (optional): New list of permission names (replaces existing)
  • newMentionable (optional): New mentionable status

Example:

{
  "server": "My Cool Server",
  "role": "Team Alpha",
  "newName": "Team Bravo",
  "newColor": "#e67e22"
}

Development

  1. Install development dependencies:
npm install --save-dev typescript @types/node
  1. Start the server in development mode:
npm run dev

Testing

You can test the server using the MCP Inspector:

npx @modelcontextprotocol/inspector node build/index.js

Examples

Here are some example interactions you can try with Claude after setting up the Discord MCP server:

  1. "Can you read the last 5 messages from the general channel?"
  2. "Please send a message to the announcements channel saying 'Meeting starts in 10 minutes'"
  3. "What were the most recent messages in the development channel about the latest release?"

Claude will use the appropriate tools to interact with Discord while asking for your approval before sending any messages.

Security Considerations

  • The bot requires proper Discord permissions to function
  • All message sending operations require explicit user approval
  • Environment variables should be properly secured
  • Token should never be committed to version control
  • Channel access is limited to channels the bot has been given access to

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

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

Support

If you encounter any issues or have questions:

  1. Check the GitHub Issues section
  2. Consult the MCP documentation at https://modelcontextprotocol.io
  3. Open a new issue with detailed reproduction steps

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选