diff --git a/packages/cli/src/ui/components/views/McpStatus.test.tsx b/packages/cli/src/ui/components/views/McpStatus.test.tsx
index 86dbc7bb36..8d448ff8f3 100644
--- a/packages/cli/src/ui/components/views/McpStatus.test.tsx
+++ b/packages/cli/src/ui/components/views/McpStatus.test.tsx
@@ -184,4 +184,18 @@ describe('McpStatus', () => {
expect(lastFrame()).toMatchSnapshot();
unmount();
});
+
+ it('truncates resources when exceeding limit', () => {
+ const manyResources = Array.from({ length: 25 }, (_, i) => ({
+ serverName: 'server-1',
+ name: `resource-${i + 1}`,
+ uri: `file:///tmp/resource-${i + 1}.txt`,
+ }));
+
+ const { lastFrame, unmount } = render(
+ ,
+ );
+ expect(lastFrame()).toContain('15 resources hidden');
+ unmount();
+ });
});
diff --git a/packages/cli/src/ui/components/views/McpStatus.tsx b/packages/cli/src/ui/components/views/McpStatus.tsx
index c153180371..0a3602cc3e 100644
--- a/packages/cli/src/ui/components/views/McpStatus.tsx
+++ b/packages/cli/src/ui/components/views/McpStatus.tsx
@@ -8,6 +8,7 @@ import type { MCPServerConfig } from '@google/gemini-cli-core';
import { MCPServerStatus } from '@google/gemini-cli-core';
import { Box, Text } from 'ink';
import type React from 'react';
+import { MAX_MCP_RESOURCES_TO_SHOW } from '../../constants.js';
import { theme } from '../../semantic-colors.js';
import type {
HistoryItemMcpStatus,
@@ -251,28 +252,40 @@ export const McpStatus: React.FC = ({
{serverResources.length > 0 && (
Resources:
- {serverResources.map((resource, index) => {
- const label = resource.name || resource.uri || 'resource';
- return (
-
-
- - {label}
- {resource.uri ? ` (${resource.uri})` : ''}
- {resource.mimeType ? ` [${resource.mimeType}]` : ''}
-
- {showDescriptions && resource.description && (
-
-
- {resource.description.trim()}
-
-
- )}
-
- );
- })}
+ {serverResources
+ .slice(0, MAX_MCP_RESOURCES_TO_SHOW)
+ .map((resource, index) => {
+ const label = resource.name || resource.uri || 'resource';
+ return (
+
+
+ - {label}
+ {resource.uri ? ` (${resource.uri})` : ''}
+ {resource.mimeType ? ` [${resource.mimeType}]` : ''}
+
+ {showDescriptions && resource.description && (
+
+
+ {resource.description.trim()}
+
+
+ )}
+
+ );
+ })}
+ {serverResources.length > MAX_MCP_RESOURCES_TO_SHOW && (
+
+ {' '}...{' '}
+ {serverResources.length - MAX_MCP_RESOURCES_TO_SHOW}{' '}
+ {serverResources.length - MAX_MCP_RESOURCES_TO_SHOW === 1
+ ? 'resource'
+ : 'resources'}{' '}
+ hidden
+
+ )}
)}
diff --git a/packages/cli/src/ui/constants.ts b/packages/cli/src/ui/constants.ts
index 143cda002c..9bd4cf1b34 100644
--- a/packages/cli/src/ui/constants.ts
+++ b/packages/cli/src/ui/constants.ts
@@ -25,3 +25,6 @@ export const TOOL_STATUS = {
CANCELED: '-',
ERROR: 'x',
} as const;
+
+// Maximum number of MCP resources to display per server before truncating
+export const MAX_MCP_RESOURCES_TO_SHOW = 10;