summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts83
1 files changed, 76 insertions, 7 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 01e04d70..68f53873 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -9,7 +9,7 @@ import { type PartListUnion } from '@google/genai';
import open from 'open';
import process from 'node:process';
import { UseHistoryManagerReturn } from './useHistoryManager.js';
-import { Config } from '@gemini-code/core';
+import { Config, MCPServerStatus, getMCPServerStatus } from '@gemini-code/core';
import { Message, MessageType, HistoryItemWithoutId } from '../types.js';
import { createShowMemoryAction } from './useShowMemoryCommand.js';
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
@@ -138,9 +138,74 @@ export const useSlashCommandProcessor = (
},
},
{
+ name: 'mcp',
+ description: 'list configured MCP servers and tools',
+ action: async (_mainCommand, _subCommand, _args) => {
+ const toolRegistry = await config?.getToolRegistry();
+ if (!toolRegistry) {
+ addMessage({
+ type: MessageType.ERROR,
+ content: 'Could not retrieve tool registry.',
+ timestamp: new Date(),
+ });
+ return;
+ }
+
+ const mcpServers = config?.getMcpServers() || {};
+ const serverNames = Object.keys(mcpServers);
+
+ if (serverNames.length === 0) {
+ addMessage({
+ type: MessageType.INFO,
+ content: 'No MCP servers configured.',
+ timestamp: new Date(),
+ });
+ return;
+ }
+
+ let message = 'Configured MCP servers and tools:\n\n';
+
+ for (const serverName of serverNames) {
+ const serverTools = toolRegistry.getToolsByServer(serverName);
+ const status = getMCPServerStatus(serverName);
+
+ // Add status indicator
+ let statusDot = '';
+ switch (status) {
+ case MCPServerStatus.CONNECTED:
+ statusDot = '🟢'; // Green dot for connected
+ break;
+ case MCPServerStatus.CONNECTING:
+ statusDot = '🟡'; // Yellow dot for connecting
+ break;
+ case MCPServerStatus.DISCONNECTED:
+ default:
+ statusDot = '🔴'; // Red dot for disconnected
+ break;
+ }
+
+ message += `${statusDot} ${serverName} (${serverTools.length} tools):\n`;
+ if (serverTools.length > 0) {
+ serverTools.forEach((tool) => {
+ message += ` - ${tool.name}\n`;
+ });
+ } else {
+ message += ' No tools available\n';
+ }
+ message += '\n';
+ }
+
+ addMessage({
+ type: MessageType.INFO,
+ content: message,
+ timestamp: new Date(),
+ });
+ },
+ },
+ {
name: 'memory',
description:
- 'Manage memory. Usage: /memory <show|refresh|add> [text for add]',
+ 'manage memory. Usage: /memory <show|refresh|add> [text for add]',
action: (mainCommand, subCommand, args) => {
switch (subCommand) {
case 'show':
@@ -163,7 +228,7 @@ export const useSlashCommandProcessor = (
},
{
name: 'tools',
- description: 'list available tools',
+ description: 'list available Gemini CLI tools',
action: async (_mainCommand, _subCommand, _args) => {
const toolRegistry = await config?.getToolRegistry();
const tools = toolRegistry?.getAllTools();
@@ -175,10 +240,14 @@ export const useSlashCommandProcessor = (
});
return;
}
- const toolList = tools.map((tool) => tool.name);
+
+ // Filter out MCP tools by checking if they have a serverName property
+ const geminiTools = tools.filter((tool) => !('serverName' in tool));
+ const geminiToolList = geminiTools.map((tool) => tool.name);
+
addMessage({
type: MessageType.INFO,
- content: `Available tools:\n\n${toolList.join('\n')}`,
+ content: `Available Gemini CLI tools:\n\n${geminiToolList.join('\n')}`,
timestamp: new Date(),
});
},
@@ -191,7 +260,7 @@ export const useSlashCommandProcessor = (
},
{
name: 'about',
- description: 'Show version info',
+ description: 'show version info',
action: (_mainCommand, _subCommand, _args) => {
const osVersion = process.platform;
let sandboxEnv = 'no sandbox';
@@ -214,7 +283,7 @@ export const useSlashCommandProcessor = (
},
{
name: 'bug',
- description: 'Submit a bug report.',
+ description: 'submit a bug report',
action: (_mainCommand, _subCommand, args) => {
let bugDescription = _subCommand || '';
if (args) {