Avoid MCP form ID collisions for distinct server names

This commit is contained in:
Gabrielsv01 2026-05-04 23:15:49 -03:00
parent f1737f7100
commit bc8c08d930

View file

@ -168,12 +168,9 @@ function toMCPServerType(value: unknown): MCPServerType {
}
function makeMCPServerID(name: string): string {
const normalized = name
.trim()
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
if (normalized.length > 0) {
return `mcp-${normalized}`
const encoded = encodeURIComponent(name)
if (encoded.length > 0) {
return `mcp-${encoded}`
}
return `mcp-${Math.random().toString(36).slice(2, 10)}`
}