From 6b2497c78d2f5dc42473678ce774947d292672f5 Mon Sep 17 00:00:00 2001 From: ronantakizawa Date: Tue, 12 Aug 2025 13:31:50 -0600 Subject: [PATCH 1/2] fix: fix MCP_PROXY_FULL_ADDRESS compatibility with /message --- client/e2e/test-results/.last-run.json | 21 +++++++++++++++++++++ server/src/index.ts | 23 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 client/e2e/test-results/.last-run.json diff --git a/client/e2e/test-results/.last-run.json b/client/e2e/test-results/.last-run.json new file mode 100644 index 000000000..1d017ad2b --- /dev/null +++ b/client/e2e/test-results/.last-run.json @@ -0,0 +1,21 @@ +{ + "status": "failed", + "failedTests": [ + "1af8f9525206dc757939-686d1b72059552706759", + "1af8f9525206dc757939-3eb9167d55fa7bfcd223", + "1af8f9525206dc757939-abc961e2687902e8e5ad", + "9101c99554b07dbfcf1a-1b8098044a674460d91e", + "505e4ab94dca249895e7-983753a5b7cda2a15a69", + "505e4ab94dca249895e7-4db49683e81898eb7b8e", + "505e4ab94dca249895e7-3d6d8d9e5240fa6da980", + "505e4ab94dca249895e7-74fa757dd051d21269b0", + "1af8f9525206dc757939-439df54b9ee58caf4734", + "1af8f9525206dc757939-ecc422dc794292ff1ef7", + "1af8f9525206dc757939-87de041e4d294116727b", + "9101c99554b07dbfcf1a-37573fbbe5b38d389cb8", + "505e4ab94dca249895e7-981fec1450cd4cb72ec0", + "505e4ab94dca249895e7-94528f686575c2699fff", + "505e4ab94dca249895e7-cc2321d0c5e63bb50998", + "505e4ab94dca249895e7-9b01eb4d5cf5262c86af" + ] +} \ No newline at end of file diff --git a/server/src/index.ts b/server/src/index.ts index 34a69414a..a489c3bf7 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -98,6 +98,25 @@ const sessionToken = process.env.MCP_PROXY_AUTH_TOKEN || randomBytes(32).toString("hex"); const authDisabled = !!process.env.DANGEROUSLY_OMIT_AUTH; +// Extract base path from MCP_PROXY_FULL_ADDRESS for SSE message endpoint +const getMessagePath = (): string => { + const proxyFullAddress = process.env.MCP_PROXY_FULL_ADDRESS; + if (!proxyFullAddress) { + return "/message"; + } + try { + const url = new URL(proxyFullAddress); + // Remove trailing slash and add /message to the pathname + const basePath = + url.pathname === "/" ? "" : url.pathname.replace(/\/$/, ""); + return `${basePath}/message`; + } catch { + return "/message"; + } +}; + +const MESSAGE_PATH = getMessagePath(); + // Origin validation middleware to prevent DNS rebinding attacks const originValidationMiddleware = ( req: express.Request, @@ -391,7 +410,7 @@ app.get( throw error; } - const webAppTransport = new SSEServerTransport("/message", res); + const webAppTransport = new SSEServerTransport(MESSAGE_PATH, res); console.log("Created client transport"); webAppTransports.set(webAppTransport.sessionId, webAppTransport); @@ -469,7 +488,7 @@ app.get( } if (serverTransport) { - const webAppTransport = new SSEServerTransport("/message", res); + const webAppTransport = new SSEServerTransport(MESSAGE_PATH, res); webAppTransports.set(webAppTransport.sessionId, webAppTransport); console.log("Created client transport"); serverTransports.set(webAppTransport.sessionId, serverTransport!); From 3cc35b5d6e17961d1563541cfb8df91a6a0448bc Mon Sep 17 00:00:00 2001 From: ronantakizawa Date: Tue, 12 Aug 2025 13:32:27 -0600 Subject: [PATCH 2/2] fix: fix MCP_PROXY_FULL_ADDRESS compatibili ty with /message --- client/e2e/test-results/.last-run.json | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 client/e2e/test-results/.last-run.json diff --git a/client/e2e/test-results/.last-run.json b/client/e2e/test-results/.last-run.json deleted file mode 100644 index 1d017ad2b..000000000 --- a/client/e2e/test-results/.last-run.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "status": "failed", - "failedTests": [ - "1af8f9525206dc757939-686d1b72059552706759", - "1af8f9525206dc757939-3eb9167d55fa7bfcd223", - "1af8f9525206dc757939-abc961e2687902e8e5ad", - "9101c99554b07dbfcf1a-1b8098044a674460d91e", - "505e4ab94dca249895e7-983753a5b7cda2a15a69", - "505e4ab94dca249895e7-4db49683e81898eb7b8e", - "505e4ab94dca249895e7-3d6d8d9e5240fa6da980", - "505e4ab94dca249895e7-74fa757dd051d21269b0", - "1af8f9525206dc757939-439df54b9ee58caf4734", - "1af8f9525206dc757939-ecc422dc794292ff1ef7", - "1af8f9525206dc757939-87de041e4d294116727b", - "9101c99554b07dbfcf1a-37573fbbe5b38d389cb8", - "505e4ab94dca249895e7-981fec1450cd4cb72ec0", - "505e4ab94dca249895e7-94528f686575c2699fff", - "505e4ab94dca249895e7-cc2321d0c5e63bb50998", - "505e4ab94dca249895e7-9b01eb4d5cf5262c86af" - ] -} \ No newline at end of file