gemini-cli - 💡(How to fix) Fix MCP server discovery failure: ByteString conversion error when using non-ASCII characters in headers [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#25668Fetched 2026-04-20 12:15:41
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

It appears that Gemini CLI attempts to convert these header values into a ByteString (restricted to 255), causing an overflow error when a Unicode character is encountered.

Code Example

"mcpServers": {
		"mcp": {
			"httpUrl": "https://mcp",
			"headers": {
				"X-Custom": "mąka",
			},
			"timeout": 60000
		},
RAW_BUFFERClick to expand / collapse

What happened?

The MCP server discovery process fails when the configuration headers contain non-ASCII characters (like 'ą'). It appears that Gemini CLI attempts to convert these header values into a ByteString (restricted to 255), causing an overflow error when a Unicode character is encountered.

Steps to Reproduce:

  1. Configure an MCP server in settings.json
"mcpServers": {
		"mcp": {
			"httpUrl": "https://mcp",
			"headers": {
				"X-Custom": "mąka",
			},
			"timeout": 60000
		},
  1. Trigger the discovery process for the server.

What did you expect to happen?

convert non-ascii characters automatically

Client information

  • CLI Version: 0.38.2
  • Git Commit: b0ed611a0
  • Session ID: 977679c3-feec-4261-98ad-bf1baf1720d6
  • Operating System: win32 v25.0.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-3.1-flash-lite-preview
  • Auth Type: oauth-personal
  • Memory Usage: 332.6 MB
  • Terminal Name: Unknown
  • Terminal Background: #0c0c0c
  • Kitty Keyboard Protocol: Unsupported

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

The MCP server discovery process can be fixed by ensuring configuration headers only contain ASCII characters or by properly handling Unicode characters in the ByteString conversion.

Guidance

  • Verify that the issue is indeed caused by non-ASCII characters in the configuration headers by testing with ASCII-only headers.
  • Consider updating the Gemini CLI to handle Unicode characters correctly, potentially by using a more suitable data type than ByteString.
  • As a temporary workaround, avoid using non-ASCII characters in configuration headers.
  • Test the discovery process with a modified settings.json file that contains only ASCII characters in the headers.

Example

"mcpServers": {
		"mcp": {
			"httpUrl": "https://mcp",
			"headers": {
				"X-Custom": "maka",
			},
			"timeout": 60000
		},

Notes

The provided information does not specify how the Gemini CLI handles Unicode characters, so a definitive fix may require additional details about the CLI's implementation.

Recommendation

Apply workaround: Avoid using non-ASCII characters in configuration headers, as this is a simple and effective way to prevent the overflow error until a more robust solution is available.

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