Skip to content

Commit c195a9a

Browse files
authored
fix(core): Use 127.0.0.1 for IDE client connection (#10658)
1 parent ed0d1a0 commit c195a9a

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/core/src/ide/ide-client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('IdeClient', () => {
113113
'utf8',
114114
);
115115
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(
116-
new URL('http://localhost:8080/mcp'),
116+
new URL('http://127.0.0.1:8080/mcp'),
117117
expect.any(Object),
118118
);
119119
expect(mockClient.connect).toHaveBeenCalledWith(mockHttpTransport);
@@ -181,7 +181,7 @@ describe('IdeClient', () => {
181181
await ideClient.connect();
182182

183183
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(
184-
new URL('http://localhost:9090/mcp'),
184+
new URL('http://127.0.0.1:9090/mcp'),
185185
expect.any(Object),
186186
);
187187
expect(mockClient.connect).toHaveBeenCalledWith(mockHttpTransport);
@@ -229,7 +229,7 @@ describe('IdeClient', () => {
229229
await ideClient.connect();
230230

231231
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(
232-
new URL('http://localhost:8080/mcp'),
232+
new URL('http://127.0.0.1:8080/mcp'),
233233
expect.any(Object),
234234
);
235235
expect(ideClient.getConnectionStatus().status).toBe(
@@ -662,7 +662,7 @@ describe('IdeClient', () => {
662662
await ideClient.connect();
663663

664664
expect(StreamableHTTPClientTransport).toHaveBeenCalledWith(
665-
new URL('http://localhost:8080/mcp'),
665+
new URL('http://127.0.0.1:8080/mcp'),
666666
expect.objectContaining({
667667
requestInit: {
668668
headers: {

packages/core/src/ide/ide-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,10 @@ export class IdeClient {
667667
}
668668

669669
private createProxyAwareFetch() {
670-
// ignore proxy for 'localhost' by deafult to allow connecting to the ide mcp server
670+
// ignore proxy for '127.0.0.1' by deafult to allow connecting to the ide mcp server
671671
const existingNoProxy = process.env['NO_PROXY'] || '';
672672
const agent = new EnvHttpProxyAgent({
673-
noProxy: [existingNoProxy, 'localhost'].filter(Boolean).join(','),
673+
noProxy: [existingNoProxy, '127.0.0.1'].filter(Boolean).join(','),
674674
});
675675
const undiciPromise = import('undici');
676676
return async (url: string | URL, init?: RequestInit): Promise<Response> => {
@@ -841,5 +841,5 @@ export class IdeClient {
841841
function getIdeServerHost() {
842842
const isInContainer =
843843
fs.existsSync('/.dockerenv') || fs.existsSync('/run/.containerenv');
844-
return isInContainer ? 'host.docker.internal' : 'localhost';
844+
return isInContainer ? 'host.docker.internal' : '127.0.0.1';
845845
}

0 commit comments

Comments
 (0)