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

Method connect

packages/core/src/ide/ide-client.ts:82–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 }
81
82 async connect(): Promise<void> {
83 if (!this.currentIde || !this.currentIdeDisplayName) {
84 this.setState(
85 IDEConnectionStatus.Disconnected,
86 `IDE integration is not supported in your current environment. To use this feature, run ANUS in one of these supported IDEs: ${Object.values(
87 DetectedIde,
88 )
89 .map((ide) => getIdeInfo(ide).displayName)
90 .join(', ')}`,
91 false,
92 );
93 return;
94 }
95
96 this.setState(IDEConnectionStatus.Connecting);
97
98 const { isValid, error } = IdeClient.validateWorkspacePath(
99 process.env['ANUS_CLI_IDE_WORKSPACE_PATH'],
100 this.currentIdeDisplayName,
101 process.cwd(),
102 );
103
104 if (!isValid) {
105 this.setState(IDEConnectionStatus.Disconnected, error, true);
106 return;
107 }
108
109 const portFromFile = await this.getPortFromFile();
110 if (portFromFile) {
111 const connected = await this.establishConnection(portFromFile);
112 if (connected) {
113 return;
114 }
115 }
116
117 const portFromEnv = this.getPortFromEnv();
118 if (portFromEnv) {
119 const connected = await this.establishConnection(portFromEnv);
120 if (connected) {
121 return;
122 }
123 }
124
125 this.setState(
126 IDEConnectionStatus.Disconnected,
127 `Failed to connect to IDE companion extension for ${this.currentIdeDisplayName}. Please ensure the extension is running. To install the extension, run /ide install.`,
128 true,
129 );
130 }
131
132 /**
133 * A diff is accepted with any modifications if the user performs one of the

Callers 9

startMethod · 0.80
ide-client.test.tsFile · 0.80
connectToMcpServerFunction · 0.80
establishConnectionMethod · 0.80
mainFunction · 0.80
testMCPConnectionFunction · 0.80
startMethod · 0.80
tryConnectFunction · 0.80

Calls 6

setStateMethod · 0.95
getPortFromFileMethod · 0.95
establishConnectionMethod · 0.95
getPortFromEnvMethod · 0.95
getIdeInfoFunction · 0.85
validateWorkspacePathMethod · 0.80

Tested by

no test coverage detected