mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(ui): Block spaces and hyphens in MCP server names and aliases
- Update validateMCPServerName to reject both spaces and hyphens - Apply shared validation to alias field in create form (was inline) - Update tooltips to mention space restriction - Ensures consistency across create/edit forms for server_name and alias fields
This commit is contained in:
parent
2b00466d3a
commit
8fa2734830
2 changed files with 14 additions and 11 deletions
|
|
@ -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. 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
|
||||
|
|
|
|||
|
|
@ -47,7 +47,15 @@ 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.")
|
||||
: Promise.resolve();
|
||||
if (!value) return Promise.resolve();
|
||||
|
||||
if (value.includes("-")) {
|
||||
return Promise.reject("Server name cannot contain '-' (hyphen). Please use '_' (underscore) instead.");
|
||||
}
|
||||
|
||||
if (value.includes(" ")) {
|
||||
return Promise.reject("Server name cannot contain spaces. Please use '_' (underscore) instead.");
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue