summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorN. Taylor Mullen <[email protected]>2025-06-23 22:35:23 +0100
committerGitHub <[email protected]>2025-06-23 21:35:23 +0000
commitfd58d3267ed50d25bb068678376dddf86aa007d8 (patch)
tree6578f501229f4c6918c590b6e6148d0c2b795583
parentdc76bcc433d58d879f8850ac777d2cd239dad611 (diff)
feat: Open MCP docs if no MCPs are configured (#1325)
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts33
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts20
2 files changed, 46 insertions, 7 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index 31105509..d411a2da 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -754,7 +754,8 @@ Add any other context about the problem here.
expect(commandResult).toBe(true);
});
- it('should display a message when no MCP servers are configured', async () => {
+ it('should display a message with a URL when no MCP servers are configured in a sandbox', async () => {
+ process.env.SANDBOX = 'sandbox';
mockConfig = {
...mockConfig,
getToolRegistry: vi.fn().mockResolvedValue({
@@ -773,11 +774,39 @@ Add any other context about the problem here.
2,
expect.objectContaining({
type: MessageType.INFO,
- text: 'No MCP servers configured.',
+ text: `No MCP servers configured. Please open the following URL in your browser to view documentation:\nhttps://goo.gle/gemini-cli-docs-mcp`,
}),
expect.any(Number),
);
expect(commandResult).toBe(true);
+ delete process.env.SANDBOX;
+ });
+
+ it('should display a message and open a URL when no MCP servers are configured outside a sandbox', async () => {
+ mockConfig = {
+ ...mockConfig,
+ getToolRegistry: vi.fn().mockResolvedValue({
+ getToolsByServer: vi.fn().mockReturnValue([]),
+ }),
+ getMcpServers: vi.fn().mockReturnValue({}),
+ } as unknown as Config;
+
+ const { handleSlashCommand } = getProcessor();
+ let commandResult: SlashCommandActionReturn | boolean = false;
+ await act(async () => {
+ commandResult = await handleSlashCommand('/mcp');
+ });
+
+ expect(mockAddItem).toHaveBeenNthCalledWith(
+ 2,
+ expect.objectContaining({
+ type: MessageType.INFO,
+ text: 'No MCP servers configured. Opening documentation in your browser: https://goo.gle/gemini-cli-docs-mcp',
+ }),
+ expect.any(Number),
+ );
+ expect(open).toHaveBeenCalledWith('https://goo.gle/gemini-cli-docs-mcp');
+ expect(commandResult).toBe(true);
});
it('should display configured MCP servers with status indicators and their tools', async () => {
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 2bc84a10..397c6e3c 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -291,11 +291,21 @@ export const useSlashCommandProcessor = (
const serverNames = Object.keys(mcpServers);
if (serverNames.length === 0) {
- addMessage({
- type: MessageType.INFO,
- content: 'No MCP servers configured.',
- timestamp: new Date(),
- });
+ const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
+ addMessage({
+ type: MessageType.INFO,
+ content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
+ timestamp: new Date(),
+ });
+ } else {
+ addMessage({
+ type: MessageType.INFO,
+ content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
+ timestamp: new Date(),
+ });
+ await open(docsUrl);
+ }
return;
}