From 48f0cb1739a9c785e27a65131a50e76974108097 Mon Sep 17 00:00:00 2001 From: BarryY Date: Thu, 15 May 2025 13:18:08 +0800 Subject: [PATCH] fix: Fix Discord client initialization in HTTP transport --- src/transport.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/transport.ts b/src/transport.ts index 05a3f43..441ce43 100644 --- a/src/transport.ts +++ b/src/transport.ts @@ -25,7 +25,7 @@ import { editWebhookHandler, deleteWebhookHandler } from './tools/tools.js'; -import { Client } from "discord.js"; +import { Client, GatewayIntentBits } from "discord.js"; import { info, error } from './logger.js'; export interface MCPTransport { @@ -535,9 +535,18 @@ export class StreamableHttpTransport implements MCPTransport { this.toolContext = createToolContext(client); info('Tool context initialized with Discord client'); } else { - // Create a dummy client for testing - allows list_tools to work - info('Unable to get Discord client. Creating tool context without client.'); - this.toolContext = createToolContext({} as Client); + // Create a real Discord client instead of a dummy + info('Creating new Discord client for transport'); + const newClient = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMessageReactions + ] + }); + this.toolContext = createToolContext(newClient); + info('Tool context initialized with new Discord client'); } }