gemini-cli - 💡(How to fix) Fix Bug: ACP handshake requires numeric protocolVersion instead of string

Official PRs (…)
ON THIS PAGE

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…

Error Message

Because modern MCP clients send a date string, the Gemini CLI server rejects the request with a Zod type mismatch error, making it incompatible with standard MCP SDKs without manual transport-level interception.

Root Cause

Source code evidence from gemini-cli v0.38.2:

   1 var PROTOCOL_VERSION = 1;
   2 var zProtocolVersion = external_exports2.number().int().gte(0).lte(65535);

Because modern MCP clients send a date string, the Gemini CLI server rejects the request with a Zod type mismatch error, making it incompatible with standard MCP SDKs without manual transport-level interception.

Code Example

1 var PROTOCOL_VERSION = 1;
   2 var zProtocolVersion = external_exports2.number().int().gte(0).lte(65535);

---

> /about
│                                                      │
About Gemini CLI│                                                      │
CLI Version       0.38.2Git Commit        b0ed611a0                          │
Model             Auto (Gemini 3)Sandbox           no sandbox                         │
OS                darwin                             │
Auth Method     Signed in with Google                 (hpghjfs@gmail.com)Tier            Gemini Code Assist in Google One AIUltraGCP Project       silver-nova-466404-t6              │

---

{
    "jsonrpc": "2.0",
   "id": 1,
   "method": "initialize",
   "params": {
       "protocolVersion": "2024-11-05",
       "capabilities": {},
       "clientInfo": { "name": "test-client", "version": "1.0.0" }
    }
}
RAW_BUFFERClick to expand / collapse

What happened?

When attempting to connect to the Gemini CLI (v0.38.2) in --acp mode using the official @modelcontextprotocol/sdk (which follows the MCP 1.0 standard), the connection fails during the initialize handshake.

Investigation of the Gemini CLI source code reveals that protocolVersion is strictly validated as a number via a Zod schema, whereas the MCP specification defines it as a string (e.g., "2024-11-05").

Source code evidence from gemini-cli v0.38.2:

   1 var PROTOCOL_VERSION = 1;
   2 var zProtocolVersion = external_exports2.number().int().gte(0).lte(65535);

Because modern MCP clients send a date string, the Gemini CLI server rejects the request with a Zod type mismatch error, making it incompatible with standard MCP SDKs without manual transport-level interception.

What did you expect to happen?

The Gemini CLI should accept the standard MCP protocolVersion string (e.g., "2024-11-05" or "2025-06-18") during the ACP initialize handshake to ensure interoperability with the official Model Context Protocol ecosystem.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
│                                                      │
│ About Gemini CLI                                     │
│                                                      │
│ CLI Version       0.38.2                             │
│ Git Commit        b0ed611a0                          │
│ Model             Auto (Gemini 3)                    │
│ Sandbox           no sandbox                         │
│ OS                darwin                             │
│ Auth Method     Signed in with Google                │
│                 ([email protected])                  │
│ Tier            Gemini Code Assist in Google One AI  │
│                 Ultra                                │
│ GCP Project       silver-nova-466404-t6              │
</details>

Login information

Google Account

Anything else we need to know?

Reproduction Steps

  1. Start Gemini CLI in ACP mode: gemini --acp
  2. Send a standard MCP initialize request via stdin:
{
    "jsonrpc": "2.0",
   "id": 1,
   "method": "initialize",
   "params": {
       "protocolVersion": "2024-11-05",
       "capabilities": {},
       "clientInfo": { "name": "test-client", "version": "1.0.0" }
    }
}
  1. Observe the failure/crash due to protocolVersion expecting a number.

Impact

This blocks seamless integration between the Gemini CLI and standard-compliant MCP client libraries, forcing developers to implement "hacky" transport interceptors to coerce types.

extent analysis

TL;DR

Update the Gemini CLI to accept the protocolVersion as a string instead of a number to ensure compatibility with the MCP 1.0 standard.

Guidance

  • The issue arises from a type mismatch between the expected number and the sent string for the protocolVersion in the initialize handshake.
  • To verify the issue, send a standard MCP initialize request with a string protocolVersion and observe the failure.
  • A potential workaround is to modify the client-side code to send the protocolVersion as a number, but this would require changes to the MCP client libraries.
  • Another approach is to update the Gemini CLI to use a more permissive schema for the protocolVersion, allowing both numbers and strings.

Example

// Example of a modified initialize request with a numeric protocolVersion
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
        "protocolVersion": 1,
        "capabilities": {},
        "clientInfo": { "name": "test-client", "version": "1.0.0" }
    }
}

Notes

The provided solution assumes that the Gemini CLI can be updated to accept a string protocolVersion. If this is not possible, alternative workarounds such as transport-level interception may be necessary.

Recommendation

Apply a workaround by modifying the client-side code to send the protocolVersion as a number, as this is a more feasible short-term solution. However, it is recommended to update the Gemini CLI to accept the protocolVersion as a string in the long term to ensure compatibility with the MCP 1.0 standard.

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 Bug: ACP handshake requires numeric protocolVersion instead of string