Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(ui): Block spaces and hyphens in MCP server names and aliases

Milan8fa2734830ca
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
index ff476bd999d..5099a826315 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx
@@ -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
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/utils.tsx b/ui/litellm-dashboard/src/components/mcp_tools/utils.tsx
index 5dcb80107ca..1d6ae540434 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/utils.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/utils.tsx
@@ -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();
};