From 1519aaf8cc88a705c5462081eff8ae09ad61d25d Mon Sep 17 00:00:00 2001 From: octo-patch Date: Thu, 23 Apr 2026 10:30:28 +0800 Subject: [PATCH] fix: ensure MCP tool name prefix starts with a letter for Gemini compatibility (fixes #874) Math.random().toString(36) can produce strings starting with a digit (e.g. '4fzyo8'), causing Gemini to reject the request with INVALID_ARGUMENT. Gemini requires function names to start with a letter or underscore. Prepend 'm' to the random prefix so generated names always start with a letter, satisfying Gemini's constraint while preserving uniqueness. --- src/vs/workbench/contrib/void/electron-main/mcpChannel.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts b/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts index e5c4fb6e..c7fddd88 100644 --- a/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts +++ b/src/vs/workbench/contrib/void/electron-main/mcpChannel.ts @@ -230,7 +230,9 @@ export class MCPChannel implements IServerChannel { } private _addUniquePrefix(base: string) { - return `${Math.random().toString(36).slice(2, 8)}_${base}`; + // Prefix must start with a letter to satisfy Gemini's function name requirements: + // "Must start with a letter or an underscore" (alphanumeric, _, ., - only; max 64 chars) + return `m${Math.random().toString(36).slice(2, 8)}_${base}`; } private async _createClient(serverConfig: MCPConfigFileEntryJSON, serverName: string, isOn = true): Promise {