Merge pull request #216 from Skn0tt/cleanup-old-transports
fix: clean up previous transport processes
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
Github,
|
Github,
|
||||||
Eye,
|
Eye,
|
||||||
EyeOff,
|
EyeOff,
|
||||||
|
RotateCcw,
|
||||||
Settings,
|
Settings,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -375,8 +376,17 @@ const Sidebar = ({
|
|||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Button className="w-full" onClick={onConnect}>
|
<Button className="w-full" onClick={onConnect}>
|
||||||
<Play className="w-4 h-4 mr-2" />
|
{connectionStatus === "connected" ? (
|
||||||
Connect
|
<>
|
||||||
|
<RotateCcw className="w-4 h-4 mr-2" />
|
||||||
|
{transportType === "stdio" ? "Restart" : "Reconnect"}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Play className="w-4 h-4 mr-2" />
|
||||||
|
Connect
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<div className="flex items-center justify-center space-x-2 mb-4">
|
<div className="flex items-center justify-center space-x-2 mb-4">
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
StdioClientTransport,
|
StdioClientTransport,
|
||||||
getDefaultEnvironment,
|
getDefaultEnvironment,
|
||||||
} from "@modelcontextprotocol/sdk/client/stdio.js";
|
} from "@modelcontextprotocol/sdk/client/stdio.js";
|
||||||
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
||||||
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import { findActualExecutable } from "spawn-rx";
|
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) => {
|
app.get("/sse", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
console.log("New SSE connection");
|
console.log("New SSE connection");
|
||||||
|
|
||||||
let backingServerTransport;
|
|
||||||
try {
|
try {
|
||||||
|
await backingServerTransport?.close();
|
||||||
backingServerTransport = await createTransport(req);
|
backingServerTransport = await createTransport(req);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof SseError && error.code === 401) {
|
if (error instanceof SseError && error.code === 401) {
|
||||||
|
|||||||
Reference in New Issue
Block a user