MCPcopy Create free account
hub / github.com/anus-dev/ANUS / establishConnection

Method establishConnection

packages/core/src/ide/ide-client.ts:371–397  ·  view source on GitHub ↗
(port: string)

Source from the content-addressed store, hash-verified

369 }
370
371 private async establishConnection(port: string): Promise<boolean> {
372 let transport: StreamableHTTPClientTransport | undefined;
373 try {
374 this.client = new Client({
375 name: 'streamable-http-client',
376 // TODO(#3487): use the CLI version here.
377 version: '1.0.0',
378 });
379 transport = new StreamableHTTPClientTransport(
380 new URL(`http://${getIdeServerHost()}:${port}/mcp`),
381 );
382 await this.client.connect(transport);
383 this.registerClientHandlers();
384 this.setState(IDEConnectionStatus.Connected);
385 return true;
386 } catch (_error) {
387 if (transport) {
388 try {
389 await transport.close();
390 } catch (closeError) {
391 logger.debug('Failed to close transport:', closeError);
392 }
393 }
394 logger.error(`Failed to connect: ${_error}`);
395 return false;
396 }
397 }
398}
399
400function getIdeServerHost() {

Callers 1

connectMethod · 0.95

Calls 6

setStateMethod · 0.95
getIdeServerHostFunction · 0.85
connectMethod · 0.80
closeMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected