Skip to content

Commit e9c64fb

Browse files
committed
Update tests and CLI
1 parent 2b0599e commit e9c64fb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/cli.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ async function runClient(url_or_command: string, args: string[]) {
3131
}
3232

3333
if (url?.protocol === "http:" || url?.protocol === "https:") {
34-
clientTransport = new SSEClientTransport();
35-
await clientTransport.connect(new URL(url_or_command));
34+
clientTransport = new SSEClientTransport(new URL(url_or_command));
35+
await clientTransport.start();
3636
} else if (url?.protocol === "ws:" || url?.protocol === "wss:") {
37-
clientTransport = new WebSocketClientTransport();
38-
await clientTransport.connect(new URL(url_or_command));
37+
clientTransport = new WebSocketClientTransport(new URL(url_or_command));
38+
await clientTransport.start();
3939
} else {
40-
clientTransport = new StdioClientTransport();
41-
await clientTransport.spawn({
40+
clientTransport = new StdioClientTransport({
4241
command: url_or_command,
4342
args,
4443
});
44+
await clientTransport.start();
4545
}
4646

4747
console.log("Connected to server.");
@@ -62,7 +62,7 @@ async function runServer(port: number | null) {
6262
app.get("/sse", async (req, res) => {
6363
console.log("Got new SSE connection");
6464

65-
const transport = new SSEServerTransport("/message");
65+
const transport = new SSEServerTransport("/message", res);
6666
const server = new Server({
6767
name: "mcp-typescript test server",
6868
version: "0.1.0",
@@ -75,7 +75,7 @@ async function runServer(port: number | null) {
7575
servers = servers.filter((s) => s !== server);
7676
};
7777

78-
await transport.connectSSE(req, res);
78+
await transport.start();
7979
await server.connect(transport);
8080
});
8181

src/client/stdio.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const serverParameters: StdioServerParameters = {
66
};
77

88
test("should start then close cleanly", async () => {
9-
const client = new StdioClientTransport();
9+
const client = new StdioClientTransport(serverParameters);
1010
client.onerror = (error) => {
1111
throw error;
1212
};
@@ -16,14 +16,14 @@ test("should start then close cleanly", async () => {
1616
didClose = true;
1717
};
1818

19-
await client.spawn(serverParameters);
19+
await client.start();
2020
expect(didClose).toBeFalsy();
2121
await client.close();
2222
expect(didClose).toBeTruthy();
2323
});
2424

2525
test("should read messages", async () => {
26-
const client = new StdioClientTransport();
26+
const client = new StdioClientTransport(serverParameters);
2727
client.onerror = (error) => {
2828
throw error;
2929
};
@@ -51,7 +51,7 @@ test("should read messages", async () => {
5151
};
5252
});
5353

54-
await client.spawn(serverParameters);
54+
await client.start();
5555
await client.send(messages[0]);
5656
await client.send(messages[1]);
5757
await finished;

0 commit comments

Comments
 (0)