Merge pull request #21074 from milan-berri/fix/mcp-server-name-validation-spaces

fix(ui): Block spaces and hyphens in MCP server names and aliases
This commit is contained in:
yuneng-jiang 2026-02-12 15:35:18 -08:00 committed by GitHub
commit 3cbb12b9c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 10 deletions

View file

@ -429,7 +429,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_MCP', 'Email_Service'). Hyphens '-' are not allowed; use underscores '_' instead. Names must comply with SEP-986 and will be rejected if invalid (https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names).">
<Tooltip title="Best practice: Use a descriptive name that indicates the server's purpose (e.g., 'GitHub_MCP', 'Email_Service'). Cannot contain spaces or hyphens; use underscores instead. Names must comply with SEP-986 and will be rejected if invalid (https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names).">
<InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
</Tooltip>
</span>
@ -450,7 +450,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
label={
<span className="text-sm font-medium text-gray-700 flex items-center">
Alias
<Tooltip title="A short, unique identifier for this server. Defaults to the server name with spaces replaced by underscores.">
<Tooltip title="A short, unique identifier for this server. Defaults to the server name if not provided. Cannot contain spaces or hyphens; use underscores instead.">
<InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
</Tooltip>
</span>
@ -458,12 +458,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
name="alias"
rules={[
{ required: false },
{
validator: (_, value) =>
value && value.includes("-")
? Promise.reject("Alias cannot contain '-' (hyphen). Please use '_' (underscore) instead.")
: Promise.resolve(),
},
{ validator: (_, value) => validateMCPServerName(value) },
]}
>
<TextInput

View file

@ -47,7 +47,7 @@ export const validateMCPServerUrl = (value: string) => {
};
export const validateMCPServerName = (value: string) => {
return value && value.includes("-")
? Promise.reject("Server name cannot contain '-' (hyphen). Please use '_' (underscore) instead.")
return value && (value.includes("-") || value.includes(" "))
? Promise.reject("Cannot contain '-' (hyphen) or spaces. Please use '_' (underscore) instead.")
: Promise.resolve();
};