Skip to content

Conversation

axosoft-ramint
Copy link
Contributor

Closes #4357

@axosoft-ramint
Copy link
Contributor Author

Draft until issues with the installer itself are addressed by the team that maintains it.

@axosoft-ramint axosoft-ramint force-pushed the feature-mcp branch 2 times, most recently from 383578b to b4f75a9 Compare June 30, 2025 20:14
@axosoft-ramint axosoft-ramint marked this pull request as ready for review June 30, 2025 20:15
@axosoft-ramint axosoft-ramint force-pushed the feature-mcp branch 3 times, most recently from a72d602 to ae46eb1 Compare July 11, 2025 00:10
@axosoft-ramint axosoft-ramint force-pushed the feature-mcp branch 2 times, most recently from a134d87 to 97a6526 Compare July 18, 2025 17:52
@axosoft-ramint axosoft-ramint force-pushed the feature-mcp branch 2 times, most recently from 1c0ba9b to 1b59716 Compare August 26, 2025 17:43
@d13 d13 self-requested a review August 26, 2025 18:26
Copy link
Member

@eamodio eamodio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we are conflating the CLI install with MCP "setup" and they are different/distinct tasks that should be handled as such.

The auto-install is only of the CLI, not MCP, and we should attempt to "auto-install" the CLI until successful (or some number of successive failures)

Comment on lines 93 to 104
switch (env.appName) {
case 'Visual Studio Code':
break;
case 'Visual Studio Code - Insiders':
appName = 'vscode-insiders';
break;
case 'Cursor':
appName = 'cursor';
break;
case 'Windsurf':
appName = 'windsurf';
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reference in "VS Code - Exploration" (MS-provided adhoc build) and "VSCodium" (currently at 1.103.2) as well in other areas. Should we add these as well?

		case 'Visual Studio Code - Exploration':
			app = 'code-exploration';
			break;
		case 'VSCodium':
			app = 'codium';
			break;

Copy link
Contributor Author

@axosoft-ramint axosoft-ramint Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those aren't supported by the "mcp install" command for the time being and should hit the default case and fail for now.

If we want them supported we should ask the CLI team to add them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked in a new getHostAppName helper on main that we should use here. And IMO we should send whatever it is to the CLI and let them say its not supported, so that way the CLI can update and we dont need to for additional support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eamodio I am now using that helper. I still need to transform the app name from that helper because, for example, we use code and the command is expecting vscode, etc.

I also always continue to the command if the app name exists, and if they show an error in the output I send failure telemetry and kick out early. Check the latest commit.

@axosoft-ramint
Copy link
Contributor Author

I feel like we are conflating the CLI install with MCP "setup" and they are different/distinct tasks that should be handled as such.

The auto-install is only of the CLI, not MCP, and we should attempt to "auto-install" the CLI until successful (or some number of successive failures)

@eamodio This process is not installing a full-fledged GK CLI. It is installing something called "gk core", which is a lightweight version of the CLI designed to basically just support the MCP and a few other things. Should I still go ahead with calling all of this logic "install CLI"?

@axosoft-ramint axosoft-ramint requested a review from eamodio August 26, 2025 22:10
```typescript
{
'attempts': number,
'autoInstall': boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we get a version number or anything after the install? Because that would be great to have.

Comment on lines 2763 to 2801
### mcp/setup/completed

> Sent when GitKraken MCP setup is completed

```typescript
{
'requiresUserCompletion': boolean
}
```

### mcp/setup/failed

> Sent when GitKraken MCP setup fails

```typescript
{
'error.message': string,
'reason': string
}
```

### mcp/setup/started

> Sent when GitKraken MCP setup is started

```typescript
void
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure we have "source" plumbed in here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the cli version would be great too

Comment on lines +314 to +317
"gitlens.ai.mcp.install": {
"label": "Install GitKraken MCP Server",
"commandPalette": "gitlens:enabled && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we will want versions of this command to other usages (e.g. home, etc) so we can understand the usage and make sure source is correct

@axosoft-ramint axosoft-ramint requested a review from eamodio August 26, 2025 22:53
await window.withProgress(
{
location: ProgressLocation.Notification,
title: 'Setting up MCP integration...',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: 'Setting up MCP integration...',
title: 'Setting up the GitKraken MCP...',

Comment on lines 164 to 160
case CLIInstallErrorReason.WebEnvironmentUnsupported:
void window.showErrorMessage(
'MCP installation is not supported in the web environment.',
);
failureReason = 'web environment unsupported';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as a fallback, but we shouldn't allow the command on the Web and kick out at the start.

@@ -311,6 +311,10 @@
"icon": "$(sparkle)",
"commandPalette": "gitlens:enabled && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
},
"gitlens.ai.mcp.install": {
"label": "Install GitKraken MCP Server",
"commandPalette": "gitlens:enabled && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add isWeb (I think that is the context key) here to not show this on the web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not isWeb, or at least that's not working as intended because using && !isWeb in the "when" clause prevents the command from appearing even when I'm not on web.

Comment on lines 136 to 140
let cliInstall = this.container.storage.get('gk:cli:install');
let cliPath = this.container.storage.get('gk:cli:path');
let cliProxyFileExists = true;
if (cliPath != null) {
try {
await workspace.fs.stat(
Uri.joinPath(Uri.file(cliPath), getPlatform() === 'windows' ? 'gk.exe' : 'gk'),
);
} catch {
cliProxyFileExists = false;
}
}
if (cliInstall?.status !== 'completed' || cliPath == null || !cliProxyFileExists) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest delegating all of this to this.installCLI() as this will need to check these same things. And have that method return the path/install data this method needs.

Comment on lines 201 to 195
cliInstall = this.container.storage.get('gk:cli:install');
cliPath = this.container.storage.get('gk:cli:path');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHould be returned by this.installCLI

},
);
} catch (ex) {
let failureReason = 'unknown error';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let failureReason = 'unknown error';
'GitKraken MCP installation is not supported on the web.',

CLIInstallErrorReason.ProxyFetch,
undefined,
`${response.status} ${response.statusText}`,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to throw if this already exists right?

throw new CLIInstallError(
CLIInstallErrorReason.ProxyDownload,
undefined,
'Downloaded proxy archive data is empty',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the file already exists? We should overwrite it or nuke it first.

Comment on lines +441 to +452
CLIInstallErrorReason.CoreDirectory,
ex instanceof Error ? ex : undefined,
ex instanceof Error ? ex.message : undefined,
);
}

// Write the installer to the extension storage
try {
await workspace.fs.writeFile(cliProxyZipFilePath, new Uint8Array(cliProxyZipFileDownloadData));
} catch (ex) {
throw new CLIInstallError(
CLIInstallErrorReason.ProxyDownload,
ex instanceof Error ? ex : undefined,
'Failed to write proxy archive to global storage',
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels fragile -- maybe we should use an unzip lib?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we can deal with that later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to test this on linux

}
}

return cliVersion;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we care about the status if the path exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand this comment based on the line it's attached to

@axosoft-ramint
Copy link
Contributor Author

@eamodio I tried addressing as many of your comments as I could, but most of them don't make sense because the code they are attached to got shifted. Would you mind resubmitting any that I did not address, with the latest on the branch?

@axosoft-ramint axosoft-ramint requested a review from eamodio August 27, 2025 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install MCP server
3 participants