Squashed 'packages/mcp-typescript/' changes from dcc30be..e665be0
e665be0 Merge pull request #14 from modelcontextprotocol/justin/fix-race-condition be9c1fe Merge branch 'main' into justin/fix-race-condition 36ba802 Merge pull request #17 from modelcontextprotocol/ashwin/capabilities a1b8886 yarn build 7b718de Report errors when start() is called multiple times 83a43fd Protocol.connect() can automatically call Transport.start() 8d80cc5 Merge branch 'main' into justin/fix-race-condition bcb4b21 add server capabilities derivation e9c64fb Update tests and CLI 2b0599e Update server SSE transport c39f808 Update client transports 87ae7ff Add start() to Transport interface git-subtree-dir: packages/mcp-typescript git-subtree-split: e665be068b9d2baa65f37fd7c2f69f68f77e57b9
This commit is contained in:
parent
50b812b120
commit
23ca80ed66
1 changed files with 228 additions and 97 deletions
13
packages/mcp-typescript/dist/cli.js
generated
vendored
13
packages/mcp-typescript/dist/cli.js
generated
vendored
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue