From 353d6b549bfbb0c64f995350a95674b288c42075 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 27 Mar 2025 09:52:35 +0100 Subject: [PATCH] fix: clean up previous transport processes --- client/src/components/Sidebar.tsx | 14 ++++++++++++-- server/src/index.ts | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client/src/components/Sidebar.tsx b/client/src/components/Sidebar.tsx index 4f60a77..6c9f137 100644 --- a/client/src/components/Sidebar.tsx +++ b/client/src/components/Sidebar.tsx @@ -8,6 +8,7 @@ import { Github, Eye, EyeOff, + RotateCcw, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -286,8 +287,17 @@ const Sidebar = ({
diff --git a/server/src/index.ts b/server/src/index.ts index 2a4fe65..d4bfc6a 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -12,6 +12,7 @@ import { StdioClientTransport, getDefaultEnvironment, } from "@modelcontextprotocol/sdk/client/stdio.js"; +import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; import express from "express"; import { findActualExecutable } from "spawn-rx"; @@ -98,12 +99,14 @@ const createTransport = async (req: express.Request) => { } }; +let backingServerTransport: Transport | undefined; + app.get("/sse", async (req, res) => { try { console.log("New SSE connection"); - let backingServerTransport; try { + await backingServerTransport?.close(); backingServerTransport = await createTransport(req); } catch (error) { if (error instanceof SseError && error.code === 401) {