File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -224,15 +224,30 @@ const server = new McpServer({
224
224
225
225
const app = express ();
226
226
227
+ let transportMap = new Map ();
228
+
227
229
app .get (" /sse" , async (req , res ) => {
228
230
const transport = new SSEServerTransport (" /messages" , res );
231
+ const sessionId = transport .sessionId ;
232
+ transportsMap .set (sessionId , transport );
229
233
await server .connect (transport );
230
234
});
231
235
232
236
app .post (" /messages" , async (req , res ) => {
233
237
// Note: to support multiple simultaneous connections, these messages will
234
238
// need to be routed to a specific matching transport. (This logic isn't
235
239
// implemented here, for simplicity.)
240
+
241
+ const sessionId = req .query .sessionId ;
242
+ if (! sessionId ) {
243
+ return res .status (400 ).json ({ error: " SessionId is not found" });
244
+ }
245
+
246
+ const transport = transportMap .get (sessionId );
247
+ if (! transport ) {
248
+ return res .status (400 ).json ({ error: " Transport is not found" });
249
+ }
250
+
236
251
await transport .handlePostMessage (req , res );
237
252
});
238
253
You can’t perform that action at this time.
0 commit comments