gemini-cli - 💡(How to fix) Fix MCP servers remain "Disconnected" on Windows/WSL despite valid JSON-RPC responses via stdio/HTTP [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25992Fetched 2026-04-26 05:24:09
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×3labeled ×1
RAW_BUFFERClick to expand / collapse

What happened?

Environment:

  • OS: Windows 10/11
  • WSL: Ubuntu-22.04 (Docker Desktop backend)
  • Gemini CLI Version: 0.39.1
  • Node.js Version: v24.11.0

Description: I am experiencing a persistent issue where MCP servers configured to run through wsl.exe are always reported as Disconnected by the Gemini CLI, even though the commands are confirmed to be functional when executed manually.

Steps to Reproduce:

  1. Configure a server via WSL/Docker: gemini mcp add wikipedia -s user "C:\Windows\System32\wsl.exe -d Ubuntu-22.04 -- docker run -i --rm mcp/wikipedia-mcp"

  2. Check status: Run /mcp inside a session or gemini mcp list. Actual Result: ✗ wikipedia: ... (stdio) - Disconnected

  3. Manual verification (Proof of health): Piping an initialization header directly to the same command works perfectly: echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"capabilities": {}, "clientInfo": {"name": "test", "version": "1.0"}, "protocolVersion": "2024-11-05"}}' | C:\Windows\System32\wsl.exe -d Ubuntu-22.04 -- docker run -i --rm mcp/wikipedia-mcp Result: The server returns a valid JSON-RPC response. This confirms the issue is within the Gemini CLI's process management or stdio stream handling on Windows.

Additional Findings:

  • Argument Parsing: The gemini mcp add command parser appears to prematurely consume flags like -d or -- even when they are inside quotes.
  • HTTP Transport: Even when running the MCP server as an HTTP service inside WSL (verified via curl), Gemini CLI fails to connect using -t http.
  • Trust Loop: The CLI consistently reports the directory as "untrusted" even after running gemini trust.

What did you expect to happen?

I expected the Gemini CLI to successfully establish a stable stdio connection with the MCP server. Once configured, the server status should appear as 'Connected' in the /mcp list, and its tools should be fully accessible to the AI agent during the session. Additionally, I expected that after running gemini trust, the directory would be recognized as trusted and its specific MCP configurations would be applied correctly."

Tradução (para seu conhecimento): "Eu esperava que o Gemini CLI estabelecesse com sucesso uma conexão estável de stdio com o servidor MCP. Uma vez configurado, o status do servidor deveria aparecer como 'Conectado' na lista do /mcp, e suas ferramentas deveriam estar totalmente acessíveis para o agente de IA durante a sessão. Além disso, eu esperava que após rodar o 'gemini trust', o diretório fosse reconhecido como confiável e suas configurações específicas de MCP fossem aplicadas corretamente.

Client information

1 > /about (System Info) 2 Gemini CLI Version: 0.39.1 3 Node.js Version: v24.11.0 4 OS: win32 (Windows 10/11) 5 CWD: C:\Users\marco\Development 6 Trust Status: Untrusted (Project settings ignored) 7 MCP Servers Configured: 4 (user scope)

Login information

Logged in via Google Account using the /auth flow. Account plan: Gemini Code Assist in Google One AI Pro.

Anything else we need to know?

The same MCP servers (Wolfram Alpha and Wikipedia) are confirmed to be working perfectly within the same WSL environment when used with Claude Code. The issue seems specific to how Gemini CLI handles the stdio/HTTP lifecycle on the Windows host.

Also, there is a persistent 'Untrusted folder' warning that appears every time a new session starts, even after executing gemini trust multiple times. This suggests a potential issue with how settings and permissions are being persisted or read from %USERPROFILE%.gemini\settings.json on Windows.

extent analysis

TL;DR

The Gemini CLI may be experiencing issues with stdio connection management or argument parsing when running MCP servers through WSL, leading to a "Disconnected" status.

Guidance

  • Verify that the gemini mcp add command is correctly parsing the command arguments, especially when using flags like -d or -- inside quotes.
  • Check the Gemini CLI's handling of stdio streams on Windows, as the issue seems specific to this platform.
  • Investigate the "Untrusted folder" warning and its relation to the %USERPROFILE%\.gemini\settings.json file, as it may be connected to the MCP server connection issue.
  • Test the MCP servers with a different tool, like Claude Code, to confirm that the issue is specific to the Gemini CLI.

Example

No code snippet is provided, as the issue seems to be related to the Gemini CLI's internal workings and configuration.

Notes

The issue may be related to the Gemini CLI's version (0.39.1) or the Node.js version (v24.11.0) used. However, without further information, it's difficult to determine the exact cause.

Recommendation

Apply a workaround by testing the MCP servers with a different tool or configuration to isolate the issue, as the problem seems specific to the Gemini CLI's handling of stdio connections on Windows.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix MCP servers remain "Disconnected" on Windows/WSL despite valid JSON-RPC responses via stdio/HTTP [1 participants]