yarn build

This commit is contained in:
Justin Spahr-Summers 2024-10-16 13:16:08 +01:00
commit a1b8886b26
No known key found for this signature in database

13
dist/cli.js generated vendored
View file

@ -26,16 +26,13 @@ async function runClient(url_or_command, args) {
// Ignore
}
if ((url === null || url === void 0 ? void 0 : url.protocol) === "http:" || (url === null || url === void 0 ? void 0 : url.protocol) === "https:") {
clientTransport = new SSEClientTransport();
await clientTransport.connect(new URL(url_or_command));
clientTransport = new SSEClientTransport(new URL(url_or_command));
}
else if ((url === null || url === void 0 ? void 0 : url.protocol) === "ws:" || (url === null || url === void 0 ? void 0 : url.protocol) === "wss:") {
clientTransport = new WebSocketClientTransport();
await clientTransport.connect(new URL(url_or_command));
clientTransport = new WebSocketClientTransport(new URL(url_or_command));
}
else {
clientTransport = new StdioClientTransport();
await clientTransport.spawn({
clientTransport = new StdioClientTransport({
command: url_or_command,
args,
});
@ -52,7 +49,7 @@ async function runServer(port) {
let servers = [];
app.get("/sse", async (req, res) => {
console.log("Got new SSE connection");
const transport = new SSEServerTransport("/message");
const transport = new SSEServerTransport("/message", res);
const server = new Server({
name: "mcp-typescript test server",
version: "0.1.0",
@ -62,7 +59,6 @@ async function runServer(port) {
console.log("SSE connection closed");
servers = servers.filter((s) => s !== server);
};
await transport.connectSSE(req, res);
await server.connect(transport);
});
app.post("/message", async (req, res) => {
@ -87,7 +83,6 @@ async function runServer(port) {
version: "0.1.0",
});
const transport = new StdioServerTransport();
await transport.start();
await server.connect(transport);
console.log("Server running on stdio");
}