From 061eada8c536ac51b8a3d4472c7970ecebd083ee Mon Sep 17 00:00:00 2001 From: JzoNg Date: Tue, 24 Jun 2025 16:53:57 +0800 Subject: [PATCH] server id validation --- web/app/components/tools/mcp/modal.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 }