Discord Gateway MCP Architecture

Discord Gateway MCP Architecture

The Claude Code team designed the Discord Gateway Service for user communication through Discord.

1. Overall Structure

LayerComponentsRole
DiscordBot, Channel, ThreadUser Interface
GatewayWebSocket, REST API, SSEMessage Routing
MCPgcp-mcp, oci-mcp, db-mcpTool Execution

2. Message Flow

3. Redis Removal: In-Memory Usage

ItemRedisIn-Memory
Thread LockSET NXdict
EventsStreamsSSE
CacheCacheMemory

Single instance is sufficient with In-Memory

4. MCP Selection: 4-Stage

PriorityMethodExample
1/command/gcp status
2@mention@gcp-monitor
3Keywordgcp server
4Channel#gcp-monitoring

5. Thread Lock

  • First responding MCP acquires lock
  • Default 5-minute hold
  • Auto-release on timeout

6. 8 MCP Tools

ToolDescription
discord_send_messageSend message
discord_get_messagesGet messages
discord_wait_for_messageWait for message
discord_create_threadCreate thread
discord_list_threadsList threads
discord_archive_threadArchive thread
discord_acquire_threadAcquire lock
discord_release_threadRelease lock

7. Execution

uvicorn gateway.main:app --port 8081
curl http://localhost:8081/health

8. Roadmap

  • Phase 1: Complete: Gateway, Lock, SSE, MCP
  • Phase 2: In Progress: Slash commands, keywords
  • Phase 3: Optional: Auth, Rate Limit

Conclusion: Start with simple architecture, extend as needed


Korean Version: 한국어 버전

Built with Hugo
Theme Stack designed by Jimmy