Skip to content

Commit d16e89d

Browse files
committed
Preserve original URL
1 parent cdab12a commit d16e89d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cli/src/transport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export type TransportOptions = {
1515

1616
function createSSETransport(options: TransportOptions): Transport {
1717
const baseUrl = new URL(options.url ?? "");
18+
// Create new URL while preserving the port from baseUrl
1819
const sseUrl = new URL("/sse", baseUrl);
20+
if (baseUrl.port) {
21+
sseUrl.port = baseUrl.port;
22+
}
1923

2024
return new SSEClientTransport(sseUrl);
2125
}

client/src/lib/hooks/useConnection.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ export function useConnection({
280280
return;
281281
}
282282
let mcpProxyServerUrl;
283+
const originalUrl = new URL(sseUrl);
284+
283285
switch (transportType) {
284286
case "stdio":
285287
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`);
@@ -290,12 +292,12 @@ export function useConnection({
290292

291293
case "sse":
292294
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/sse`);
293-
mcpProxyServerUrl.searchParams.append("url", sseUrl);
295+
mcpProxyServerUrl.searchParams.append("url", originalUrl.toString());
294296
break;
295297

296298
case "streamable-http":
297299
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/mcp`);
298-
mcpProxyServerUrl.searchParams.append("url", sseUrl);
300+
mcpProxyServerUrl.searchParams.append("url", originalUrl.toString());
299301
break;
300302
}
301303
(mcpProxyServerUrl as URL).searchParams.append(

0 commit comments

Comments
 (0)