Use MCP_PROXY_FULL_ADDRESS for SSE transport backed endpoints

The STDIO and SSE transports use SSE between the client and the proxy
server.  SSE requires the client to initiate the MCP conversation
(event-stream) at the endpoint provided by the server.  The endpoint
provided by the server must obey where the client sees the server,
rather than being assumed to be server-root `/message`.

The Streamable HTTP endpoint does not need the full proxy address
because the response is an event-stream directly, and does not use SSE.
This commit is contained in:
Richard Michael 2025-08-10 13:06:19 -07:00
commit 3628abca9e

View file

@ -391,7 +391,11 @@ app.get(
throw error;
}
const webAppTransport = new SSEServerTransport("/message", res);
const proxyFullAddress = (req.query.proxyFullAddress as string) || "";
const prefix = proxyFullAddress || "";
const endpoint = `${prefix}/message`;
const webAppTransport = new SSEServerTransport(endpoint, res);
console.log("Created client transport");
webAppTransports.set(webAppTransport.sessionId, webAppTransport);
@ -511,7 +515,11 @@ app.get(
}
if (serverTransport) {
const webAppTransport = new SSEServerTransport("/message", res);
const proxyFullAddress = (req.query.proxyFullAddress as string) || "";
const prefix = proxyFullAddress || "";
const endpoint = `${prefix}/message`;
const webAppTransport = new SSEServerTransport(endpoint, res);
webAppTransports.set(webAppTransport.sessionId, webAppTransport);
console.log("Created client transport");
serverTransports.set(webAppTransport.sessionId, serverTransport!);