Skip to content

Commit 8e6b21f

Browse files
committed
Uninstalls duplicate GK MCP servers
(#4626)
1 parent c00c630 commit 8e6b21f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/env/node/gk/mcp/integration.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class GkMcpProvider implements McpServerDefinitionProvider, Disposable {
109109
throw new Error(`Invalid MCP configuration: missing required properties (${output})`);
110110
}
111111

112-
this.onRegistrationCompleted(cliInstall.version);
112+
this.onRegistrationCompleted(cliPath, appName, cliInstall.version);
113113

114114
return {
115115
name: config.name ?? 'GitKraken',
@@ -126,10 +126,12 @@ export class GkMcpProvider implements McpServerDefinitionProvider, Disposable {
126126
return undefined;
127127
}
128128

129-
private onRegistrationCompleted(_cliVersion?: string | undefined) {
130-
if (!this.container.telemetry.enabled) return;
129+
private async onRegistrationCompleted(cliPath: string, appName: string, _cliVersion?: string) {
130+
if (this.container.telemetry.enabled) {
131+
this.container.telemetry.setGlobalAttribute('gk.mcp.registrationCompleted', true);
132+
}
131133

132-
this.container.telemetry.setGlobalAttribute('gk.mcp.registrationCompleted', true);
134+
await this.uninstallExternalMcp(cliPath, appName);
133135
}
134136

135137
private onRegistrationFailed(reason: string, message?: string | undefined, cliVersion?: string | undefined) {
@@ -142,4 +144,17 @@ export class GkMcpProvider implements McpServerDefinitionProvider, Disposable {
142144
'cli.version': cliVersion,
143145
});
144146
}
147+
148+
@debug()
149+
private async uninstallExternalMcp(cliPath: string, appName: string): Promise<void> {
150+
try {
151+
Logger.log(`Uninstalling external MCP configuration for ${appName}...`);
152+
const output = await runCLICommand(['mcp', 'uninstall', appName], {
153+
cwd: cliPath,
154+
});
155+
Logger.log(`External MCP configuration uninstalled successfully: ${output}`);
156+
} catch (ex) {
157+
Logger.warn(`Failed to uninstall external MCP configuration: ${ex}`);
158+
}
159+
}
145160
}

0 commit comments

Comments
 (0)