From c195a9aa3b8cd08c35b080c90f2b979a5d70a112 Mon Sep 17 00:00:00 2001 From: Shreya Keshive Date: Tue, 7 Oct 2025 13:26:35 -0700 Subject: [PATCH] fix(core): Use 127.0.0.1 for IDE client connection (#10658) --- packages/core/src/ide/ide-client.test.ts | 8 ++++---- packages/core/src/ide/ide-client.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/ide/ide-client.test.ts b/packages/core/src/ide/ide-client.test.ts index 0640232a6c..9375cd040f 100644 --- a/packages/core/src/ide/ide-client.test.ts +++ b/packages/core/src/ide/ide-client.test.ts @@ -113,7 +113,7 @@ describe('IdeClient', () => { 'utf8', ); expect(StreamableHTTPClientTransport).toHaveBeenCalledWith( - new URL('http://localhost:8080/mcp'), + new URL('http://127.0.0.1:8080/mcp'), expect.any(Object), ); expect(mockClient.connect).toHaveBeenCalledWith(mockHttpTransport); @@ -181,7 +181,7 @@ describe('IdeClient', () => { await ideClient.connect(); expect(StreamableHTTPClientTransport).toHaveBeenCalledWith( - new URL('http://localhost:9090/mcp'), + new URL('http://127.0.0.1:9090/mcp'), expect.any(Object), ); expect(mockClient.connect).toHaveBeenCalledWith(mockHttpTransport); @@ -229,7 +229,7 @@ describe('IdeClient', () => { await ideClient.connect(); expect(StreamableHTTPClientTransport).toHaveBeenCalledWith( - new URL('http://localhost:8080/mcp'), + new URL('http://127.0.0.1:8080/mcp'), expect.any(Object), ); expect(ideClient.getConnectionStatus().status).toBe( @@ -662,7 +662,7 @@ describe('IdeClient', () => { await ideClient.connect(); expect(StreamableHTTPClientTransport).toHaveBeenCalledWith( - new URL('http://localhost:8080/mcp'), + new URL('http://127.0.0.1:8080/mcp'), expect.objectContaining({ requestInit: { headers: { diff --git a/packages/core/src/ide/ide-client.ts b/packages/core/src/ide/ide-client.ts index e4c4006bf1..46ed52876d 100644 --- a/packages/core/src/ide/ide-client.ts +++ b/packages/core/src/ide/ide-client.ts @@ -667,10 +667,10 @@ export class IdeClient { } private createProxyAwareFetch() { - // ignore proxy for 'localhost' by deafult to allow connecting to the ide mcp server + // ignore proxy for '127.0.0.1' by deafult to allow connecting to the ide mcp server const existingNoProxy = process.env['NO_PROXY'] || ''; const agent = new EnvHttpProxyAgent({ - noProxy: [existingNoProxy, 'localhost'].filter(Boolean).join(','), + noProxy: [existingNoProxy, '127.0.0.1'].filter(Boolean).join(','), }); const undiciPromise = import('undici'); return async (url: string | URL, init?: RequestInit): Promise => { @@ -841,5 +841,5 @@ export class IdeClient { function getIdeServerHost() { const isInContainer = fs.existsSync('/.dockerenv') || fs.existsSync('/run/.containerenv'); - return isInContainer ? 'host.docker.internal' : 'localhost'; + return isInContainer ? 'host.docker.internal' : '127.0.0.1'; }