diff --git a/web/app/components/tools/mcp/modal.tsx b/web/app/components/tools/mcp/modal.tsx index b28a813152..357875d7c0 100644 --- a/web/app/components/tools/mcp/modal.tsx +++ b/web/app/components/tools/mcp/modal.tsx @@ -73,6 +73,10 @@ const MCPModal = ({ } } + const isValidServerID = (str: string) => { + return /^[a-z0-9_-]{1,24}$/.test(str) + } + const handleBlur = async (url: string) => { if (data) return @@ -99,7 +103,7 @@ const MCPModal = ({ Toast.notify({ type: 'error', message: 'invalid server url' }) return } - if (!serverIdentifier.trim()) { + if (!isValidServerID(serverIdentifier.trim())) { Toast.notify({ type: 'error', message: 'invalid server identifier' }) return }