nodebb-plugin-integration 0.4.4 → 0.5.0
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/package.json +1 -1
- package/src/mcp/server.js +32 -28
package/package.json
CHANGED
package/src/mcp/server.js
CHANGED
|
@@ -187,30 +187,9 @@ async function start(rawConfig) {
|
|
|
187
187
|
await stop();
|
|
188
188
|
|
|
189
189
|
const api = createApiClient(config);
|
|
190
|
-
|
|
191
|
-
const nextMcpServer = new Server(
|
|
192
|
-
{
|
|
193
|
-
name: "nodebb-integration-mcp",
|
|
194
|
-
version: "0.4.2"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
capabilities: {
|
|
198
|
-
tools: {}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const nextTransport = new StreamableHTTPServerTransport({
|
|
204
|
-
sessionIdGenerator: undefined
|
|
205
|
-
});
|
|
206
|
-
|
|
207
190
|
let nextHttpServer = null;
|
|
208
191
|
|
|
209
192
|
try {
|
|
210
|
-
Tools.register(nextMcpServer, api);
|
|
211
|
-
|
|
212
|
-
await nextMcpServer.connect(nextTransport);
|
|
213
|
-
|
|
214
193
|
nextHttpServer = http.createServer(async (req, res) => {
|
|
215
194
|
let pathname;
|
|
216
195
|
|
|
@@ -242,10 +221,32 @@ async function start(rawConfig) {
|
|
|
242
221
|
return;
|
|
243
222
|
}
|
|
244
223
|
|
|
224
|
+
let requestMcpServer = null;
|
|
225
|
+
let requestTransport = null;
|
|
226
|
+
|
|
245
227
|
try {
|
|
246
|
-
|
|
228
|
+
requestMcpServer = new Server(
|
|
229
|
+
{
|
|
230
|
+
name: "nodebb-integration-mcp",
|
|
231
|
+
version: "0.5.0"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
capabilities: {
|
|
235
|
+
tools: {}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
requestTransport = new StreamableHTTPServerTransport({
|
|
241
|
+
sessionIdGenerator: undefined
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
Tools.register(requestMcpServer, api);
|
|
245
|
+
|
|
246
|
+
await requestMcpServer.connect(requestTransport);
|
|
247
|
+
await requestTransport.handleRequest(req, res);
|
|
247
248
|
} catch (error) {
|
|
248
|
-
console.error("[MCP] Request failed:", error.
|
|
249
|
+
console.error("[MCP] Request failed:", error.stack || error);
|
|
249
250
|
|
|
250
251
|
if (!res.headersSent) {
|
|
251
252
|
res.writeHead(500, {
|
|
@@ -253,6 +254,14 @@ async function start(rawConfig) {
|
|
|
253
254
|
});
|
|
254
255
|
res.end(JSON.stringify({ error: "MCP request failed" }));
|
|
255
256
|
}
|
|
257
|
+
} finally {
|
|
258
|
+
if (requestTransport) {
|
|
259
|
+
await requestTransport.close().catch(() => {});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (requestMcpServer) {
|
|
263
|
+
await requestMcpServer.close().catch(() => {});
|
|
264
|
+
}
|
|
256
265
|
}
|
|
257
266
|
});
|
|
258
267
|
|
|
@@ -273,8 +282,6 @@ async function start(rawConfig) {
|
|
|
273
282
|
});
|
|
274
283
|
|
|
275
284
|
httpServer = nextHttpServer;
|
|
276
|
-
transport = nextTransport;
|
|
277
|
-
mcpServer = nextMcpServer;
|
|
278
285
|
|
|
279
286
|
console.log(
|
|
280
287
|
`[MCP] Streamable HTTP listening on ${config.host}:${config.port}/mcp`
|
|
@@ -287,9 +294,6 @@ async function start(rawConfig) {
|
|
|
287
294
|
});
|
|
288
295
|
}
|
|
289
296
|
|
|
290
|
-
await nextTransport.close().catch(() => {});
|
|
291
|
-
await nextMcpServer.close().catch(() => {});
|
|
292
|
-
|
|
293
297
|
throw error;
|
|
294
298
|
}
|
|
295
299
|
}
|