Skip to content

Commit 353d6b5

Browse files
committed
fix: clean up previous transport processes
1 parent 4d4bb91 commit 353d6b5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

client/src/components/Sidebar.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Github,
99
Eye,
1010
EyeOff,
11+
RotateCcw,
1112
} from "lucide-react";
1213
import { Button } from "@/components/ui/button";
1314
import { Input } from "@/components/ui/input";
@@ -286,8 +287,17 @@ const Sidebar = ({
286287

287288
<div className="space-y-2">
288289
<Button className="w-full" onClick={onConnect}>
289-
<Play className="w-4 h-4 mr-2" />
290-
Connect
290+
{connectionStatus === "connected" ? (
291+
<>
292+
<RotateCcw className="w-4 h-4 mr-2" />
293+
Restart
294+
</>
295+
) : (
296+
<>
297+
<Play className="w-4 h-4 mr-2" />
298+
Connect
299+
</>
300+
)}
291301
</Button>
292302

293303
<div className="flex items-center justify-center space-x-2 mb-4">

server/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
StdioClientTransport,
1313
getDefaultEnvironment,
1414
} from "@modelcontextprotocol/sdk/client/stdio.js";
15+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
1516
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
1617
import express from "express";
1718
import { findActualExecutable } from "spawn-rx";
@@ -98,12 +99,14 @@ const createTransport = async (req: express.Request) => {
9899
}
99100
};
100101

102+
let backingServerTransport: Transport | undefined;
103+
101104
app.get("/sse", async (req, res) => {
102105
try {
103106
console.log("New SSE connection");
104107

105-
let backingServerTransport;
106108
try {
109+
await backingServerTransport?.close();
107110
backingServerTransport = await createTransport(req);
108111
} catch (error) {
109112
if (error instanceof SseError && error.code === 401) {

0 commit comments

Comments
 (0)