Avoid MCP form ID collisions for distinct server names
This commit is contained in:
parent
f1737f7100
commit
bc8c08d930
1 changed files with 3 additions and 6 deletions
|
|
@ -168,12 +168,9 @@ function toMCPServerType(value: unknown): MCPServerType {
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeMCPServerID(name: string): string {
|
function makeMCPServerID(name: string): string {
|
||||||
const normalized = name
|
const encoded = encodeURIComponent(name)
|
||||||
.trim()
|
if (encoded.length > 0) {
|
||||||
.toLowerCase()
|
return `mcp-${encoded}`
|
||||||
.replace(/[^a-z0-9]+/g, "-")
|
|
||||||
if (normalized.length > 0) {
|
|
||||||
return `mcp-${normalized}`
|
|
||||||
}
|
}
|
||||||
return `mcp-${Math.random().toString(36).slice(2, 10)}`
|
return `mcp-${Math.random().toString(36).slice(2, 10)}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue