gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

(gemini cli v0.1.15) If no mcp servers are installed, all /mcp commands kick off a new browser documentation tab each and every time

Open momoadeli opened this issue 1 year ago • 0 comments

What happened?

(gemini cli v0.1.15) If no mcp servers are installed, all /mcp commands kick off a new browser documentation tab each and every time

What did you expect to happen?

If there are no servers installed simply show:

"No MCP servers configured. Please view MCP documentation in your browser: https://goo.gle/gemini-cli-docs-mcp or use the cli /docs command"

Also note, there's also a gemini cli /docs command that will suffice

NOTE!: Please let me know if you'd like me to open a PR with code change I'm proposing below.

Client information

$ gemini 
>mcp (and any other option  of MCP)
# paste output here: A new browser tab is opened unnecessarily

Login information

No response

Anything else we need to know?

The issue is here:

https://github.com/google-gemini/gemini-cli/blob/23c014e29cbb3ac28e6fb02ef14d0538377f38ca/packages/cli/src/ui/commands/mcpCommand.ts#L63

if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') { return { type: 'message', messageType: 'info', content: No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}, }; } else { // Open the URL in the browser await open(docsUrl); return { type: 'message', messageType: 'info', content: No MCP servers configured. Opening documentation in your browser: ${docsUrl}, }; } }

Proposed change to mcpCommand block above. Remove sandbox checks and replace with mcp server length checks. Please let me know if you'd like me to open a PR:

const mcpServers = config.getMcpServers() || {}; const serverNames = Object.keys(mcpServers); const blockedMcpServers = config.getBlockedMcpServers() || [];

if (serverNames.length === 0 && blockedMcpServers.length === 0) { const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp'; // Simply return the informational message without opening a browser tab. return { type: 'message', messageType: 'info', content: No MCP servers configured. Please view MCP documentation in your browser: ${docsUrl} or use the cli /docs command, }; }

momoadeli avatar Jul 31 '25 10:07 momoadeli