Skip to main content
Glama
discord-mcp

discord-mcp

README.md
# discord-mcp

A small, dependency-light [MCP](https://modelcontextprotocol.io) server that lets AI agents (Claude Code and other MCP clients) **post and read in Discord as your own bots**. Built for running a "virtual team" where each agent has its own Discord identity.

- **Zero dependencies.** Speaks the MCP stdio protocol and Discord's REST API with the Python standard library only, so it runs on any Python 3.8+, including macOS's built-in `python3`. Your token stays on your machine.
- **Many bots, one server.** Every tool takes a `bot` name and uses `<BOT>_DISCORD_TOKEN`, so Scout, Analyst and Editor each post under their own name and avatar.
- **Three tools:** `list_channels`, `post_message`, `read_messages`.

## Setup

1. Create a bot per agent in the [Discord Developer Portal](https://discord.com/developers/applications): New Application → Bot → Reset Token (copy it) → turn on **Message Content Intent**.
2. Invite it: OAuth2 → URL Generator → scope `bot` → permissions View Channels, Send Messages, Send Messages in Threads, Read Message History → open the URL and pick your server.
3. Nothing to install: just clone the repo.
4. In the folder your agents run from, create `.env` (see `.env.example`) and optionally `channels.json` (see `channels.example.json`) to name channels.

## Use with Claude Code

Add to your project's `.mcp.json`:

```json
{
  "mcpServers": {
    "discord": {
      "command": "python3",
      "args": ["/path/to/discord-mcp/server.py"],
      "env": {
        "DISCORD_ENV_FILE": "/path/to/your/project/.env",
        "DISCORD_CHANNELS_FILE": "/path/to/your/project/channels.json",
        "DISCORD_DEFAULT_BOT": "scout"
      }
    }
  }
}
```

Or register it for all your projects:

```bash
claude mcp add discord --scope user \
  -e DISCORD_ENV_FILE=/path/to/your/project/.env \
  -e DISCORD_CHANNELS_FILE=/path/to/your/project/channels.json \
  -- python3 /path/to/discord-mcp/server.py
```

Then in Claude Code, run `/mcp` to check it is connected, and ask: *"Post 'hello' to newsroom as scout."*

## Configuration

| Variable | Default | Meaning |
|---|---|---|
| `<BOT>_DISCORD_TOKEN` | — | Token for bot `<bot>` (environment or `.env`) |
| `DISCORD_ENV_FILE` | `./.env`, then `.env` next to `server.py` | Where to read tokens from |
| `DISCORD_CHANNELS_FILE` | `./channels.json`, then next to `server.py` | Channel aliases, e.g. `{"channels": {"newsroom": "123..."}}` |
| `DISCORD_DEFAULT_BOT` | `bot` | Bot used when a tool call does not name one |

## Notes

- The bots post and read through the REST API; they do not stay online or react instantly. Run your agents on a schedule (or poll) to reply.
- Keep a human approval step before agents message real people.

## License

MIT