mcp-discord-direct-interface
Grants direct programmatic ingress to the official Discord Application Programming Interface (API), facilitating execution of HTTP operations and leveraging application-specific slash command invocation mechanisms for platform interaction.
Author

hanweg
Quick Info
Actions
Tags
Direct Interface to Discord's Backend Services (MCP Module)
This specialized MCP module furnishes uncensored pathways to the underlying Discord API. It encompasses support for conventional Representational State Transfer (REST) interactions alongside native slash command formatting.
Implementation Procedure
Automated Deployment via Smithery
For seamless integration into Claude Desktop utilizing Smithery:
bash npx -y @smithery/cli install @hanweg/mcp-discord-raw --client claude
Manual Setup Steps
- Bot Credentialization:
- Establish a new application via the Discord Developer Portal.
- Generate a bot instance and secure the authorization token.
- Enable the mandatory privileged gateway intents:
- MESSAGE CONTENT INTENT
- PRESENCE INTENT
- SERVER MEMBERS INTENT
-
Employ the OAuth2 URL Generator to extend an invitation for the bot to join your server.
-
Repository Acquisition and Dependency Resolution: bash
Clone the source code repository
git clone https://github.com/hanweg/mcp-discord-raw.git cd mcp-discord-raw
Establish and activate a Python isolated environment
uv venv .venv\Scripts\activate
For Python 3.13+ environments, install the auxiliary library: uv pip install audioop-lts
Install the package in editable mode
uv pip install -e .
Configuration Manifest
Incorporate the following directive into your claude_desktop_config.json file:
"discord-raw": {
"command": "uv",
"args": [
"--directory",
"PATH/TO/mcp-discord-raw",
"run",
"discord-raw-mcp"
],
"env": {
"DISCORD_TOKEN": "YOUR-BOT-TOKEN"
}
}
Operational Syntax
Standard REST Methodology
python { "method": "POST", "endpoint": "guilds/123456789/roles", "payload": { "name": "Bot Master", "permissions": "8", "color": 3447003, "mentionable": true } }
Slash Command Emulation
python { "method": "POST", "endpoint": "/role create name:Bot_Master color:blue permissions:8 mentionable:true guild_id:123456789" }
Practical Illustrations
- Role Creation Snippet:
{ "method": "POST", "endpoint": "/role create name:Moderator color:red permissions:moderate_members guild_id:123456789" }
- Message Transmission Example:
{ "method": "POST", "endpoint": "channels/123456789/messages", "payload": { "content": "Greetings transmitted from the application programming interface!" } }
- Server Metadata Retrieval:
{ "method": "GET", "endpoint": "guilds/123456789" }
Guidance for Optimal Performance:
Seed the project knowledge base with essential identifiers (server, channel, user IDs) and include instructions similar to this to bootstrap the model:
"To maximize utility of the direct Discord API tool (named discord_api), use the following tripartite structure:
1. method: The required HTTP verb ("GET", "POST", "PUT", "PATCH", "DELETE").
2. endpoint: The specific Discord API path (e.g., "guilds/{guild.id}/roles").
3. payload: An optional JSON object containing request body data.
Illustrative Use Cases: 1. Role Provisioning:
discord_api method: POST endpoint: guilds/{server_id}/roles payload: { "name": "New Role", "color": 3447003, // Standard blue integer value "mentionable": true }
- Channel Hierarchy Management:
// Group/Category Creation discord_api method: POST endpoint: guilds/{server_id}/channels payload: { "name": "Channel_Grouping", "type": 4 // Enumeration for a category } // Child Text Channel within the Group discord_api method: POST endpoint: guilds/{server_id}/channels payload: { "name": "designated-chat", "type": 0, // Text channel type "parent_id": "category_id", "topic": "Discussion thread" }
- Relocating Channels:
discord_api method: PATCH endpoint: channels/{channel_id} payload: { "parent_id": "category_id" }
- Message Dispatch:
discord_api method: POST endpoint: channels/{channel_id}/messages payload: { "content": "Transmitting data now 🚀" }
- Role Assignment:
discord_api method: PUT endpoint: guilds/{server_id}/members/{user_id}/roles/{role_id} payload: {}
Refer to the official Discord API documentation for comprehensive endpoint coverage. The output provides essential metadata (like generated IDs) for subsequent chained operations.
Expert Directives:
- Persist IDs returned from creation calls for reuse in subsequent API calls.
- Consider using Discord's native shorthand for emojis (e.g., :smile:) instead of direct Unicode sequences, as the latter might cause instability in the execution environment.
- Channel Type Codes: 0=Text, 2=Voice, 4=Category, 13=Stage.
- Role colors must be supplied in base-10 (decimal) format, not hexadecimal.
- Modifications typically necessitate the PATCH method.
- Ensure empty request bodies are formatted as {} rather than null.
Licensing
This module is distributed under the MIT License.
WIKIPEDIA: XMLHttpRequest (XHR) represents an Application Programming Interface embodied by a JavaScript object. Its methods are engineered to dispatch Hypertext Transfer Protocol (HTTP) queries from a running web browser environment to a designated web server. These capabilities permit browser-based applications to invoke server interactions subsequent to the page rendering phase, enabling asynchronous data retrieval. XHR forms a foundational element of Ajax development patterns. Before its introduction, the primary means for server communication involved standard hyperlinks and form submissions, actions that generally triggered a complete page refresh.
== Genesis ==
The conceptual foundation for XMLHttpRequest was first postulated in the year 2000 by the engineering team behind Microsoft Outlook. This concept subsequently materialized within the Internet Explorer 5 browser release (1999). Notably, the initial syntactic structure did not employ the standardized XMLHttpRequest identifier. Instead, developers relied on COM object instantiations: ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the time Internet Explorer 7 was released (2006), support for the canonical XMLHttpRequest identifier was universal across all major browser engines.
Today, the XMLHttpRequest identifier serves as the established protocol standard across all primary browser platforms, including Mozilla's Gecko rendering engine (since 2002), Safari 1.2 (2004), and Opera 8.0 (2005).
=== Formalization === The World Wide Web Consortium (W3C) formally published a Working Draft specification for the XMLHttpRequest object on April 5, 2006. A subsequent Working Draft, designated Level 2, followed on February 25, 2008. Level 2 introduced enhancements such as event progress monitoring, mechanisms for cross-origin requests, and improved handling of binary data streams. By the conclusion of 2011, the Level 2 specification features were integrated back into the primary standard document. Towards the end of 2012, the WHATWG assumed stewardship over the document's evolution, maintaining it as a continuous specification using Web IDL notation.
== Operation == Executing a request using XMLHttpRequest conventionally involves several distinct programmatic phases.
- Instantiation: Create an XMLHttpRequest instance via its constructor.
- Setup: Invoke the
openmethod to define the request modality (GET, POST, etc.), designate the target resource URL, and specify whether the operation should be synchronous or asynchronous. - Listener Registration: For asynchronous operations, define an event handler function intended to process state transitions.
- Transmission: Initiate the query by calling the
sendmethod, optionally including data. - Response Handling: Monitor the event listener for state changes. Upon data receipt, it defaults to the
responseTextattribute. When processing concludes, the object transitions to state 4, the 'done' status. Beyond these foundational steps, XMLHttpRequest offers extensive control over transmission parameters and response parsing. Custom HTTP headers can be appended to guide server processing. Data can be streamed to the server via thesendargument. Responses can be immediately parsed from JSON into native JavaScript objects or processed iteratively as they arrive, avoiding wait times for full content transfer. Furthermore, requests can be terminated prematurely or assigned a timeout threshold.
