feat(extensions) - Add local/remote for mcp servers (#8355)

Co-authored-by: Shi Shu <shii@google.com>
This commit is contained in:
shishu314
2025-09-15 11:11:14 -04:00
committed by GitHub
parent c1de070a5e
commit 7470133a13
2 changed files with 44 additions and 2 deletions

View File

@@ -585,6 +585,45 @@ describe('installExtension', () => {
expect(logger?.logExtensionInstallEvent).toHaveBeenCalled();
});
it('should show users information on their mcp server when installing', async () => {
const consoleInfoSpy = vi.spyOn(console, 'info');
const sourceExtDir = createExtension({
extensionsDir: tempHomeDir,
name: 'my-local-extension',
version: '1.0.0',
mcpServers: {
'test-server': {
command: 'node',
args: ['server.js'],
description: 'a local mcp server',
},
'test-server-2': {
description: 'a remote mcp server',
httpUrl: 'https://google.com',
},
},
});
mockQuestion.mockImplementation((_query, callback) => callback('y'));
await expect(
installExtension({ source: sourceExtDir, type: 'local' }),
).resolves.toBe('my-local-extension');
expect(consoleInfoSpy).toHaveBeenCalledWith(
'This extension will run the following MCP servers: ',
);
expect(consoleInfoSpy).toHaveBeenCalledWith(
' * test-server (local): a local mcp server',
);
expect(consoleInfoSpy).toHaveBeenCalledWith(
' * test-server-2 (remote): a remote mcp server',
);
expect(consoleInfoSpy).toHaveBeenCalledWith(
'The extension will append info to your gemini.md context',
);
});
it('should continue installation if user accepts prompt for local extension with mcp servers', async () => {
const sourceExtDir = createExtension({
extensionsDir: tempHomeDir,

View File

@@ -481,8 +481,11 @@ export async function installExtension(
);
if (mcpServerEntries.length) {
console.info('This extension will run the following MCP servers: ');
for (const [key, value] of mcpServerEntries) {
console.info(` * ${key}: ${value.description}`);
for (const [key, mcpServer] of mcpServerEntries) {
const isLocal = !!mcpServer.command;
console.info(
` * ${key} (${isLocal ? 'local' : 'remote'}): ${mcpServer.description}`,
);
}
console.info(
'The extension will append info to your gemini.md context',