mirror of
https://github.com/voideditor/void
synced 2026-05-24 01:48:25 +00:00
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.
This commit is contained in:
parent
b68d519314
commit
1519aaf8cc
1 changed files with 3 additions and 1 deletions
|
|
@ -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<ClientInfo> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue