diff options
| author | Ramón Medrano Llamas <[email protected]> | 2025-08-19 21:03:19 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-19 19:03:19 +0000 |
| commit | b24c5887c45edde8690b4d73d8961e63eee13a34 (patch) | |
| tree | 6136f1f6bcc61801edb9f6d6411966b3b6678984 /packages/cli/src | |
| parent | 4828e4daf198a675ce118cec08dcfbd0bfbb28a6 (diff) | |
feat: restart MCP servers on /mcp refresh (#5479)
Co-authored-by: Brian Ray <[email protected]>
Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/ui/commands/mcpCommand.test.ts | 5 | ||||
| -rw-r--r-- | packages/cli/src/ui/commands/mcpCommand.ts | 6 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/atCommandProcessor.test.ts | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/packages/cli/src/ui/commands/mcpCommand.test.ts b/packages/cli/src/ui/commands/mcpCommand.test.ts index 6e48c2f9..09b97bb0 100644 --- a/packages/cli/src/ui/commands/mcpCommand.test.ts +++ b/packages/cli/src/ui/commands/mcpCommand.test.ts @@ -972,6 +972,7 @@ describe('mcpCommand', () => { it('should refresh the list of tools and display the status', async () => { const mockToolRegistry = { discoverMcpTools: vi.fn(), + restartMcpServers: vi.fn(), getAllTools: vi.fn().mockReturnValue([]), }; const mockGeminiClient = { @@ -1004,11 +1005,11 @@ describe('mcpCommand', () => { expect(context.ui.addItem).toHaveBeenCalledWith( { type: 'info', - text: 'Refreshing MCP servers and tools...', + text: 'Restarting MCP servers...', }, expect.any(Number), ); - expect(mockToolRegistry.discoverMcpTools).toHaveBeenCalled(); + expect(mockToolRegistry.restartMcpServers).toHaveBeenCalled(); expect(mockGeminiClient.setTools).toHaveBeenCalled(); expect(context.ui.reloadCommands).toHaveBeenCalledTimes(1); diff --git a/packages/cli/src/ui/commands/mcpCommand.ts b/packages/cli/src/ui/commands/mcpCommand.ts index 686102be..9e321937 100644 --- a/packages/cli/src/ui/commands/mcpCommand.ts +++ b/packages/cli/src/ui/commands/mcpCommand.ts @@ -471,7 +471,7 @@ const listCommand: SlashCommand = { const refreshCommand: SlashCommand = { name: 'refresh', - description: 'Refresh the list of MCP servers and tools', + description: 'Restarts MCP servers.', kind: CommandKind.BUILT_IN, action: async ( context: CommandContext, @@ -497,12 +497,12 @@ const refreshCommand: SlashCommand = { context.ui.addItem( { type: 'info', - text: 'Refreshing MCP servers and tools...', + text: 'Restarting MCP servers...', }, Date.now(), ); - await toolRegistry.discoverMcpTools(); + await toolRegistry.restartMcpServers(); // Update the client with the new tools const geminiClient = config.getGeminiClient(); diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts index 5509d9ff..7403f788 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts @@ -63,6 +63,12 @@ describe('handleAtCommand', () => { isPathWithinWorkspace: () => true, getDirectories: () => [testRootDir], }), + getMcpServers: () => ({}), + getMcpServerCommand: () => undefined, + getPromptRegistry: () => ({ + getPromptsByServer: () => [], + }), + getDebugMode: () => false, } as unknown as Config; const registry = new ToolRegistry(mockConfig); |
