MCP server by aaddrick
discord-mcp
An MCP (Model Context Protocol) server that gives Claude direct access to Discord — read messages, search conversations, list channels, and export data.
Features
- read_messages — Fetch messages from any channel, returned as markdown
- list_channels — List all channels in a server, with optional thread discovery
- search — Search messages across a server by content
Setup
1. Install dependencies
npm install
2. Get your Discord token
Open Discord in a browser, open DevTools (F12), go to the Console tab, and paste:
(webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()
3. Configure environment
echo "DISCORD_TOKEN=your_token_here" > .env
4. Build
npm run build
Usage
As an MCP server (with Claude)
Add to your Claude MCP config (.mcp.json or Claude Desktop settings):
{
"mcpServers": {
"discord": {
"command": "npx",
"args": ["tsx", "src/mcp/server.ts"],
"env": {
"DISCORD_TOKEN": "your_token_here"
}
}
}
}
Then Claude can use the tools directly in conversation:
- "Read the last 20 messages from #general"
- "Search the server for messages about deployments"
- "List all channels and active threads"
Development
npm run dev # Run with tsx (no build step)
npm run build # Compile TypeScript
npm start # Run compiled output
MCP Tools
| Tool | Description | Key Parameters |
|------|-------------|----------------|
| read_messages | Read messages from a channel | channel_id, limit?, before?, after? |
| list_channels | List channels in a server | guild_id, include_threads? |
| search | Search messages by content | guild_id, query, limit? |
Project Structure
src/
api/
client.ts # Discord API client
rate-limiter.ts # Per-route rate limiting
types.ts # Discord API type definitions
formatters/
markdown.ts # Message → markdown conversion
mcp/
server.ts # MCP entry point
tools/ # One file per MCP tool
config.ts # Environment config
poc/ # Original proof-of-concept script
Note
This uses a Discord user token (not a bot token). User tokens don't expire but are invalidated if you change your password or toggle 2FA.