summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/mcpCommand.ts
diff options
context:
space:
mode:
authorRamón Medrano Llamas <[email protected]>2025-07-25 03:14:45 +0200
committerGitHub <[email protected]>2025-07-25 01:14:45 +0000
commit273e74c09da89492d16fc076cfbff4d043eafa4c (patch)
treed68076b1139ac909b43eb9ba402e62238044d8d2 /packages/cli/src/ui/commands/mcpCommand.ts
parente9ee686ab6c5c99d895d80951336613f248f6560 (diff)
feat: add /mcp refresh command (#4566)
Diffstat (limited to 'packages/cli/src/ui/commands/mcpCommand.ts')
-rw-r--r--packages/cli/src/ui/commands/mcpCommand.ts47
1 files changed, 46 insertions, 1 deletions
diff --git a/packages/cli/src/ui/commands/mcpCommand.ts b/packages/cli/src/ui/commands/mcpCommand.ts
index c33a25d1..5467b994 100644
--- a/packages/cli/src/ui/commands/mcpCommand.ts
+++ b/packages/cli/src/ui/commands/mcpCommand.ts
@@ -417,12 +417,57 @@ const listCommand: SlashCommand = {
},
};
+const refreshCommand: SlashCommand = {
+ name: 'refresh',
+ description: 'Refresh the list of MCP servers and tools',
+ kind: CommandKind.BUILT_IN,
+ action: async (
+ context: CommandContext,
+ ): Promise<SlashCommandActionReturn> => {
+ const { config } = context.services;
+ if (!config) {
+ return {
+ type: 'message',
+ messageType: 'error',
+ content: 'Config not loaded.',
+ };
+ }
+
+ const toolRegistry = await config.getToolRegistry();
+ if (!toolRegistry) {
+ return {
+ type: 'message',
+ messageType: 'error',
+ content: 'Could not retrieve tool registry.',
+ };
+ }
+
+ context.ui.addItem(
+ {
+ type: 'info',
+ text: 'Refreshing MCP servers and tools...',
+ },
+ Date.now(),
+ );
+
+ await toolRegistry.discoverMcpTools();
+
+ // Update the client with the new tools
+ const geminiClient = config.getGeminiClient();
+ if (geminiClient) {
+ await geminiClient.setTools();
+ }
+
+ return getMcpStatus(context, false, false, false);
+ },
+};
+
export const mcpCommand: SlashCommand = {
name: 'mcp',
description:
'list configured MCP servers and tools, or authenticate with OAuth-enabled servers',
kind: CommandKind.BUILT_IN,
- subCommands: [listCommand, authCommand],
+ subCommands: [listCommand, authCommand, refreshCommand],
// Default action when no subcommand is provided
action: async (context: CommandContext, args: string) =>
// If no subcommand, run the list command