mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-10 18:10:43 -07:00
fix(cli): include subagent-specific MCP tools in /mcp list display
Fixes #22884 Currently, /mcp list in interactive mode only retrieves tools from the main ToolRegistry. This means that MCP servers configured exclusively for a subagent (which exist in isolated registries) do not have their active tools displayed, even though the server correctly shows as 'Connected'. This commit introduces a unified `getAllDiscoveredMcpTools()`, `getAllDiscoveredPrompts()`, and `getAllDiscoveredResources()` methods in `McpClientManager` to aggregate these from all registered registries via `McpClient`. The `listAction` command has been updated to use these unified accessors, ensuring an accurate representation of all active MCP capabilities regardless of which registry they reside in.
This commit is contained in:
@@ -12,7 +12,6 @@ import type {
|
||||
import { CommandKind } from './types.js';
|
||||
import type { MessageActionReturn } from '@google/gemini-cli-core';
|
||||
import {
|
||||
DiscoveredMCPTool,
|
||||
getMCPDiscoveryState,
|
||||
getMCPServerStatus,
|
||||
MCPDiscoveryState,
|
||||
@@ -210,21 +209,18 @@ const listAction = async (
|
||||
discoveryState === MCPDiscoveryState.IN_PROGRESS ||
|
||||
connectingServers.length > 0;
|
||||
|
||||
const allTools = toolRegistry.getAllTools();
|
||||
const mcpTools = allTools.filter((tool) => tool instanceof DiscoveredMCPTool);
|
||||
const mcpClientManager = config.getMcpClientManager();
|
||||
const mcpTools = mcpClientManager
|
||||
? mcpClientManager.getAllDiscoveredMcpTools()
|
||||
: [];
|
||||
|
||||
const promptRegistry = config.getPromptRegistry();
|
||||
const mcpPrompts = promptRegistry
|
||||
.getAllPrompts()
|
||||
.filter(
|
||||
(prompt) =>
|
||||
'serverName' in prompt && serverNames.includes(prompt.serverName),
|
||||
);
|
||||
const mcpPrompts = mcpClientManager
|
||||
? mcpClientManager.getAllDiscoveredPrompts()
|
||||
: [];
|
||||
|
||||
const resourceRegistry = config.getResourceRegistry();
|
||||
const mcpResources = resourceRegistry
|
||||
.getAllResources()
|
||||
.filter((entry) => serverNames.includes(entry.serverName));
|
||||
const mcpResources = mcpClientManager
|
||||
? mcpClientManager.getAllDiscoveredResources()
|
||||
: [];
|
||||
|
||||
const authStatus: HistoryItemMcpStatus['authStatus'] = {};
|
||||
const tokenStorage = new MCPOAuthTokenStorage();
|
||||
|
||||
Reference in New Issue
Block a user