Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cli/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@ export type TransportOptions = {
};

function createSSETransport(options: TransportOptions): Transport {
const baseUrl = new URL(options.url ?? "");
const sseUrl = baseUrl.pathname.endsWith("/sse")
? baseUrl
: new URL("/sse", baseUrl);
if (!options.url) {
throw new Error("URL is required for SSE transport");
}

const sseUrl = new URL(options.url);

if (!sseUrl.pathname.endsWith("/sse")) {
console.warn(`[warn] SSE transport URL does not end with /sse: ${options.url}`);
}
Comment on lines +24 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the focus of this PR, is it necessary to output this warning at all?


return new SSEClientTransport(sseUrl);
}

function createHTTPTransport(options: TransportOptions): Transport {
const baseUrl = new URL(options.url ?? "");
const mcpUrl = baseUrl.pathname.endsWith("/mcp")
? baseUrl
: new URL("/mcp", baseUrl);
if (!options.url) {
throw new Error("URL is required for HTTP transport");
}

const mcpUrl = new URL(options.url);

if (!mcpUrl.pathname.endsWith("/mcp")) {
console.warn(`[warn] HTTP transport URL does not end with /mcp: ${options.url}`);
}
Comment on lines +38 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the focus of this PR, is it necessary to output this warning at all?


return new StreamableHTTPClientTransport(mcpUrl);
}

Expand Down
Loading