@mahesvara/discord-mcpserver 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oratorian
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,466 @@
1
+ # Discord MCP Server
2
+
3
+ An MCP (Model Context Protocol) server that enables LLMs to control Discord servers via a bot token. This server provides comprehensive Discord management tools including sending messages, managing members, roles, channels, permissions, and more.
4
+
5
+ ## Features
6
+
7
+ ### Guild/Server Management
8
+ - `discord_list_guilds` - List all servers the bot has access to
9
+ - `discord_get_guild` - Get detailed info about a specific server
10
+
11
+ ### Channel Management
12
+ - `discord_list_channels` - List channels in a server (filter by type)
13
+ - `discord_get_channel` - Get channel details
14
+ - `discord_create_channel` - Create text/voice channels **and categories**
15
+ - `discord_edit_channel` - Edit channel name, topic, position, category, and more
16
+ - `discord_delete_channel` - Delete a channel or category
17
+
18
+ ### Permission Management
19
+ - `discord_set_channel_permissions` - Set permission overrides for roles/members on channels
20
+ - `discord_remove_channel_permissions` - Remove permission overrides
21
+ - `discord_get_channel_permissions` - View all permission overrides on a channel
22
+ - `discord_sync_channel_permissions` - Sync channel permissions with parent category
23
+
24
+ ### Message Operations
25
+ - `discord_send_message` - Send messages (with optional reply)
26
+ - `discord_get_messages` - Retrieve channel messages (with pagination)
27
+ - `discord_edit_message` - Edit bot's messages
28
+ - `discord_delete_message` - Delete messages
29
+ - `discord_add_reaction` - Add emoji reactions
30
+ - `discord_remove_reaction` - Remove bot's reactions
31
+ - `discord_pin_message` - Pin a message
32
+ - `discord_unpin_message` - Unpin a message
33
+ - `discord_get_pinned_messages` - Get all pinned messages
34
+
35
+ ### Member Management
36
+ - `discord_list_members` - List server members (with pagination)
37
+ - `discord_get_member` - Get member details
38
+ - `discord_kick_member` - Kick a member
39
+ - `discord_ban_member` - Ban a member (with message deletion option)
40
+ - `discord_unban_member` - Unban a user
41
+ - `discord_set_nickname` - Set/clear member nickname
42
+
43
+ ### Role Management
44
+ - `discord_list_roles` - List all server roles
45
+ - `discord_create_role` - Create a new role
46
+ - `discord_edit_role` - Edit role name, color, permissions, and settings
47
+ - `discord_delete_role` - Delete a role
48
+ - `discord_add_role` - Assign role to member
49
+ - `discord_remove_role` - Remove role from member
50
+ - `discord_set_role_positions` - Reorder role hierarchy
51
+
52
+ ### Server Administration
53
+ - `discord_edit_guild` - Edit server settings (name, verification level, system channels, etc.)
54
+ - `discord_timeout_member` - Timeout/mute a member (up to 28 days)
55
+ - `discord_list_bans` - List all banned users
56
+ - `discord_prune_members` - Remove inactive members (with dry-run option)
57
+ - `discord_get_audit_log` - View audit log entries
58
+
59
+ ### Emoji Management
60
+ - `discord_list_emojis` - List custom emojis
61
+ - `discord_create_emoji` - Create emoji from image URL
62
+ - `discord_delete_emoji` - Delete a custom emoji
63
+
64
+ ### Sticker Management
65
+ - `discord_list_stickers` - List custom stickers
66
+ - `discord_delete_sticker` - Delete a custom sticker
67
+
68
+ ### Invite Management
69
+ - `discord_list_invites` - List active invites
70
+ - `discord_create_invite` - Create channel invite
71
+ - `discord_delete_invite` - Delete an invite
72
+
73
+ ### Webhook Management
74
+ - `discord_list_webhooks` - List webhooks (guild or channel)
75
+ - `discord_create_webhook` - Create a webhook
76
+ - `discord_edit_webhook` - Edit webhook name or channel
77
+ - `discord_delete_webhook` - Delete a webhook
78
+
79
+ ### Scheduled Events
80
+ - `discord_list_events` - List scheduled events
81
+ - `discord_create_event` - Create a scheduled event (stage, voice, or external)
82
+ - `discord_delete_event` - Delete a scheduled event
83
+
84
+ ## Setup
85
+
86
+ ### 1. Create a Discord Bot
87
+
88
+ 1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)
89
+ 2. Click "New Application" and give it a name
90
+ 3. Go to the "Bot" section and click "Add Bot"
91
+ 4. Copy the bot token (keep this secret!)
92
+ 5. Enable these **Privileged Gateway Intents**:
93
+ - Server Members Intent
94
+ - Message Content Intent
95
+
96
+ ### 2. Invite the Bot to Your Server
97
+
98
+ 1. Go to OAuth2 → URL Generator
99
+ 2. Select scopes: `bot`, `applications.commands`
100
+ 3. Select bot permissions (choose based on features you need):
101
+
102
+ **Core Permissions:**
103
+ - Manage Channels
104
+ - Manage Roles
105
+ - Manage Messages
106
+ - Read Message History
107
+ - Send Messages
108
+ - Add Reactions
109
+
110
+ **Member Management:**
111
+ - Kick Members
112
+ - Ban Members
113
+ - Manage Nicknames
114
+ - Moderate Members (for timeouts)
115
+
116
+ **Server Administration:**
117
+ - Manage Guild (for server settings)
118
+ - View Audit Log
119
+ - Manage Emojis and Stickers
120
+ - Manage Webhooks
121
+ - Manage Events
122
+ - Create Instant Invite
123
+
124
+ 4. Copy the generated URL and open it to invite the bot
125
+
126
+ ### 3. Install the MCP Server
127
+
128
+ **Option A: Install globally from npm**
129
+
130
+ ```bash
131
+ npm install -g @mahesvara/discord-mcp-server
132
+ ```
133
+
134
+ **Option B: Run directly with npx (no install required)**
135
+
136
+ ```bash
137
+ npx @mahesvara/discord-mcp-server
138
+ ```
139
+
140
+ ## Usage
141
+
142
+ ### MCP Client Configuration
143
+
144
+ Add to your MCP client configuration (e.g., Claude Desktop or Claude Code):
145
+
146
+ **Using globally installed package:**
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "discord": {
152
+ "command": "discord-mcp-server",
153
+ "env": {
154
+ "DISCORD_BOT_TOKEN": "your_bot_token_here"
155
+ }
156
+ }
157
+ }
158
+ }
159
+ ```
160
+
161
+ **Using npx (no install required):**
162
+
163
+ ```json
164
+ {
165
+ "mcpServers": {
166
+ "discord": {
167
+ "command": "npx",
168
+ "args": ["-y", "@mahesvara/discord-mcp-server"],
169
+ "env": {
170
+ "DISCORD_BOT_TOKEN": "your_bot_token_here"
171
+ }
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ ### Environment Variables
178
+
179
+ The server supports loading environment variables from a `.env` file in the current directory:
180
+
181
+ ```env
182
+ DISCORD_BOT_TOKEN=your_bot_token_here
183
+ TRANSPORT=http
184
+ PORT=3000
185
+ ```
186
+
187
+ | Variable | Description | Default |
188
+ |----------|-------------|---------|
189
+ | `DISCORD_BOT_TOKEN` | Your Discord bot token (required) | - |
190
+ | `TRANSPORT` | Transport mode: `stdio` or `http` | `stdio` |
191
+ | `PORT` | HTTP server port (when using http transport) | `3000` |
192
+
193
+ ### HTTP Transport
194
+
195
+ For remote access, run the server with HTTP transport enabled:
196
+
197
+ **Linux/macOS:**
198
+ ```bash
199
+ DISCORD_BOT_TOKEN=your_token TRANSPORT=http PORT=3000 discord-mcp-server
200
+ ```
201
+
202
+ **Windows (Command Prompt):**
203
+ ```cmd
204
+ set DISCORD_BOT_TOKEN=your_token && set TRANSPORT=http && set PORT=3000 && discord-mcp-server
205
+ ```
206
+
207
+ **Windows (PowerShell):**
208
+ ```powershell
209
+ $env:DISCORD_BOT_TOKEN="your_token"; $env:TRANSPORT="http"; $env:PORT="3000"; discord-mcp-server
210
+ ```
211
+
212
+ **Or use a `.env` file** (works on all platforms):
213
+ ```bash
214
+ discord-mcp-server
215
+ ```
216
+
217
+ Then configure your MCP client to connect via HTTP:
218
+
219
+ ```json
220
+ {
221
+ "mcpServers": {
222
+ "discord": {
223
+ "type": "http",
224
+ "url": "http://your-server-ip:3000/mcp"
225
+ }
226
+ }
227
+ }
228
+ ```
229
+
230
+ ## Tool Examples
231
+
232
+ ### Create a Category
233
+
234
+ ```json
235
+ {
236
+ "tool": "discord_create_channel",
237
+ "params": {
238
+ "guild_id": "1234567890123456789",
239
+ "name": "Bot Testing",
240
+ "type": "category"
241
+ }
242
+ }
243
+ ```
244
+
245
+ ### Create a Channel in a Category
246
+
247
+ ```json
248
+ {
249
+ "tool": "discord_create_channel",
250
+ "params": {
251
+ "guild_id": "1234567890123456789",
252
+ "name": "bot-commands",
253
+ "type": "text",
254
+ "topic": "Channel for bot interactions",
255
+ "parent_id": "CATEGORY_ID_HERE"
256
+ }
257
+ }
258
+ ```
259
+
260
+ ### Set Channel Permissions
261
+
262
+ ```json
263
+ {
264
+ "tool": "discord_set_channel_permissions",
265
+ "params": {
266
+ "channel_id": "1234567890123456789",
267
+ "target_id": "ROLE_ID_HERE",
268
+ "target_type": "role",
269
+ "allow": ["ViewChannel", "SendMessages", "ReadMessageHistory"],
270
+ "deny": ["CreatePublicThreads"]
271
+ }
272
+ }
273
+ ```
274
+
275
+ ### Common Permission Names
276
+
277
+ **View & Access:**
278
+ - `ViewChannel` - See the channel
279
+
280
+ **Messages:**
281
+ - `SendMessages`, `ReadMessageHistory`, `ManageMessages`
282
+ - `EmbedLinks`, `AttachFiles`, `AddReactions`
283
+ - `UseExternalEmojis`, `UseExternalStickers`
284
+ - `MentionEveryone`
285
+
286
+ **Threads:**
287
+ - `CreatePublicThreads`, `CreatePrivateThreads`
288
+ - `SendMessagesInThreads`, `ManageThreads`
289
+
290
+ **Voice:**
291
+ - `Connect`, `Speak`, `Stream`
292
+ - `MuteMembers`, `DeafenMembers`, `MoveMembers`
293
+ - `UseVAD`, `PrioritySpeaker`
294
+
295
+ **Management:**
296
+ - `ManageChannels`, `ManageRoles`, `ManageWebhooks`
297
+
298
+ ### Send a Message
299
+
300
+ ```json
301
+ {
302
+ "tool": "discord_send_message",
303
+ "params": {
304
+ "channel_id": "1234567890123456789",
305
+ "content": "Hello from the MCP server!"
306
+ }
307
+ }
308
+ ```
309
+
310
+ ### Assign a Role
311
+
312
+ ```json
313
+ {
314
+ "tool": "discord_add_role",
315
+ "params": {
316
+ "guild_id": "1234567890123456789",
317
+ "user_id": "9876543210987654321",
318
+ "role_id": "1111111111111111111"
319
+ }
320
+ }
321
+ ```
322
+
323
+ ## Response Formats
324
+
325
+ Most read operations support two response formats:
326
+
327
+ - **json** (default): Structured data for programmatic processing
328
+ - **markdown**: Human-readable formatted output
329
+
330
+ ## Error Handling
331
+
332
+ All tools return clear error messages with suggestions when operations fail:
333
+
334
+ - Missing permissions
335
+ - Invalid IDs (guild, channel, user, role, message)
336
+ - Rate limiting
337
+ - Network issues
338
+
339
+ ## Security Notes
340
+
341
+ - **Never commit your bot token** - use environment variables
342
+ - The bot can only operate in servers it's been invited to
343
+ - Destructive operations (delete, kick, ban) are marked with `destructiveHint: true`
344
+ - All inputs are validated with Zod schemas
345
+
346
+ ## Required Bot Permissions
347
+
348
+ Depending on which tools you use, your bot needs these permissions:
349
+
350
+ | Tool Category | Required Permissions |
351
+ |--------------|---------------------|
352
+ | Messages | Send Messages, Read Message History, Manage Messages |
353
+ | Channels | Manage Channels |
354
+ | Permissions | Manage Roles (for channel permission overrides) |
355
+ | Members | Kick Members, Ban Members, Manage Nicknames, Moderate Members |
356
+ | Roles | Manage Roles |
357
+ | Reactions | Add Reactions |
358
+ | Server Settings | Manage Guild |
359
+ | Emojis/Stickers | Manage Emojis and Stickers |
360
+ | Invites | Create Instant Invite, Manage Guild |
361
+ | Webhooks | Manage Webhooks |
362
+ | Events | Manage Events |
363
+ | Audit Log | View Audit Log |
364
+
365
+ ## Tool Examples
366
+
367
+ ### Edit Role Permissions
368
+
369
+ ```json
370
+ {
371
+ "tool": "discord_edit_role",
372
+ "params": {
373
+ "guild_id": "1234567890123456789",
374
+ "role_id": "1111111111111111111",
375
+ "name": "Moderators",
376
+ "color": 3447003,
377
+ "permissions": ["KickMembers", "BanMembers", "ManageMessages", "ModerateMembers"]
378
+ }
379
+ }
380
+ ```
381
+
382
+ ### Reorder Role Hierarchy
383
+
384
+ ```json
385
+ {
386
+ "tool": "discord_set_role_positions",
387
+ "params": {
388
+ "guild_id": "1234567890123456789",
389
+ "positions": [
390
+ { "role_id": "1111111111111111111", "position": 5 },
391
+ { "role_id": "2222222222222222222", "position": 4 }
392
+ ]
393
+ }
394
+ }
395
+ ```
396
+
397
+ ### Timeout a Member
398
+
399
+ ```json
400
+ {
401
+ "tool": "discord_timeout_member",
402
+ "params": {
403
+ "guild_id": "1234567890123456789",
404
+ "user_id": "9876543210987654321",
405
+ "duration_minutes": 60,
406
+ "reason": "Spamming in chat"
407
+ }
408
+ }
409
+ ```
410
+
411
+ ### Create an Invite
412
+
413
+ ```json
414
+ {
415
+ "tool": "discord_create_invite",
416
+ "params": {
417
+ "channel_id": "1234567890123456789",
418
+ "max_age": 86400,
419
+ "max_uses": 10,
420
+ "temporary": false
421
+ }
422
+ }
423
+ ```
424
+
425
+ ### Create a Scheduled Event
426
+
427
+ ```json
428
+ {
429
+ "tool": "discord_create_event",
430
+ "params": {
431
+ "guild_id": "1234567890123456789",
432
+ "name": "Community Game Night",
433
+ "description": "Join us for games!",
434
+ "scheduled_start_time": "2024-12-01T20:00:00Z",
435
+ "entity_type": "voice",
436
+ "channel_id": "1111111111111111111"
437
+ }
438
+ }
439
+ ```
440
+
441
+ ### Role Permission Names
442
+
443
+ When editing roles, use these permission names:
444
+
445
+ **General:**
446
+ - `Administrator` - Full access (use with caution)
447
+ - `ManageGuild`, `ManageRoles`, `ManageChannels`
448
+ - `KickMembers`, `BanMembers`, `ModerateMembers`
449
+ - `ViewAuditLog`, `ViewGuildInsights`
450
+
451
+ **Messages:**
452
+ - `SendMessages`, `ManageMessages`, `ReadMessageHistory`
453
+ - `EmbedLinks`, `AttachFiles`, `AddReactions`
454
+ - `MentionEveryone`, `UseExternalEmojis`
455
+
456
+ **Voice:**
457
+ - `Connect`, `Speak`, `Stream`
458
+ - `MuteMembers`, `DeafenMembers`, `MoveMembers`
459
+
460
+ **Other:**
461
+ - `ManageWebhooks`, `ManageEmojisAndStickers`
462
+ - `ManageEvents`, `CreateEvents`
463
+
464
+ ## License
465
+
466
+ MIT
@@ -0,0 +1,4 @@
1
+ export declare const CHARACTER_LIMIT = 50000;
2
+ export declare const DEFAULT_LIMIT = 20;
3
+ export declare const MAX_LIMIT = 100;
4
+ export declare const MAX_MESSAGE_LENGTH = 2000;
@@ -0,0 +1,5 @@
1
+ // Shared constants for Discord MCP Server
2
+ export const CHARACTER_LIMIT = 50000;
3
+ export const DEFAULT_LIMIT = 20;
4
+ export const MAX_LIMIT = 100;
5
+ export const MAX_MESSAGE_LENGTH = 2000; // Discord's message limit
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "dotenv/config";