Validation to mcp server name (#12515)

* added validation

* add helper util
This commit is contained in:
Jugal D. Bhatt
2025-07-11 23:54:42 +05:30
committed by GitHub
parent 9f7847feb1
commit 7b44576216
6 changed files with 86 additions and 3 deletions
@@ -145,7 +145,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
label={
<span className="text-sm font-medium text-gray-700 flex items-center">
MCP Server Name
<Tooltip title="Best practice: Use a descriptive name that indicates the server's purpose (e.g., 'GitHub Integration', 'Email Service')">
<Tooltip title="Best practice: Use a descriptive name that indicates the server's purpose (e.g., 'GitHub_MCP', 'Email_Service'). Hyphens '-' are not allowed; use underscores '_' instead.">
<InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
</Tooltip>
</span>
@@ -153,10 +153,16 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
name="alias"
rules={[
{ required: false, message: "Please enter a server name" },
{
validator: (_, value) =>
value && value.includes('-')
? Promise.reject("Server name cannot contain '-' (hyphen). Please use '_' (underscore) instead.")
: Promise.resolve(),
},
]}
>
<TextInput
placeholder="e.g., GitHub MCP, Zapier MCP, etc."
placeholder="e.g., GitHub_MCP, Zapier_MCP, etc."
className="rounded-lg border-gray-300 focus:border-blue-500 focus:ring-blue-500"
/>
</Form.Item>
@@ -110,7 +110,12 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({ mcpServer, accessToken, o
<TabPanels className="mt-6">
<TabPanel>
<Form form={form} onFinish={handleSave} initialValues={mcpServer} layout="vertical">
<Form.Item label="MCP Server Name" name="alias">
<Form.Item label="MCP Server Name" name="alias" rules={[{
validator: (_, value) =>
value && value.includes('-')
? Promise.reject("Server name cannot contain '-' (hyphen). Please use '_' (underscore) instead.")
: Promise.resolve(),
}]}>
<TextInput />
</Form.Item>
<Form.Item label="Description" name="description">