V3

v-3/discordmcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

242 stars 106 forks 质量 58 趋势 19

v-3/discordmcp 是从 https://github.com/v-3/discordmcp. 导入的 MCP 服务器候选服务器

概览

v-3/discordmcp 是从 https://github.com/v-3/discordmcp. 导入的 MCP 服务器候选服务器

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,使LLM能够与Discord频道交互,通过Discord的API发送和读取消息。通过该服务器,像Claude这样的LLM可以直接与Discord频道交互,同时保持用户控制和安全。

特色

  • 向Discord频道发送消息
  • 阅读频道的最新消息
  • 自动服务器和通道发现
  • 支持频道名称和ID
  • 正确的错误处理和验证

先修条件

  • Node.js 16.x 或更高
  • 一个Discord机器人令牌
  • 必须在获得适当权限后邀请机器人加入您的服务器:
  • 阅读消息/查看频道
  • 发送消息
  • 阅读消息历史

布置

  1. 克隆此仓库:

  2. 安装依赖:

  3. 在根目录中用你的 Discord 机器人令牌创建一个 .env 文件:

  4. 搭建服务器:

桌面版 Claude 的使用

  1. 打开你的Claude for Desktop配置文件:
  • macOS:~/Library/Application Support/Claude/claude_desktop_config.json
  • 窗口:%APPDATA%\Claude\claude_desktop_config.json
  1. 添加Discord MCP服务器配置:

  2. 重启桌面版Claude

可用工具

发送消息

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 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
}

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?”
在 GitHub 查看完整 README

安装

npx @modelcontextprotocol/inspector node build/index.js
新手?先看 mcpskill.org 教程 →

配置

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