1
1
import { arch } from 'process' ;
2
2
import type { ConfigurationChangeEvent } from 'vscode' ;
3
- import { Disposable , ProgressLocation , Uri , window , workspace } from 'vscode' ;
3
+ import { Disposable , env , ProgressLocation , Uri , window , workspace } from 'vscode' ;
4
4
import type { Container } from '../../../../container' ;
5
5
import { registerCommand } from '../../../../system/-webview/command' ;
6
6
import { configuration } from '../../../../system/-webview/configuration' ;
@@ -231,13 +231,33 @@ export class GkCliIntegrationProvider implements Disposable {
231
231
throw new Error ( errorMsg ) ;
232
232
}
233
233
234
+ // Get the app name
235
+ let appName = 'vscode' ;
236
+ switch ( env . appName ) {
237
+ case 'Visual Studio Code' :
238
+ case 'Visual Studio Code - Insiders' :
239
+ appName = 'vscode' ;
240
+ break ;
241
+ case 'Cursor' :
242
+ appName = 'cursor' ;
243
+ break ;
244
+ case 'Windsurf' :
245
+ appName = 'windsurf' ;
246
+ break ;
247
+ default : {
248
+ const errorMsg = `Failed to install MCP: unsupported app name - ${ env . appName } ` ;
249
+ Logger . error ( errorMsg ) ;
250
+ throw new Error ( errorMsg ) ;
251
+ }
252
+ }
253
+
234
254
// Get the VS Code settings.json file path
235
- // TODO: Make this path point to the current vscode profile's settings.json once the API supports it
236
- const settingsPath = `${ this . container . context . globalStorageUri . fsPath } \\..\\..\\settings.json` ;
255
+ // TODO: Use this path to point to the current vscode profile's settings.json once the API supports it.
256
+ // const settingsPath = `${this.container.context.globalStorageUri.fsPath}\\..\\..\\settings.json`;
237
257
238
258
// Configure the MCP server in settings.json
239
259
try {
240
- await run ( mcpExtractedPath . fsPath , [ 'mcp' , 'install' , 'vscode' , '--file-path' , settingsPath ] , 'utf8' ) ;
260
+ await run ( 'gk.exe' , [ 'mcp' , 'install' , appName /* , '--file-path', settingsPath*/ ] , 'utf8' , { cwd : mcpExtractedFolderPath . fsPath } ) ;
241
261
} catch {
242
262
// Try alternative execution methods based on platform
243
263
try {
@@ -251,17 +271,18 @@ export class GkCliIntegrationProvider implements Disposable {
251
271
`"${ mcpExtractedPath . fsPath } "` ,
252
272
'mcp' ,
253
273
'install' ,
254
- 'vscode' ,
255
- '--file-path' ,
256
- `" ${ settingsPath } "` ,
274
+ appName ,
275
+ /* '--file-path',
276
+ settingsPath,*/
257
277
] ,
258
278
'utf8' ,
259
279
) ;
260
280
} else {
261
281
// On Unix-like systems, try running with sh
262
282
await run (
263
283
'/bin/sh' ,
264
- [ '-c' , `"${ mcpExtractedPath . fsPath } " mcp install vscode --file-path "${ settingsPath } "` ] ,
284
+ // ['-c', `"${mcpExtractedPath.fsPath}" mcp install vscode --file-path "${settingsPath}"`],
285
+ [ '-c' , `"${ mcpExtractedPath . fsPath } " mcp install ${ appName } ` ] ,
265
286
'utf8' ,
266
287
) ;
267
288
}
@@ -273,28 +294,14 @@ export class GkCliIntegrationProvider implements Disposable {
273
294
}
274
295
275
296
// Verify that the MCP server was actually configured in settings.json
276
- try {
277
- const settingsUri = Uri . file ( settingsPath ) ;
278
- const settingsData = await workspace . fs . readFile ( settingsUri ) ;
279
- const settingsJson = JSON . parse ( settingsData . toString ( ) ) ;
280
-
281
- if ( ! settingsJson ?. [ 'mcp' ] ?. [ 'servers' ] ?. [ 'GitKraken' ] ) {
282
- const errorMsg = 'MCP server configuration verification failed: Unable to update MCP settings' ;
283
- Logger . error ( errorMsg ) ;
284
- throw new Error ( errorMsg ) ;
285
- }
286
-
287
- Logger . log ( 'MCP configured successfully - GitKraken server verified in settings.json' ) ;
288
- } catch ( verifyError ) {
289
- if ( verifyError instanceof Error && verifyError . message . includes ( 'verification failed' ) ) {
290
- // Re-throw verification errors as-is
291
- throw verifyError ;
292
- }
293
- // Handle file read/parse errors
294
- const errorMsg = `Failed to verify MCP configuration in settings.json: ${ verifyError } ` ;
297
+ const setting = workspace . getConfiguration ( 'mcp.servers.GitKraken' ) ;
298
+ if ( ! setting ?. get ( 'type' ) || ! setting ?. get ( 'args' ) || ! setting ?. get ( 'command' ) ) {
299
+ const errorMsg = 'MCP server configuration verification failed: Unable to update MCP settings' ;
295
300
Logger . error ( errorMsg ) ;
296
301
throw new Error ( errorMsg ) ;
297
302
}
303
+
304
+ Logger . log ( 'MCP configured successfully - GitKraken server verified in settings.json' ) ;
298
305
} finally {
299
306
// Always clean up downloaded/extracted files, even if something failed
300
307
if ( mcpInstallerPath != null ) {
0 commit comments