Skip to content

Commit 67eb1a7

Browse files
Updates command and params
1 parent 8e760a6 commit 67eb1a7

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

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

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { arch } from 'process';
22
import type { ConfigurationChangeEvent } from 'vscode';
3-
import { Disposable, ProgressLocation, Uri, window, workspace } from 'vscode';
3+
import { Disposable, env, ProgressLocation, Uri, window, workspace } from 'vscode';
44
import type { Container } from '../../../../container';
55
import { registerCommand } from '../../../../system/-webview/command';
66
import { configuration } from '../../../../system/-webview/configuration';
@@ -231,13 +231,33 @@ export class GkCliIntegrationProvider implements Disposable {
231231
throw new Error(errorMsg);
232232
}
233233

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+
234254
// 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`;
237257

238258
// Configure the MCP server in settings.json
239259
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 });
241261
} catch {
242262
// Try alternative execution methods based on platform
243263
try {
@@ -251,17 +271,18 @@ export class GkCliIntegrationProvider implements Disposable {
251271
`"${mcpExtractedPath.fsPath}"`,
252272
'mcp',
253273
'install',
254-
'vscode',
255-
'--file-path',
256-
`"${settingsPath}"`,
274+
appName,
275+
/*'--file-path',
276+
settingsPath,*/
257277
],
258278
'utf8',
259279
);
260280
} else {
261281
// On Unix-like systems, try running with sh
262282
await run(
263283
'/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}`],
265286
'utf8',
266287
);
267288
}
@@ -273,28 +294,14 @@ export class GkCliIntegrationProvider implements Disposable {
273294
}
274295

275296
// 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';
295300
Logger.error(errorMsg);
296301
throw new Error(errorMsg);
297302
}
303+
304+
Logger.log('MCP configured successfully - GitKraken server verified in settings.json');
298305
} finally {
299306
// Always clean up downloaded/extracted files, even if something failed
300307
if (mcpInstallerPath != null) {

0 commit comments

Comments
 (0)