Skip to content

Commit 2736962

Browse files
committed
Fixes #4701 guards against missing config props
1 parent 119ebee commit 2736962

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,32 @@ export class GkMcpProvider implements McpServerDefinitionProvider, Disposable {
9595
return undefined;
9696
}
9797

98-
let output = await runCLICommand(['mcp', 'config', appName, '--source=gitlens', `--scheme=${env.uriScheme}`], {
99-
cwd: cliPath,
100-
});
101-
output = output.replace(CLIProxyMCPConfigOutputs.checkingForUpdates, '').trim();
102-
10398
try {
99+
let output = await runCLICommand(
100+
['mcp', 'config', appName, '--source=gitlens', `--scheme=${env.uriScheme}`],
101+
{
102+
cwd: cliPath,
103+
},
104+
);
105+
output = output.replace(CLIProxyMCPConfigOutputs.checkingForUpdates, '').trim();
106+
104107
const config: McpConfiguration = JSON.parse(output);
108+
if (!config.type || !config.command || !Array.isArray(config.args)) {
109+
throw new Error(`Invalid MCP configuration: missing required properties (${output})`);
110+
}
105111

106112
this.onRegistrationCompleted(cliInstall.version);
107113

108114
return {
109-
name: config.name,
115+
name: config.name ?? 'GitKraken',
110116
type: config.type,
111117
command: config.command,
112118
args: config.args,
113119
version: cliInstall.version,
114120
};
115121
} catch (ex) {
116122
Logger.error(`Error getting MCP configuration: ${ex}`);
117-
this.onRegistrationFailed('Error getting MCP configuration', undefined, cliInstall.version);
123+
this.onRegistrationFailed('Error getting MCP configuration', String(ex), cliInstall.version);
118124
}
119125

120126
return undefined;

0 commit comments

Comments
 (0)